I've a simple ivy.xml file:
<dependencies>
<dependency org="javax.validation" name="validation-api" rev="1.0.0.GA" conf="compile->master,sources"/>
</dependencies>
where compile is my configuration name, and master,sources are the mapped Maven types.
This is resolved correctly and give me these files:
validation-api-1.0.0.GA.jar
validation-api-1.0.0.GA-sources.jar
Now, i've to add this dependency:
<dependency org="com.google.gwt" name="gwt-user" rev="2.8.1" conf="compile->default"/>
which has validation-api as its dependecy, the same i specified at the top.
Ivy resolves this giving me these files:
gwt-user-2.8.1.jar
<its dependecies>
validation-api-1.0.0.GA-sources.jar
but this time the file validation-api-1.0.0.GA.jar is not retrieved.
Why?
I think this file is not in conflict... what should i do to have gwt-user and the validation-api jars (binary and source)?
This happens mainly due to the way configurations are declared in the ivy xmls. If you are dealing with a Maven artifact, it's very common that the ivy xml generated from the Maven artifact uses a different conf tag for the dependency. You are resolving the "default" conf of gwt-user. Normally, "default" extends "master, runtime". So, if validation-api-1.0.0.GA was declared under "master" or "runtime" conf in gwt-user's ivy.xml, it would have got resolved.
In order to give more accurate answer, I need the part of your ivy.xml as well as the ivy.xml of gwt-user
Related
I need to resolve a jcuda native library via Ivy, but I'm having some trouble finding the right way to define the dependency.
I'm using Artifactory for my dependency management, and it properly identified and resolved the individual native library versions for all available plaforms (see screenshot):
However, I am stuck at the resolution of the
The error produced by Ivy shows the correct resolution path.
I found a hint in the original Maven definition for these libraries (found in my local Ivy cache, %HOME%\.ivy2\cache\org.jcuda\jcuda-natives\windows-x86_64\ivy-0.8.0.xml.original), which used the following classifier:
<classifier>${jcuda.os}-${jcuda.arch}</classifier>
In my Ivy configurations, I don't distinguish OS and architecture, but using the catenated classifier gives me windows-x86_64, which is the jar file I'm looking for.
I needed to add the Maven namespace (xmlns:maven="http://maven.apache.org") to ivy.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<ivy-module version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd" xmlns:maven="http://maven.apache.org">
And then the following dependency can use maven:classifier to resolve the specific native library I'm looking for:
<dependency org="org.jcuda" name="jcuda-natives" rev="0.8.0">
<artifact maven:classifier="windows-x86_64" ext="jar" />
</dependency>
I have an eclipse project with IvyDE managed dependencies
My IvyDE is something like:
<ivy-module version="2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
<info organisation="R01"
module="myModule"
status="integration">
</info>
<configurations>
<conf name="compile" description="Used only at compile time; not deployed to the server" />
<conf name="runtime" extends="compile" description="Deployed to the server"/>
</configurations>
<dependencies>
<dependency org="com.sun.jersey" name="jersey-core" rev="1.9.1" conf="runtime"/>
<dependency org="javax.ws.rs" name="jsr311-api" rev="1.1.1" conf="compile"/>
</dependencies>
</ivy-module>
I have dependencies needed at compile-time and dependencies needed at runtime
I don't know if this is possible with apache IVY in eclipse (IvyDE) but I want to deploy to the server ONLY the RUNTIME-dependencies.
Now the only solution I've found is:
set IvyDE to resolve ALL (compile + runtime) dependencies and set the module classpath
add the [Ivy] library to the [DeploymentAssembly] at the project properties
This way all the dependencies (including the compile-time dependencies) are deployed to the server...
Is there any way to achieve this???
Thanks in advance
I answer my own question.
Finally I managed to get have TWO different ivy-managed classpath libraries, one used at compile-time and the other at run-time
The trick is include TWO ivyDE-managed dependencies:
One ivyDE managed dependency should be for COMPILE configuration and the other for RUNTIME configuration:
(repeat for the RUNTIME configuration)
Then it's only a matter of setting:
ivy dependency for COMPILE config should be a [Project Library]
ivy dependency for RUNTIME config should be at [Deployment Assembly]
That's all!
To work with Xuggler you need xuggle-xuggler-5.4.jar. According to the people who made this, most users only need the above-mentioned JAR file. However, this is what they say about using Xuggler without Maven or Ivy:
Using Xuggler WITHOUT Apache Maven or Apache Ivy
What are you... stuck
in 2003? Anyway, if you insist on this, Xuggler's pre-compiled
binaries (including native versions) can be found here. Make sure that
xuggle-xuggler.jar and its dependencies are included in your Java
classpath. See the xuggle-xugger-*.pom file distributed with the
version of Xuggler that you use to find the (small) set of dependent
jars, and download them as well.
I downloaded the xuggle-xuggler.jar file for the latest version, 5.4 but I don't understand the pom file for it.
What dependencies is he talking about?
Next, how do I download these dependencies ?
Once I get these dependencies, how do I start working in Eclipse?
Update After Downloading Dependencies
I have the following directory structure:
xuggle-xuggler-5.4.jar is stored in E:\xuggle
the various xuggler dependencies are stored in E:\xuggle\xuggle-dependencies
Question:
How do I start working with Xuggler in Eclipse? What paths do I have to set and what values do these paths have?
The following files list the other jars which xuggle depends upon:
ivy.xml
pom.xml
You can read these and then manually retrieve them from the appropriate repository, but I would submit it's simpler to start using a dependency manager.
You asked how to download these dependencies, well ivy has a convenient command-line mode of operation. (See example below)
Eclipse integration is very tough.... Once you've downloaded the jar you could try and generate the ".classpath" file or just manually add each jar via the Eclipse GUI.
The reason I don't recommend this approach is because there are Eclipse plugins for both Maven and Ivy that would do this for you automatically.
Example
Run ivy from command-line as follows:
java -jar ivy.jar -settings ivysettings.xml -dependency xuggle xuggle-xuggler 5.4 -retrieve "lib/[artifact]-[revision].[ext]"
It will retrieve xuggle and all its dependencies into a "lib" directory as follows:
├── ivysettings.xml
└── lib
├── commons-cli-1.1.jar
├── logback-classic-1.0.0.jar
├── logback-core-1.0.0.jar
├── slf4j-api-1.6.4.jar
└── xuggle-xuggler-5.4.jar
ivysettings.xml
This file tells ivy to retrieve jars from either Maven Central, or the Maven repository provided by the Xuggle project.
<ivysettings>
<settings defaultResolver="repos" />
<resolvers>
<chain name="repos">
<ibiblio name="central" m2compatible="true"/>
<ibiblio name="xuggle" m2compatible="true" root="http://xuggle.googlecode.com/svn/trunk/repo/share/java"/>
</chain>
</resolvers>
</ivysettings>
Don't fight Maven, embrace it. These days all major build systems are maven compatible (Maven, Ivy, Gradle, Grape, Buildr ...). But you can use Maven from Eclipse:
create a file called pom.xml with this content:
<project>
<groupId>com.foo<groupId> <!-- change these -->
<artifactId>foo</artifactId> <!-- parameters to whatever -->
<version>1.0-SNAPSHOT</version><!-- you like -->
<repositories>
<repository>
<id>xuggle repo</id>
<url>http://xuggle.googlecode.com/svn/trunk/repo/share/java/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>xuggle</groupId>
<artifactId>xuggle-xuggler</artifactId>
<version>5.2</version>
</dependency>
</dependencies>
</project>
Install the m2e extension and, from Eclipse, do "File > Import ... > Existing Maven Projects". In the dialog, select the Folder that contains the pom.xml.
Make sure that the Folder's layout is like this:
pom.xml
src/main/java // sources go here
src/test/java // test sources go here
Then you should have a working Eclipse project with the required dependencies.
Update after your update:
You can see the dependencies when you look at this file: http://xuggle.googlecode.com/svn/trunk/repo/share/java/xuggle/xuggle-xuggler/5.2/xuggle-xuggler-5.2.pom
commons-cli (a utility library for command line processing)
logback (a logging framework)
junit (a testingframework)
Maven will take care of loading these dependencies for you. So will Eclipse, if you use the m2e plugin as suggested above.
If you absolutely don't want to do that, you will have to download the dependencies manually. Look at the pom file above, note the names and versions of the dependencies, look them up at http://mvnrepository.com/ and download them there, e.g. this is the page for slf4j-api: http://mvnrepository.com/artifact/org.slf4j/slf4j-api/1.6.4
Before importing my Maven project, I build it using the following: mvn clean install
I then create the necessary Eclipse files as follows: mvn -Dwtpversion=2.0 eclipse:eclipse
I notice that my Referenced Libraries in Eclipse contains this jar: validation-api-1.0.0.GA.jar
However, when I view the effective POM in Eclipse no such jar appears. Therefore, I am wondering how this jar gets added to my Eclipse classpath?
I require this jar for #Valid annotation I am using and I need Maven to be aware of it. If I build my classpath files using Maven then how come Maven is not aware of it?
Thanks
Check the Dependency hierarchy-tab in your pom (in Eclipse), maybe the jar is a dependency of some other jar you use.
In this case, the reference was in the project's Java Build Path, and was probably added when the project was created because of the -Dwtpversion=2.0 -parameter.
Maven also adds to your class path the sub-dependencies of your main dependencies (which are those specifically declared by you in the pom.xml). Do a
mvn dependency:tree -Dverbose
To see what other dependencies are pulled in with a specific pom-declared dependency.
Also, if you only wanna see the subdependencies of a certain dependency, called x.y.z you can do:
mvn dependency:tree -Dverbose -Dincludes=x.y.z
(where x.y is the groupId and z is the artefactId)
One of your project dependencies probably has a dependency for this jar file. Check the graphical dependency graph or just search for that, find out your project dependency that is dependent on this and exclude this dependency, if possible, by using maven's 'exclude' tags.
You can use maven dependency exclusions, as below:
<project>
...
<dependencies>
<dependency>
<groupId>sample.ProjectA</groupId>
<artifactId>Project-A</artifactId>
<version>1.0</version>
<scope>compile</scope>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>sample.ProjectB</groupId>
<artifactId>Project-B</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Source: Maven - Dependency Exclusions
I have encountered the same problem. And after some research I realized that transitive dependencies of your parent pom may not show up in Effective POM, but would be present in Reference libraries.
The whole confusion raised because when I ran the following command
mvn dependency:tree -Dincludes=X (where X is the group-id of the jar I was looking for)
It did no mention of parent pom, instead it referred to dependency in parent pom which brings X to the table. (Which make sense because we inherit from parent pom).
I have just added dependencies to an eclipse project so that my jar can see other jars. How can I be sure that the dependencies work, and that what I've done is correct? I view a pom.xml file that has been created so what are the target folder and classes,test-classes subfolders used for? Thanks
If you have the m2eclipse plugin installed you can open your pom in Eclipse and click on the Dependency Hierarchy tab to view your resolved dependencies. You should manage all dependencies through Maven with the setup you are describing.
If you want to check command line you may want to look at using Effective Pom.
If you use m2e, it adds Maven Dependencies pseudo library to your project.
You may expand it and see if the dependent jar file is in there.
If it is, Eclipse ( or more precisely m2e ) has resolved the dependency correctly and it's available for you project build.
If you added your dependencies correctly your application should build and execute correctly, or am I missing something? Dependencies should be added to a POM section that looks like this example:
<dependencies>
<dependency>
<groupId>annogen</groupId>
<artifactId>annogen</artifactId>
<version>0.1.0</version>
</dependency>
<!-- other dependencies here -->
</dependencies>
Maven and the m2e/m2eclipse plugin rely on source files to be conventionally placed in src/main/java for application code and src/test/java for test code. Application code is compiled to target/classes and test code is compiled to target/test-classes. If you plan to use Maven and/or m2e/m2eclipse, do read about it. Maven: The Complete Reference is a good starting point.