Using a custom repository with Apache Ivy, no resolver found - java

It seems that Apache ivy downloads artifacts only from http://mvnrepository.com/ and few other places, but all the jars are outdated there.
So I am trying to add custom repository for Ivy. I am using repository Ivy RoundUp : http://code.google.com/p/ivyroundup/
This is my configuration, but getting error:
build.xml:
<target name="update" depends="init-ivy" description="Download project dependencies">
<!-- edited for brevity -->
<ivy:settings file="ivysettings.xml" />
<ivy:retrieve pattern="war/WEB-INF/lib/[artifact]-[revision].[ext]" />
<!-- edited for brevity -->
</target>
ivy.xml :
<ivy-module version="2.0">
<info organisation="org.apache" module="hello-ivy"/>
<dependencies>
<dependency org="org.springframework" name="spring" rev="3.0.6" conf="default->master"/>
</dependencies>
</ivy-module>
ivysettings.xml:
<ivysettings>
<resolvers>
<packager name="roundup" buildRoot="${user.home}/.ivy2/packager/build" resourceCache="${user.home}/.ivy2/packager/cache">
<ivy pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/ivy.xml"/>
<artifact pattern="http://ivyroundup.googlecode.com/svn/trunk/repo/modules/[organisation]/[module]/[revision]/packager.xml"/>
</packager>
</resolvers>
</ivysettings>
error:
Buildfile: C:\Users\Jansu\workspace\HibernateSpring\build.xml
build:
deploywar:
[war] Building war: C:\Users\Jansu\workspace\HibernateSpring\hibernate.war
[copy] Copying 1 file to C:\apache-tomcat-7.0.20\webapps
download-ivy:
[get] Getting: http://repo2.maven.org/maven2/org/apache/ivy/ivy/2.2.0/ivy-2.2.0.jar
[get] To: C:\Users\Jansu\.ant\lib\ivy-2.2.0.jar
[get] Not modified - so not downloaded
init-ivy:
update:
[ivy:retrieve] :: Ivy 2.2.0 - 20100923230623 :: http://ant.apache.org/ivy/ ::
[ivy:retrieve] :: loading settings :: file = C:\Users\Jansu\workspace\HibernateSpring\ivysettings.xml
[ivy:retrieve] :: resolving dependencies :: org.apache#hello-ivy;working#Jansu-PC
[ivy:retrieve] confs: [default]
[ivy:retrieve] :: resolution report :: resolve 110ms :: artifacts dl 0ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 1 | 0 | 0 | 0 || 0 | 0 |
---------------------------------------------------------------------
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: UNRESOLVED DEPENDENCIES ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: org.springframework#spring;3.0.6: no resolver found for org.springframework#spring: check your configuration
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve] :::: ERRORS
[ivy:retrieve] unknown resolver null
[ivy:retrieve] no resolver found for org.springframework#spring: check your configuration
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
BUILD FAILED
C:\Users\Jansu\workspace\HibernateSpring\build.xml:177: impossible to resolve dependencies:
resolve failed - see output for details
Total time: 2 seconds
So it seems that it does not find my resolver . I did configure the resolver like the custom repository asked me to: http://code.google.com/p/ivyroundup/wiki/HowToConfigureIvy
And here is list of all artifacts in that repo, so you can see that Spring 3.0.6 exists in there : http://ivyroundup.googlecode.com/svn/trunk/repo/modules.xml
Any suggestions? Feel free to ask more information.
EDIT:
build.properties :
ivy.install.version=2.2.0
ivy.home=${user.home}/.ant
ivy.jar.dir=${ivy.home}/lib
ivy.jar.file=${ivy.jar.dir}/ivy-${ivy.install.version}.jar

