Maven - Unable to resolve dependencies - maven

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>

Related

Dependency javax.mail:mail:1.4 not found

After I imported a maven project in IntelliJ IDEA, there are two errors in the pom.xml file:
"Failed to read artifact descriptor for javax.mail:mail:jar:1.4"
"Dependency javax.mail:mail:1.4 not found"
Does anyone know the reason behind these errors and how can I fix them?
Thank you and have a great day!
Due to license restrictions the older java mail classes are not in maven central or the java.net repository. usually companies host their own maven proxy and add these classes there.
Since around version 1.4.5 the dependencies are available in the java.net repository. Some later versions are also in maven central.
All other versions need to be downloaded from the oracle website and either added to a maven proxy or to your local maven repository - for example using the dependency plugin.
Change the pom.xml to include:
<dependencies>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>
Or if you have a build.gradle file in the dependencies section add:
compile "com.sun.mail:jakarta.mail:1.6.3"

How to cache specific maven artifact into local repository?

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.

maven assembly how to add a zip flie from nexus repository to the build

I am trying to include a zip file from nexus repository to my project during packaging using the maven assembly plugin. This zip file has YAJSW and other custom scripts. The maven assembly can build a tar.gz package now, but how do I include a zip file from nexus repository. There is a pom for that zip file. Should I just include that as dependency? Is this the correct plugin or should I use another plugin.
Thanks.
Add the dependency of the zip file like the following:
The following is an example for archive which has been created by maven-assembly-plugin:
<dependency>
<groupId>the.group.id</groupId>
<artifactId>the-artifactid</artifactId>
<version>1.0</version>
<type>tar.gz</type>
<cassifier>bin-unix</classifier>
</dependency>
<dependency>
<groupId>the.group.id</groupId>
<artifactId>the-artifactid</artifactId>
<version>1.0</version>
<type>zip</type>
<cassifier>bin</classifier>
</dependency>
The classifier in those cases is comming from the assembly-decscriptor-id in the project which creates the archive. Apart from that it is important to define the type.
Add a dependency to the zip with the respective GAV (group/artifactId/version).
(Without seeing your pom.xml it's a bit hard to say more).

Need explanation for maven error please

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.

Can I download a jar file from maven central using maven?

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.

Resources