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...
Related
I am using Eclipse Mars to run my Java project. I am making use of Maven in it. But while trying to compile my package I am getting the following error.
Failed to execute goal on project apex-check: Could not resolve dependencies for project org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0: Failed to collect dependencies at org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Failed to read artifact descriptor for org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0: Could not transfer artifact org.fundacionjala.enforce.sonarqube:apex-squid:pom:1.0 from/to central (https://repo.maven.apache.org/maven2): Failed to authenticate with proxy -> [Help 1].
I am able to find that my pom.xml has a bug in its dependency. But don't know how to resolve it. I have given below my pom.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Copyright (c) Fundacion Jala. All rights reserved. ~ Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.fundacionjala.enforce.sonarqube</groupId>
<artifactId>apex</artifactId>
<version>1.0b${build.number}</version>
</parent>
<artifactId>apex-check</artifactId>
<name>Apex :: Checks</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>apex-squid</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
I have written 'apex-check' and 'apex-squid' as two separate projects.
Can anyone explain how to correct my pom.xml?
You need to have:
org.fundacionjala.enforce.sonarqube:apex-check:jar:1.0
org.fundacionjala.enforce.sonarqube:apex-squid:jar:1.0
jar files available in your local .m2/repository folder. If they are not present maven will try to download from central repository and as an expected result it will fail on firewall or it will not find the artifact. i.e. if:
apex-check requires apex-squid project as dependency first you need to install squid project files by using mvn install on squid project folder.
But it seems more like you want to create a multi module maven project, take a look at this question. Create a parent project similar to this project, add check and squid as module and run mvn clean install on parent.
**edit: I just see you already have parent, so make sure parent has your projects as modules, which helps reactive build order and eclipse imports
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.
Considering the following ivy dependencies,
<dependency org="org.fusesource.restygwt" name="restygwt" rev="1.3"
conf="gwtcompile->default; compile->default"/>
<dependency org="org.jboss.resteasy" name="resteasy-jaxrs" rev="2.3.4.Final"
conf="compile->compile(*),runtime(*);runtime->runtime(*)"/>
They depend on public maven repos mirrored by
http ://myivyserver:8888/mirrored/ .
as specified by the ivysettings resolver chaining to ...
<url name="mirrored" m2compatible="true">
<artifact
pattern="http://myivyserver:8888/mirrored/${maven2.artifact.pattern}" />
</url>
Where I can see the mirrored directory completely replicating the artefacts of remote maven repos.
I am used to Maven and the seeing the buildpath on eclipse showing maven dependencies.
Now, I am creating Ivy-dependency for a project. I am expecting to see similar, and I do see, a similar Ivy dependency node showing all the jars due to the Ivy eclipse pluggin.
However, the Ivy dependency node in eclipse buildpath does not show any jars transitively specified by the mirrored poms.
For example,
<dependency org="org.fusesource.restygwt" name="restygwt" rev="1.3"
conf="gwtcompile->default; compile->default"/>
<dependency org="org.jboss.resteasy" name="resteasy-jaxrs" rev="2.3.4.Final"
conf="compile->compile(*),runtime(*);runtime->runtime(*)"/>
both dependencies’ pom specify dependency on javax.ws.rs (jsr311-api)
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
However javax.ws.rs(jsr311-api) does not show up on the buildpath library of the ivy managed project, as a Maven managed one would.
What further more would I have to do to get ivy plugin to resolve transitive dependencies that are due to maven poms?
Thank you.
URL resolver considers maven layout but not pom dependencies. When I was implementing this functionality ibiblio resolver was able to resolve pom's dependencies.
http://ant.apache.org/ivy/history/latest-milestone/resolver/ibiblio.html
<ibiblio name="maven2" m2compatible="true" root="http://myivyserver:8888/mirrored">
I haven't used it long because I preferred non-transitive dependencies in my code so I've finished with using pure url resolver.
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.
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" />