does anyone knows how do I specify in Ivy something like mirror/mirrorOf in Maven? I'm working with a local Maven proxy (Nexus) and need the tool to specify which of the parent repositories should Nexus proxy be accessing.
In Maven I do simply:
<mirrors>
<mirror>
<id>central-mirror</id>
<mirrorOf>central</mirrorOf>
<url>http://localhost:8081/content/repositories/central</url>
</mirror>
</mirrors>
but I can't find this kind of option in Ivy.
You need to create a public resolver that does what you want (more details # Ivy docs)
Basically save the following snippet under $USERHOME/.ivy2/ivysettings-public.xml. This should do the trick.
<ivysettings>
<resolvers>
<ibiblio name="public" m2compatible="true" root="http://localhost:8081/content/groups/public"/>
</resolvers>
</ivysettings>
The unmodified standard installation has 'nexus' in the URL!
If you need to deploy artifacts, I think the solution is to do something similar to the shared resolver (see link to docs above), but I haven't tried.
I changed your local URL to resolve to the standard 'content/groups/public' which is better since in the maven settings fragment above you're passing all calls through the mirror, not just the ones to central. Just add any additional repositories to that group in the Nexus UI as they come up and you should be fine.
If your project loads it's own ivysettings which doesn't honor the defaults, then these settings will not get loaded and you're again back at zero :(
I don't think such an option exists directly. You could try implementing a chain, and put your Nexus repository ahead of central in that chain. If I understand how chains work correctly (that's a big if), Ivy will check your repository before central, so as long as your repository has the relevant contents central won't be needed.
See the tutorial for details.
This is how I made it work (The answer from #Heron did not work for me):
Create a file with this content:
<ivysettings>
<settings defaultResolver="default"/>
<property name="m2-pattern" value="${user.home}/.m2/repository/[organisation]/[module]/[revision]/[module]-[revision](-[classifier]).[ext]" override="false" />
<resolvers>
<chain name="default">
<ibiblio name="public" m2compatible="true" root="http://nexus-server:8081/nexus/content/groups/public"/>
</chain>
</resolvers>
</ivysettings>
Refere to it from the ant build:
<ivy:settings file="/Users/wdb/.ivy2/ivysettings-public.xml" />
Ivy is now able to resolve dependencies from my nexus repository.
I have done the same but with Archiva, what is very similar. You only have to declare in a new chain the following:
<chain name="private">
<url name="archiva" m2compatible="true">
<ivy pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/ivy.xml" />
<artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact].[ext]" />
</url>
</chain>
Archiva manages Maven 2 repositories (artifacts with Maven meta data)
there isn't usually Ivy meta data (ivy.xml).
And the Maven 2 layout is [organisation]/[module]/[revision]/[artifact]-[revision].[ext].
We have only to provide the following information
<url name="archiva" m2compatible="true">
<artifact pattern="http://..../archiva/repository/internal/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
or
<settings defaultResolver="archiva"/>
<resolvers>
<ibiblio name="archiva" m2compatible="true" root="http://.../archiva/repository/internal/[organization]/[module]/[revision]/[artifact]-[revision].[ext]"/>
</resolvers>
Related
I used to date the followind dependency
<ivy-module
version="2.0" ...>
<dependency name="primefaces" org="org.primefaces" rev="3.5" />
but since today the dependency is not resolved correctly. I tried it with the newest version
<dependency name="primefaces" org="org.primefaces" rev="5.1" />
and this works fine.
I went to the direct-download page of primefaces (http://www.primefaces.org/downloads) and there stands:
PrimeFaces 4.0 and newer are available at Maven Central, for older
releases add the following repository definition to your pom.xml in
repositories section.
view plainprint?
<!-- For 3.5 and older -->
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
Is this an actual news? If so, how I have to change the dependency line in ivy to get the version 3.5 ? This version 3.5 ist necessary for me for Liferay portlets.
You'll have to add that repository as Ivy resolver. If you don't have it yet, create ivysettings.xml with something like this inside
<ivysettings>
...
<resolvers>
<ibiblio name="primefaces" root="http://repository.primefaces.org" m2compatible="true" />
</resolvers>
...
</ivysettings>
I'm trying to understanding and using ivy with archiva, but i have this strange thing that i can't explain,
Build.xml
...some xml code
<target name="resolveArchiva" description="--> go take the jar">
<ivy:settings file="./archivaIvySetting.xml" >
<credentials host="my host to Archiva" realm="my repository's name"
username="user" passwd="passwd"/>
</ ivy:settings>
<ivy:retrieve />
</target>
some other code....
Ivy.xml
<ivy-module version="2.0">
<info organisation="archiva" module="my-repo"/>
<dependencies>
<dependency org="annogen" name="annogen" rev="0.1.0"/>
<dependency org="commons-lang" name="commons-lang" rev="2.1" />
</dependencies>
</ivy-module>
arvchivaIvySetting.xml
<ivysettings>
<settings defaultResolver="archiva" />
<resolvers>
<ibiblio name="archiva" m2compatible="true" root="repositories/internal/"/>
</resolvers>
</ivysettings>
the problem it's that in my repo there is an artifact for annogen but it's not present the common-lang artifact, despite that, the build says that it find the artifacts for both the dependencies, and that's true because i find both .jar in my lib project. How is it possible? it's clear that my setting doesn't point to the archiva rep but to the maven ones but how can i change it?
I have a dependency on my project like this:
<dependency org="org.springframework"
name="org.springframework.web.servlet"
rev="3.1.2.RELEASE" />
And it wants to pull things like this:
org.apache.commons#com.springsource.org.apache.commons.logging;1.1.1
which causes issues with other libraries that use a newer version of commons-logging. So I work around it by excluding it like this:
<exclude org="org.apache.commons"
module="com.springsource.org.apache.commons.logging" />
but having to do that kind of defeats the purpose of the conflict management Ivy has built-in. Is there a better way to handle this, or do I have to track down all the potential conflicts manually?
Disclaimer: I'm pretty new to Ivy and dependency management, so I have no idea if this concept extends into the Maven world as well. If not, I apologize for the false tagging.
I'm assuming you are using the EBR repositories in your ivysettings.xml file.
You get those com.springsource dependencies because all the libraries in EBR are valid OSGi bundles and SpringSource transformed normal jars in bundles by prefixing the bundle names with com.springsource.
Also, I'm assuming your project doesn't make use of an OSGi container and you don't actually need OSGi bundles in your project. To get back to resolving normal jars and not OSGi bundles you need not to use the EBR repositories.
In your ivysettings.xml comment the resolvers that point to EBR repositories, for example:
<!-- <resolvers>
<chain name="chained">
<url name="com.springsource.repository.bundles.release">
<ivy pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<artifact pattern="http://repository.springsource.com/ivy/bundles/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
<url name="com.springsource.repository.bundles.external">
<ivy pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
<artifact pattern="http://repository.springsource.com/ivy/bundles/external/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</url>
</chain>
</resolvers> -->
And replace those with the ibiblio resolver:
<settings defaultResolver="central"/>
<resolvers>
<ibiblio name="central" m2compatible="true"/>
</resolvers>
Also, you need to change any dependency that, initially, was taken from EBR repositories to the format the usual Maven central repository has. For example, your dependency on org.springframework.web.servlet needs to be changed in ivy.xml to:
<dependency org="org.springframework"
name="spring-web"
rev="3.1.2.RELEASE" />
With the changes above, Ivy will resolve the dependencies from Maven central, as well.
I have add resolver to ivysettings.xml
<ibiblio name="google-api-services" root="http://mavenrepo.google-api-java-client.googlecode.com/hg" m2compatible="true" />
But get a error
module not found: com.google.apis#google-api-services-drive;v2-rev13-1.8.0-beta
It resolves fine for me..... Perhaps there is a problem with your ivysettings file?
The following example configures the google api services repo and Maven Central.
<ivysettings>
<settings defaultResolver="repos" />
<resolvers>
<chain name="repos">
<ibiblio name="central" m2compatible="true"/>
<ibiblio name="google-api-services" m2compatible="true" root="http://mavenrepo.google-api-java-client.googlecode.com/hg"/>
</chain>
</resolvers>
</ivysettings>
I am trying to understand how to manage this situation, suppose I have a 3rd party library (best-lib) that consists of three jars (a.jar, b.jar, c.jar) and I will be uploading those jars to a personal Artifactory server, the (best-lib) has two versions 1.0 and 2.0.
What I would like to have in my ivy.xml file is one single dependency to retrieve all those jars at once for example:
<dependencies>
<dependency org="mycompany" name="best-lib" rev="1.0" />
</dependencies>
And this dependency should add all three jars (a, b, and c) of version 1.0.
The question is:
Is this possible?
How can I upload the three jars to artifactory to achieve this behaviour?
Is it possible to upload those jars all at once?
Artifactory alternative solutions are also acceptable (e.g. Nexus or Archivia).
Note: I am not building best-lib I just have its jars, and best-lib is not a library that can be downloaded from a public maven2 repository.
Thanks.
When publishing the "best-lib" module, use an ivy.xml file that lists the 3 jars published by the module:
<ivy-module version="2.0">
<info organisation="mycompany" module="best-lib"/>
<publications>
<artifact name="a" type="jar"/>
<artifact name="b" type="jar"/>
<artifact name="c" type="jar"/>
</publications>
..
..
When you create a dependency against this module, ivy will understand that there are 3 jars in this module.
For an example of how to publish an ivy module see:
Issues using ivy:publish task
Update
If the 3 jars are already in your repository you could publish a stand-alone ivy modules that references the other 3 as dependencies:
<ivy-module version="2.0">
<info organisation="mycompany" module="best-lib" rev="1.0"/>
<dependences>
<dependency org="mycompany" name="a" rev="1.0" />
<dependency org="mycompany" name="b" rev="1.0" />
<dependency org="mycompany" name="c" rev="1.0" />
</dependencies>
Finally, you may need to tell us what format your Artifactory repository uses.... I have been assuming it's an ivy repo. If it's Maven then the concepts are the same but obviously server-side we'd be talking about pom.xml files, instead of ivy.xml (Ivy supports Maven repositories).