I use Ivy to resolve OSGi bundles, like org.eclipse.jdt:
<dependencies>
<dependency org="bundle" name="org.eclipse.jdt" rev="x.y.z"/>
</dependencies>
It works fine and gives me all mandatory dependencies.
My question is, how can I select some (not all) optional dependencies of transitive bundles?
I can:
Select optional dependencies of org.eclipse.jdt by activating use_xxx configuration
Select all optional dependencies using transitive-optional configuration
What I actually need is a possibility to globally activate a configuration use_yyy. Globally means (applying to all transitive dependencies):
If a module doesn't have this configuration, do nothing
If a module does have this configuration, activate it
Related
I am using ant as a build tool and using Ivy for dependency management.
<dependency conf="compile->master;runtime->default" org="org.springframework" name="spring-web" rev="5.1.6.RELEASE"/>
<dependency conf="compile->master;runtime->default" org="io.projectreactor.netty" name="reactor-netty" rev="0.9.6.RELEASE"/>
Now when I give ant build it is failing to find the jar, the problem is it is attaching linux-x86_64.
It is searching for below jar
http://companyRepo:8081/nexus/content/groups/OfficialDevelopment/io/netty/netty-transport-native-epoll/4.1.48.Final/netty-transport-native-epoll-4.1.48.Final-linux-x86_64.jar
Why is it searching for linux-x86_64 ?
I searched and found similar issues but not sure on the solution.
https://github.com/netty/netty/issues/7101
How to build netty-transport-native-epoll-4.0.32.Final-linux-x86_64.jar?
I have no idea about ant but its basically the "classifier". Please check the ant /ivy documentation on how you can specify a classifier
I'm not an Ivy user, but I believe you need to add a dependency for netty-transport-native-epoll with a nested artifact for the classified native libraries. Something like this:
<dependency org="io.netty" name="netty-transport-native-epoll" rev="4.1.48.Final">
<artifact name="netty-transport-native-epoll"/>
<artifact name="netty-transport-native-epoll" e:classifier="linux-x86_64"/>
</dependency>
I usually use https://mvnrepository.com/ to figure out different dependency syntaxes, and the Ivy descriptors are included, but it seems that, unlike Nexus et. al., it does not support searching by classifier.
I am using Spring Boot JPA example and in the pom.xml we've configured to completely exclude the packages to to be removed during static code analysis.
<properties>
<java.version>1.8</java.version>
<sonar.exclusions>
**/enums/**/*,**/entity/**/*,**/constant/**/*,**/dto/**/*,**/repository/**/*
</sonar.exclusions>
<sonar.test.exclusions>**/test/**</sonar.test.exclusions>
</properties>
But we've seen that these packages are not getting excluded. Any pointers why ?
Follow this procedure to exclude these packages:
Click on your project name in SonarQube -> Administration -> General Settings -> Analysis Scope -> Source File Exclusions (You can put the file pattern in the text box)
This will skip the files which matches the given pattern.
I have a project that makes use of some third-party libraries. Some of these drag in transitive dependencies that have actually several artifacts in the repository:
module-1.2.jar
module-1.2-sources.jar
module-1.2-tests.jar
My investigations tought me that these seem to be Maven build artifacts that where propagated with a classifier. Now it seems that IVY is well able to handle the sources file but when I declare a dependency like this, it appears that the wrong jar is selected:
<dependency org="acme" module="module" rev="1.2"/>
When I do a resolve in ANT like this
<ivy:resolve conf="${ivy.non.test.confs}" validate="false" refresh="true" />
<ivy:retrieve conf="${ivy.non.test.confs}" pattern="${build.lib}/[conf]/[artifact].[ext]" sync="true" />
it happens that the module-1.2-tests.jar is selected as resolve target and retrieved under the name of the actual jar name (module-1.2.jar in this example).
What am I doing wrong here?
I got a strange problem. I added Guava to my ivy.xml as the following:
<dependency org="com.google.guava" name="guava" rev="14.0.1" conf="test"/>
When I run ant, I can see it's resolved:
[ivy:retrieve] found com.google.guava#guava;14.0.1 in default
And I can find the file in the ~/.ivy2/cache. But it didn't get copied to my lib directory.
Other dependencies have no problem....Any advice? Thanks.
Specify the configuration mapping in ivy.xml
I had the same problem and couldn't for the life of me figure out where the dependencies were downloaded to. Ivy seemed to suggest it was downloaded, and there were some entries in the cache, but nothing was appearing in my /lib.
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| compile | 2 | 2 | 2 | 0 || 0 | 0 |
---------------------------------------------------------------------
But everything changed when I saw this answer.
In ivy.xml, you have to specify the configuration mapping conf="myconfig->default", the key being ->default
<configurations>
<conf name="myconfig" description="Required for JSF"/>
</configurations>
<dependencies>
<dependency conf="myconfig->default" name="jsf-api" org="com.sun.faces" rev="2.2.13"/>
</dependencies>
This will map your user-defined configuration to a Maven scope (to be exact, the default scope). In practice, you will only use either default or master scope (source).
See:
Official description: http://ant.apache.org/ivy/history/2.2.0/ivyfile/configurations.html
IMHO a clearer explanation: http://wrongnotes.blogspot.sg/2014/02/simplest-explanation-of-ivy.html
This answer discusses maven scopes other than default: https://stackoverflow.com/a/7116577/4212710
My gut feel is that this is only required if you are pointing to an Maven repository. I have not tried otherwise.
If you have already done this and it still does not download, perhaps #javabrett's answer can help.
If you truly used <ivy:retrieve />, not just resolve, then it's probably because you need to use conf="test->default" ?
This is caused by the Maven packaging-type for com.google.guava:guava:14.0.1 being the OSGi bundle rather than jar. There is an Ivy bug for this that has been resolved, but the solution is not complete.
You need to avoid specifying type="jar" and instead use type="jar,bundle" if you want to download both package-types.
See also this question and the POM definition.
I have 3 maven projects: first - "A" with packaging jar, second - "B" packaging jar, third - "C" packaging jar. "C" depends on "B" as compile time dependency, "B" depends on "A" also as compile time dependency. Project "C" also uses classes from "A". So I have transitive dependency C -> B -> A. But when I try to build these projects maven failed with compilation error while compiling project C: it can't find classes from project "A" that is used in "C".
I thought that maven resolves transitive dependency. Why I get such an error?
Maven resolves transitive dependencies, but will not (usually) automatically build them for you. You can get maven to do what you want by supplying the --also-make/-am flag along with the project list:
mvn -am -pl C clean install
This assumes that A, B, C are all modules of a shared parent, and you would be running the command above in the parent's directory.
The failure of transitive dependency in Maven occurs due to many reason. You need to enable debugging option for that.
I faced similar issue. I am using eclipse. To enable debug option for maven in eclipse: Windows->Preference->Maven->Tick mark Debug Output
Error in my project was:
[WARNING] The POM for mil-pop2:java-json:jar:1.0 is invalid, transitive dependencies (if any) will not be available: 4 problems were encountered while building the effective model for mil-pop2:java-json:1.0
[ERROR] 'dependencies.dependency.systemPath' for java-json.jar:java-json.jar:jar must specify an absolute path but is ${project.basedir}/src/main/resources/lib/java-json.jar #
The reason for failure in transitive dependency is the project in which we are dependent inherits the jar from custom path rather than local repository. Remove the custom path if you have provided.
Before :
<dependency>
<groupId>java-json</groupId>
<artifactId>java-json.jar</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/java-json.jar</systemPath>
</dependency>
After:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
This solved my error.