Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download artifacts from ivy repository using maven

We are moving from ivy to maven. We have lots of artifacts in artifactory which were published using ivy and hence the artifact folder/path structure is similar to

  1. artifactory/libs-release/[organization]/[module]/[revision]/[type]s/[module](-[classifier]).[ext]

  2. artifactory/libs-release/[organization]/[module]/[revision]/[type]s/ivy.xml

However, when we add the dependency in maven pom.xml , the dependency name will be something like com.abc.xyz. But maven tries to look into the path com/abc/xyz/ folder whereas we have the artifact in artifactory in com.abc.xyz/my-artifact/1.0.0/jars/my-artifact.jar

How can I tell maven (pom.xml) to read and understand the path which is in artifactory.

I tried using ivy-maven-plugin but it gives classNotFound error for some groovy class even though I have required groovy jars in my local m2 repository folder.

* Answer ok, here is what we did. We created folders manually and then we are now using makepom plugin to convert ivy.xml to maven pom.xml Thank you to all your suggestions and more are welcome.

like image 473
S S Avatar asked Oct 10 '12 12:10

S S


People also ask

How do I download artifacts from Artifactory using Maven?

Once you have created your Maven repository, go to Application | Artifactory | Artifacts, select your Maven repository and click Set Me Up. In the Set Me Up dialog, click Generate Maven Settings. You can now specify the repositories you want to configure for Maven.

What are Maven artifacts?

In Maven terminology, an artifact is an output generated after a Maven project build. It can be, for example, a jar, war, or any other executable file. Also, Maven artifacts include five key elements, groupId, artifactId, version, packaging, and classifier.


2 Answers

Why would you try to fit Maven into Ivy. Ivy was there to utilize and mimic what Maven already have at that time.

Since Ivy can read Maven repository but not the other way around, I would suggest you to setup your own local network (or company) Maven repository, either using Nexus or Artifactory. Then you can upload the artifact there one by one, and the standardize those Ivy build to point to that new Maven repository. This takes some additional efforts at the beginning, but I believe it will pay up later.

There is another option, configure Maven to read non-standard repository layout, but why would you want to go that route? Everything will be much more difficult once you choose this path.

like image 181
Daniel Baktiar Avatar answered Nov 02 '22 22:11

Daniel Baktiar


Take a look at my Ivy integration package. The jar.macro is especially convenient because it automatically builds the pom.xml as you build the jar. The macro is very similar to the jar task.

What I do is build pom.xml with each of my jars, then use mvn deploy:deploy-file to deploy my jars to the Maven repository.

mvn deploy:deploy-file -Dfile=$jar_file
    -D pomFile=pom.xml
    -D repositoryId=$repo_id
    -D url=$repo_url
like image 34
David W. Avatar answered Nov 02 '22 20:11

David W.