Ivyroundup is designed around the packager resolver in ivy. This resolver is incredibly clever, demonstrates the true power of ivy, but the bulk of the world uses Maven repositories to host their software. Fact is soon Maven Central will contain nearly 90% of the world's Java open source components.
Enabling Maven repositories
Thankfully, ivy fully understands Maven repositories, meaning we can use ivy as a client and let very good products like Nexus host the repository. Here's the settings file that enables Maven Central:
<ivysettings>
<settings defaultResolver='central'/>
<resolvers>
<ibiblio name='central' m2compatible='true'/>
</resolvers>
</ivysettings>
I would highly recommend you consider setting up you own local instance of Nexus (Or Artifactory, or Archiva...). You can then cache Maven central artifacts (more efficient), search for software components and upload and host artifacts which cannot be downloaded, due to license restrictions (JDBC jars).
Enabling a local repository manager also uses the ibiblio resolver as follows:
<ivysettings>
<settings defaultResolver='nexus'/>
<resolvers>
<ibiblio name='nexus' m2compatible='true' root='https://nexus.mydomain.com:8081/nexus/content/groups/central/' />
</resolvers>
</ivysettings>
Searching Maven Central (New ivy support features)
You're looking for the Spring 3.0.6 release? It's already in Maven Central:
http://search.maven.org/#search|ga|1|g%3A%22org.springframework%22%20AND%20v%3A%223.0.6.RELEASE%22
The Spring core artifact details are here:
http://search.maven.org/#artifactdetails|org.springframework|spring-core|3.0.6.RELEASE|jar
The search page now conveniently gives you both the Maven and ivy client declaration to copy into your build:
<dependency org="org.springframework" name="spring-core" rev="3.0.6.RELEASE" >
<artifact name="spring-core" type="jar" />
</dependency>

for sake of completeness ...
ivysettings.xml with a chain resolver for
https://maven.org
https://jitpack.io/
<ivysettings>
<settings defaultResolver="default-chain"/>
<resolvers>
<chain name="default-chain">
<!-- default resolver
<ibiblio name="maven.org" m2compatible="true" root="https://repo1.maven.org/maven2"/>
-->
<ibiblio name="maven.org" m2compatible="true"/>
<!-- resolver for github
example use in ivy.xml: https://github.com/omajid/xdg-java
<dependency org="com.github.omajid" name="xdg-java" rev="7c623b86e6b99bef0a72db86318663ad3c0270e5" conf="compile->master"/>
-->
<ibiblio name="jitpack.io" m2compatible="true" root="https://jitpack.io/"/>
</chain>
</resolvers>
</ivysettings>

Your update target should invoke ivy:resolve task after ivy:settings.
<target name="update" depends="init-ivy" description="Download project dependencies">
<ivy:settings file="ivysettings.xml" />
<ivy:resolve conf="default" />
<ivy:retrieve pattern="war/WEB-INF/lib/[artifact]-[revision].[ext]" />
</target>

you must have something to tell whats the default resolver, like,
<conf defaultResolver="default" />

Related

How to publish artifacts to Artifactory with different names? [duplicate]

I published few atifacts of a component to a maven repository using different configurations of ivy. As an example, I took the following way (Ivy Documentation) to do the same..
<ivy-module version="1.0">
<info organisation="org.apache" module="filter"/>
<configurations>
<conf name="api" description="only provide filter framework API"/>
<conf name="homemade-impl" extends="api" description="provide a home made implementation of our api"/>
</configurations>
<publications>
<artifact name="filter-api" type="jar" conf="api" ext="jar"/>
<artifact name="filter-hmimpl" type="jar" conf="homemade-impl" ext="jar"/>
</publications>
</ivy-module>
According to the above configuration, the artifacts that are produced are filter-api.jar and filter-hmimpl.jar, and I generated a pom file filter.pom and published this into a maven repository.
Now, when I am trying to resolve the artifact filter-api in another component using the following..
<dependency org="org.apache" name="filter" rev="3.1" conf="default->api"/>
But it is not working, I believe my filter.pom should contain some modules like this, to make it work..
<modules>
<module>api</module>
<module>homemade-impl</module>
</modules>
Am I correct, and if yes how can I map different conf's of ivy to modules in maven.
Publishing mutliple files to a Maven repository is tricky because Maven modules normally contain a single artifact. Maven modules do support additional module artifacts, which are referenced in a Maven dependency using the "classifier" attribute.
The following answers provide examples of publishing multiple files to a Maven module:
how to publish 3rdparty artifacts with ivy and nexus
Convert ivy.xml to pom.xml
Observe that the ANT scripts are using the makepom to generate POM files and that these files are considered artifacts published (part of the ivy publications section).
For more background you might be interested in the following answer that deals with the differences between Maven "scopes" and ivy "confgurations".
How are maven scopes mapped to ivy configurations by ivy
Finally, if your ivy build uses configurations, it's possible to configure the makepom task to map between configurations and scopes:
<ivy:makepom ivyfile="${build.dir}/ivy.xml" pomfile="${build.dir}/${ivy.module}.pom"/>
<mapping conf="api" scope="compile"/>
</ivy:makepom>
Most likely, the problem is with the dependency declaration. You pull the dependency into your 'default' configuration with conf="default->api". But you really want them in the "compile" conf, to include them in your compile classpath.

