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!
Related
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
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>
Its maybe that I'm trying to misuse Ivy, but if I am then I definitely don't understand 'configurations'
I have a dependency I want to access only when running my build script under Jenkins. In my eclipse workspace I have no need for the dependency. Is it possible to achieve this?
For example if I wanted to pull ant-contrib in at build time I have tried setting up my configuration file as follows:
<configurations defaultconf="compile">
<conf name="compile" visibility="public" />
<conf name="build" visibility="public" extends="compile" />
</configurations>
<dependencies>
<dependency org="junit" name="junit" rev="4.8.1" conf="compile->default" />
<dependency org="ant-contrib" name="ant-contrib" rev="1.0b3" conf="build->*" />
</dependencies>
With this example I always end up with ant contrib and ant on my build path in eclipse which isn't what I wanted. The resolve ant task allows me to resolve a specific configuration so I assumed that IvyDE would only resolve the default one. What am I missing?
Thanks,
Dan.
When adding the ivy file using IvyDE it is possible to select the configurations that should be resolved. This way only compile can be selected and only junit would be resolved.
It seems that to change this you need to remove and re-add the ivy dependency, I can't find any settings to change the configurations without doing that.
I’m using STS 2.9.1 (build on Eclipse 3.7.2) with m2e plugin bundled with STS (v1.0.200.20111228-1245).
I have a problem regarding missing dependencies in Eclipse project that contains several modules, or maybe I don’t fully understand how it should work.
It’s a maven project.
In my Project > Properties > Java Build Path > Libraries I have “Maven Dependencies” library, but it's empty (and that’s the problem).
The main POM doesn’t have any dependencies, but it has several modules declared in it.
Adding a dependency to module’s POM doesn’t add it to the “Maven Dependencies” library (what was my expectation) and leads to Eclipse showing errors in source files.
Adding a dependency to the main POM adds it to the “MD” lib, but of course I don’t want to add all of my modules’ dependencies to the main POM just to have it in “MD” lib and adding every single dependency to the Build Path doesn’t seem right nor practical.
I’ve tried:
Project > Clean,
Maven > Update dependencies,
Maven > Update project configuration,
Unchecking the checkbox: Project > Properties > Maven > Resolve dependencies from Workspace projects.
None of the above seems to do the trick.
Example:
Simplified project structure:
simple.project
...
sample-module
...
pom.xml
pom.xml
simple.project/pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>simple.project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>sample-module</module>
</modules>
<dependencies>
<dependency><!-- This dependency is present in "MD" lib. -->
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
simple.project/sample-module/pom.xml:
<project ...>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>simple.project</artifactId>
<groupId>test</groupId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>test</groupId>
<artifactId>sample-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency><!-- I've expected this dependency also to appear in "MD" lib. -->
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
It is not supposed to work. A project only imports a dependency from another one if it depends on that project (using dependency) or if it inherits from it (using parent). The module element only represents an aggregation.
The question is from time ago, but I solved this creating a Maven Project and adding Maven Modules: right click on project and "New > Project... > Maven > Maven Module".
After that, no more errors were shown in code.
First thing that I see is that you're defining dependencies in a pom parent. There I would expect to see a <dependencyManagement> (see here the doc) structure. In this way the submodules will inherit properly those common dependencies.
Aside from that lets start for the most simple test. Try to compile your project from the maven utility in the command line. If it works then you have a problem in your Eclipse configuration, otherwise the problem is in the way you have defined your project.
If your project compiles properly from the command line, lets see what else can be happening.
The fact that the Maven Dependencies Library is empty means that the Eclipse Maven plugin is not resolving properly your poms. I had quite bad experiences with the embedded STS maven plugin. Try to downgrade it to the m2e 0.10 version. You only need to open the STS DashBoard / Find Updates / Install m2e 0.10
I hope some of these tips can help you.
I'm getting this error when I try to add jruby as a dependency using the ivy Eclipse plugin:
Impossible to resolve dependencies of com.restphone#;working#James-Moores-iMac.local
unresolved dependency: org.jruby.extras#bytelist;1.0.8: not found
This is in my ivy.xml:
<dependency org="org.jruby"
name="jruby-complete"
rev="1.6.6" />
And this is in ivysettings.xml:
<ivysettings>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name="codehaus" m2compatible="true" root="http://repository.codehaus.org/"/>
</chain>
</resolvers>
</ivysettings>
But according to the jruby mailing list, jruby has NO dependencies for runtime, compile or
test scope.
Do I need to give the ivy plugin more information somewhere?
In my opinion it's always a good idea to specify a configuration mapping for your dependencies.
The following ivy file worked fine for me. As described, only the ruby jar was downloaded.
<ivy-module version="2.0">
<info organisation="org.demo" module="demo"/>
<configurations>
<conf name="compile"/>
<conf name="runtime" extends="compile"/>
<conf name="test" extends="runtime"/>
</configurations>
<dependencies>
<dependency org="org.jruby" name="jruby-complete" rev="1.6.6" conf="compile->default"/>
</dependencies>
</ivy-module>
Here I have mapped my local "compile" configuration to the default remote configuration. (In a Maven module, the default ivy configuration translates to the "compile" scope).
I dug into the remote POM file:
<properties>
<jar.scope>provided</jar.scope>
..
..
<dependency>
<groupId>org.jruby.joni</groupId>
<artifactId>joni</artifactId>
<scope>${jar.scope}</scope>
</dependency>
<dependency>
<groupId>org.jruby.extras</groupId>
<artifactId>jnr-netdb</artifactId>
<scope>${jar.scope}</scope>
</dependency>
...
All the extra depedencies have been declared in the "provided" Maven scope.
Couple of issues:
1)
In Maven the provided scope is used for jars which are required for compiling that module. They do not need to be packaged because they are part of the target runtime environment. Similarily such dependencies are not needed as transitive dependencies for your module and hence don't need to downloaded.
2)
All the jars are all located in the Maven Central repository. The following settings file would retrieve everything, if you chose to omit the ivy configuration mapping
<ivysettings>
<property name="ivy.checksums" value=""/>
<settings defaultResolver="chain"/>
<resolvers>
<chain name="chain">
<ibiblio name="central" m2compatible="true"/>
</chain>
</resolvers>
</ivysettings>
3)
The following error is caused by a junk checksum. My provided settings file disables this check... something you are advised not to do on a remote repository
[ivy:resolve] :::: WARNINGS
[ivy:resolve] problem while downloading module descriptor: http://repo1.maven.org/maven2/org/jruby/extras/bytelist/1.0.8/bytelist-1.0.8.pom: invalid sha1: expected=e40ee094403473e43f71e21cf9cbf71f08d2098b computed=a9627bc7e42f886e290985367040794adb676320 (977ms)
[ivy:resolve] module not found: org.jruby.extras#bytelist;1.0.8
Although the JRuby docs may not state a required dependency, it looks as though the repository that you are using does...
You've asked for 'jruby-complete' and if you go and look at this POM you will see its specifying the jruby extras.
One option is to select a different POM file as the basis of your dependency, but a quick fix is to add the attribute transitive="false" to your dependency.
<dependency org="org.jruby"
name="jruby-complete"
transitive="false"
rev="1.6.6" />