Suppose I have some Maven coordinates, like
org.ow2.asm:asm:5.0.3
How would I cache these artifact into (existing) local maven repository?
I believe this truly answers your question: it shows how to download and cache locally a specific Maven artifact from specific Maven repository with all dependencies without having to create pom.xml or any other sort of dependency declaration.
In your pom.xml add under <dependencies> the following :
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
and use the command
mvn clean verify
at your project level to build the project and its dependencies to find the artifact in the corresponding .m2/repository folder.
Related
In our project we use the artifact
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>1.7.5</version>
</dependency>
Everything works fine: Nexus downloads the same content as in http://repo1.maven.org/maven2/nl/jqno/equalsverifier/equalsverifier/1.7.5/ to its proxy repository.
('Download' column in artifact details on Nexus shows 'pom, jar')
Now, we switch to the newest version 2.0.2 of the artifact:
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>2.0.2</version>
</dependency>
Then, when we try to build the project then the attempt fails. Nexus cannot resolve the artifact! It seems like Nexus didn't download the complete content of the artifact version ('Download' column in artifact details on Nexus shows 'pom, pom'). On the other site, when I look at the artifact in the Central repository, the content is as usual: http://repo1.maven.org/maven2/nl/jqno/equalsverifier/equalsverifier/2.0.2/.
What causes the problem with the newest artifact version? Why can't Nexus download it correctly?
You may have overlooked that your dependency is of type pom. This will only download the pom, because that's what you are asking for. Remove the <type> and you should get the jar aswell.
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<version>2.0.2</version>
<type>pom</type> <-------------- Remove this
</dependency>
Assuming crea1's answer didn't solve your problem:
Maybe something went wrong when Maven downloaded the artifact, causing Maven to "think" the artifact was downloaded anyway.
You can force Maven to try and download it again with mvn -U test.
If that doesn't work, try going into ~/.m2/repository (or wherever Maven stores its artifacts locally on your system), locating EqualsVerifier, removing the entire 2.0.2 folder, and calling Maven again.
I have installed an artifact successfully into my local maven repository.
How do I add a dependency to this artifact in a second client maven project?
What would the POM file of the client look like?
It would be same as other dependency you are providing.
Let say you first project groupId is A.B.C.D ,artifactId is XYZ and version is 1.0,Then you just need to declare below line in the dependencies section of your second maven project,Maven will automatically find it from local repository.
<dependency>
<groupId>A.B.C.D</groupId>
<artifactId>XYZ</artifactId>
<version>1.0</version>
</dependency>
http://blog.bigpixel.ro/2012/07/building-cc-applications-with-maven/comment-page-1/#comment-8196
I'm following the example above for the maven nar plugin, but I get the following error when I do a mvn package
“could not find artifact net.sf.antcontrib:cpptasks-parallel:jar:1.0-beta-5-parallel-1-SNAPSHOT” but I see the following folder tree and its contents in my ~/.m2/repository... What gives?
~
.m2
repository
net
sf
antcontrib
cpptasks-parallel
1.0-beta-5-parallel-1-SNAPSHOT
Change dependency
<dependency>
<groupId>net.sf.antcontrib</groupId>
<artifactId>cpptasks-parallel</artifactId>
<version>1.0-beta-5-parallel-1-SNAPSHOT</version>
</dependency>
to
<dependency>
<groupId>org.codeswarm</groupId>
<artifactId>cpptasks-parallel</artifactId>
<version>20121119</version>
</dependency>
Unfortunately, neither maven-nar-plugin nor cpptasks-parallel are currently deployed to Central. So you need to mvn install them yourself (or better, mvn deploy them to your own Maven repository). You can find both projects on GitHub.
EDIT: nar-maven-plugin version 3.0.0 has been released, and is now available from Maven Central. Two notes:
The groupId and artifactId changed; the GAV is now:
<plugin>
<groupId>com.github.maven-nar</groupId>
<artifactId>nar-maven-plugin</artifactId>
<version>3.0.0</version>
</plugin>
The cpptasks-parallel project has been merged into nar-maven-plugin, so no need to worry about that dependency anymore.
I have a dependency problem with maven. I used to have saxon 8.7 that is located on maven central. Then, I had to upgrade to the latests saxon-b 9.1.0.0 which is only partially on maven central.
This is a snippet of my dependencies:
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon-dom</artifactId>
<version>9.1.0.8</version>
<scope>runtime</scope>
</dependency>
The first artifact 'saxon' is available on maven central, but the secon 'saxon-dom'. Here is the artifact I want.
Can I tell maven to download the "jar" file or am I obliged to download the jar and publish it locally on my maven repo to use it as a dependency?
Did not expect to resolve this so easily :
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxon</artifactId>
<version>9.1.0.8</version>
<classifier>dom</classifier>
</dependency>
Basically, I can get the dependencies that are "attached" to the 'saxon' artifact using the classifier tag. Did not know about this and I found out that the tag existed when I searched for 'saxon' on Sonatype repository (which is quite good). It gave me the dependency snippet above.
Reference : http://maven.apache.org/pom.html
If the required version is not in the repo, then yes you need to do one of the following alternatives
Search for a public repo containing the required version of jar. And add the repo to your pom.xml file. OR
Download it manually, and install it locally on your machine, to help the project build completely.
Im trying to compile a Maven project. The compile fails however due to a "Failure to find xx.xxx.jar" in the repository i have specified in my settings.xml. I have access to this repository and when i navigate to the Url of the repository maven is trying to use i can see a pom file with the name of the jar but no jar. When i open the pom it contains the correct groupid and artificatid and jar name however the jar is not in the same directory.
Maven gives another error saying that "resolution will not be reattempted until the update interval of my repo-server has elasped or updated are forced".
What is happening here?
When maven goes to the repo i specify in settings.xml and finds a pom for the jar does it then try and go out to some external site to resolve the dependency or should the jar exist in the same folder as the pom?
What module are you attempting to download?
I discovered something similar with the following Maven central module:
http://search.maven.org/#artifactdetails|net.sf.json-lib|json-lib|2.4|jar
The Maven POM packaging declaration was jar, but no jar in Maven called "json-lib-2.4.jar"
When I looked at the files actually stored, I discovered that the author is providing two versions of the jar, each compiled for different versions of the JVM:
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk13</classifier>
</dependency>
<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>