How do I specify net.sf.json-lib#json-lib#2.3 in Ivy or Maven?

I am in the middle of converting over our build system from Ant to Ant with Ivy, and have run into an issue specifying a particular jar we need.
groupId: net.sf.json-lib
artifactId: json-lib
version: 2.3
I specified it in Ivy as:
<dependency org="net.sf.json-lib" artifact="json-lib"
rev="2.3" conf="compile->default"/>
And got the following error:
[ivy:retrieve] ==== public: tried
[ivy:retrieve] http://buildl01.tcprod.local/artifactory/libs-release/net/sf/json-lib/json-lib/2.3/json-lib-2.3.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: FAILED DOWNLOADS ::
[ivy:retrieve] :: ^ see resolution messages for details ^ ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: net.sf.json-lib#json-lib;2.3!json-lib.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
Notice Ivy tried to download the file json-lib-2.3.jar from the repository.
I did a search on the Central Maven Repository and found that the artifact isn't called json-lib-2.3.jar but either json-lib-2.3-jdk-13.jar or json-lib-2.3-jdk-15.jar.
The problem is the way the name of the artifact is specified. The version number appears in the middle of the jar name. If the artifact was `json-lib-jdk-15-2.4.jar, I could do this:
<dependency org="net.sf.json-lib" artifact="json-lib"
rev="2.3" conf="compile->default">
<artifact name="json-lib-jdk-15"/>
</dependency>
How can I specify this jar for downloading?
The "thing" at the end of the jar name is called the classifier. It is used to target specific platforms or to provide sources or Javadoc.
To get the jar, you need to define the classifier like this:
<ivy-module version='2.0' xmlns:m="http://ant.apache.org/ivy/maven">
...
<dependency org="net.sf.json-lib" artifact="json-lib" rev="2.3"conf="compile->default">
<artifact name="json-lib" type="jar" m:classifier="jdk15"/>
</dependency>
Read this article for more information.

Ivy can't resolve log4j from Maven Central

New to Apache Ivy, and can't get it to resolve the latest log4j jar from Maven Central. I'm using IvyDE to manage all of my dependencies and using all of its defaults, which I believe configure it to use either the Maven repo or Ibiblio.
This link takes you to Maven's log4j page. From here I am just using the Apache Ivy <dependency> tag provided on that page:
<dependency org="log4j" name="log4j" rev="1.2.16" >
<artifact name="log4j" type="bundle" />
</dependency>
When I add this to my ivy.xml file and save it inside Eclipse, IvyDE automatically runs an Ivy resolve...and I am getting an error:
Ivy resolve job of ivy.xml in 'myProject' has encountered a problem.
Impossible to resolve dependencies of myOrg#myProject;working#myMachine
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
download failed: log4j#log4j;1.2.16!log4j.bundle
(Those last 4 lines, although identical, are in fact repeated 4 times!)
Is something wrong with log4j on Maven Central? All of my other jars resolve without a hitch, and I am using the same technique for getting all of my jars. This is the only one (out of 30 or so) that is failing. Thanks in advance!
Leave out the
<artifact name="log4j" type="bundle" />
part and it will download the normal jar file.
I don't think you need the bundle-specification part and it seems (to me) like some kind of anomaly.
bundle is not even a core packaging value for maven:
The current core packaging values are: pom, jar, maven-plugin, ejb,
war, ear, rar, par. These define the default list of goals which
execute to each corresponding build lifecycle stage for a particular
package structure.
I used following :
<dependency org="log4j" name="log4j" rev="1.2.17">
<artifact name="log4j" type="jar" />
</dependency>
and it worked.

Hudson plug-in not publishing all artifacts to Artifactory

I've got a small Java project setup to build continuously through a Hudson server. I'd like to publish the build artifacts to an Artifactory server as a post-build step so, naturally, I'm using the Hudson-Artifactory plug-in to facilitate this. The local publish appears to work just fine - it publishes the two artifacts (both .jar files) and the resolved ivy.xml file as expected. When I request a build on the Hudson server, however, only one of my two artifacts gets published.
The build creates the following artifacts:
ftpSvc.jar
ftpSvc-lib.jar
My ivy.xml file looks like this:
<?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">
<info organisation="esf"
status="integration"
module="ftpSvc"
revision="SNAPSHOT" />
<publications>
<artifact name="ftpSvc" ext="jar"/>
<artifact name="ftpSvc-lib" ext="jar" type="lib" />
</publications>
<!--list the dependencies of this project-->
<dependencies>
<dependency org="commons-net" name="commons-net" rev="1.3.0" />
</dependencies>
</ivy-module>
The two artifacts are clearly called out in the <publications> section. The build target in my build.xml file looks like this:
<target name="publish_local" description="publish artifacts locally">
<echo>organisation: ${ivy.organisation}</echo>
<echo>module: ${ivy.module}</echo>
<echo>status: ${ivy.status}</echo>
<echo>revision: ${ivy.revision}</echo>
<echo>local dir: ${ivy.default.ivy.user.dir}</echo>
<ivy:publish
resolver="local"
update="true"
verwrite="true"
srcivypattern="${bundle.jar.dir}/ivy.xml"
artifactspattern="${bundle.jar.dir}/[artifact].[ext]" />
</target>
The artifactspattern grabs all defined artifacts from the build directory - nothing fancy going on here. Lastly, the resolver chain in my ivysettings.xml file looks like this (server names changed to protect the innocent):
<resolvers>
<chain name="main">
<ibiblio name="main" m2compatible="true" root="http://my.server.employer.com:8080/artifactory/repo" />
<filesystem name="local">
<ivy pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/ivy-[revision].xml" />
<artifact pattern="${ivy.default.ivy.user.dir}/local/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" />
</filesystem>
</chain>
</resolvers>
It's all rather routine stuff and, as mentioned above, the local publish works fine. Here's a peek at the console output when I build through Eclipse:
publish_local:
[echo] organisation: esf
[echo] module: ftpSvc
[echo] status: integration
[echo] revision: SNAPSHOT
[echo] local dir: C:\Users\myusername\.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
[ivy:publish] published ftpSvc to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
[ivy:publish] published ftpSvc-lib to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
[ivy:publish] published ivy to C:\Users\myusername\.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Both .jar files and the resolved ivy.xml file get published as expected. On my Hudson server, I've got the Artifactory Configuration settings configured thusly (again, some details have been changed to obscure my true superhero identity):
Artifactory server: http://my.server.employer.com:8080/artifactory
Target repository: target-repository
Ivy pattern: [organisation]/[module]/[revision]ivy-[revision].xml
Artifact pattern: "[organisation]/[module]/[revision]/[artifact]-[revision].[ext]"
As you can see, the Ivy and Artifact patterns are exactly the same as the patterns in my local resolver from my ivysettings.xml file. Thus, when the build is run on the Hudson server, I'd expect the exact same artifacts to be published to my Artifactory server.
Let's take a look at the console output from the latest build on my Hudson server:
publish_local:
[echo] organisation: esf
[echo] module: ftpSvc
[echo] status: integration
[echo] revision: SNAPSHOT
[echo] local dir: /usr/share/tomcat6/.ivy2
[ivy:publish] :: publishing :: esf#ftpSvc
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc.jar
[ivy:publish] published ftpSvc to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /usr/share/tomcat6/.hudson/jobs/ftpSvc-ivy/workspace/trunk/out/jars/ftpSvc-lib.jar
[ivy:publish] published ftpSvc-lib to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ftpSvc-lib-SNAPSHOT.jar
Collecting Module information for module: ftpSvc
Module location: /tmp/ivy2450884590736960955.xml
[ivy:publish] published ivy to /usr/share/tomcat6/.ivy2/local/esf/ftpSvc/SNAPSHOT/ivy-SNAPSHOT.xml
Build finished triggered
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.jar
Deploying artifact: http://my.server.employer.com:8080/artifactory/target-repository/esf/ftpSvc/SNAPSHOT/ftpSvc-SNAPSHOT.xml
Deploying build info to: http://my.server.employer.com.com:8080/artifactory/api/build
Dubya' Tee Eff!? Once again, the local publish appears to work just fine, publishing both jars and the ivy.xml file to the local/esf/ftpSvc/SNAPSHOT/ directory on the Hudson server. The Artifactory plug-in, on the other hand, gets everything totally wrong. Not only does it fail to publish one of the two jars, it renames the ivy.xml file incorrectly.
Are there any Hudson/Ivy/Artifactory experts out there that can shed some light on what's going on here? I've got multiple projects that are exhibiting the exact same behavior. Any and all assistance in resolving this problem would be greatly appreciated.
Hey, I haven't used that plugin, but I would try removing the dash from the name ftpSvc-lib and/or removing type="lib" from its artifact element, just to see what happens.
I got the same problem, filled a bug on the JFrog Jira, the bug has been marked resolved today, but as you can see in my comments on the Jira, I'm still confused about this resolution.
https://issues.jfrog.org/jira/browse/IAP-26?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
If anyone has an idea, any input would be great...

How do I use TestNG with Apache Ivy?

I tried to use TestNG with Apache Ivy, but was unsuccessful. Here is my ivy.xml:
<ivy-module version="2.0">
<info organisation="me" module="myproject"/>
<dependencies>
<dependency org="org.testng" name="testng" rev="5.8" />
</dependencies>
</ivy-module>
This fails to actually download a TestNG jarfile. It seems to be because TestNG has a jarfile for jdk14 and jdk15. Here's the output from ivy:retrieve:
[ivy:retrieve] :: resolving dependencies :: me#myproject;working#jared-mbp17
[ivy:retrieve] confs: [default]
[ivy:retrieve] found org.testng#testng;5.8 in public
[ivy:retrieve] :: resolution report :: resolve 1139ms :: artifacts dl 11ms
---------------------------------------------------------------------
| | modules || artifacts |
| conf | number| search|dwnlded|evicted|| number|dwnlded|
---------------------------------------------------------------------
| default | 1 | 1 | 1 | 0 || 1 | 0 |
---------------------------------------------------------------------
[ivy:retrieve]
[ivy:retrieve] :: problems summary ::
[ivy:retrieve] :::: WARNINGS
[ivy:retrieve] [FAILED ] org.testng#testng;5.8!testng.jar: (0ms)
[ivy:retrieve] ==== shared: tried
[ivy:retrieve] /Users/jared/.ivy2/shared/org.testng/testng/5.8/jars/testng.jar
[ivy:retrieve] ==== public: tried
[ivy:retrieve] http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: FAILED DOWNLOADS ::
[ivy:retrieve] :: ^ see resolution messages for details ^ ::
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve] :: org.testng#testng;5.8!testng.jar
[ivy:retrieve] ::::::::::::::::::::::::::::::::::::::::::::::
[ivy:retrieve]
[ivy:retrieve] :: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
In the repository you can see two different jarfiles:
http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8-jdk14.jar
http://repo1.maven.org/maven2/org/testng/testng/5.8/testng-5.8-jdk15.jar
How do I specify either jdk14 or jdk15?
You need to specify the classifier of the artifact you want.
There is a related fix as of 2.1.0-RC1. You can use the element artifact within the dependency element to specify the classifier you want. In this case, the classifier should be jdk14 or jdk15. If you want jdk15 your ivy.xml would then be:
<ivy-module version="2.0"
xmlns:e="http://ant.apache.org/ivy/extra">
<info organisation="me" module="myproject"/>
<dependencies>
<dependency org="org.testng" name="testng" rev="5.8"
transitive="false">
<artifact name="testng" type="jar" ext="jar" e:classifier="jdk15" />
</dependency>
</dependencies>
</ivy-module>
Note the specification of the XML namespace "http://ant.apache.org/ivy/extra" as an attribute of the ivy-module element. Without that the e:classifier won't work.

Categories