My maven artifact is deployed to a Nexus snapshot repository. There, it is stored in the correct directory, but its filenames have the following pattern:
mylibrary-1.0-20130213.125827-2.jar
However, Maven fails to download that snapshot. According to the error log, Maven seems to expect the following file name:
mylibrary-1.0-SNAPSHOT.jar
These are the repository settings in my pom:
<repositories>
<repository>
<id>mycompany-all</id>
<url>https://servername/nexus/content/groups/mycompany/</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
Note: the nexus group includes both the releases and snapshots repo.
I did not configure these repos in settings.xml - is that the problem? Or what else am I doing wrong?
The pattern you posted (mylibrary-1.0-20130213.125827-2.jar) is a unique snapshot version. Maven 3 forces you to use this type of artifact naming, but in Maven 2 it can be prevented with a statement such as:
<distributionManagement>
...
<snapshotRepository>
...
<uniqueVersion>false</uniqueVersion>
</snapshotRepository>
...
</distributionManagement>
To use a specific snapshot in your project, declare it as:
<dependency>
<groupId>com.foo</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0-20130213.125827-2</version>
</dependency>
To use the latest known snapshot, declare it "old-style":
<dependency>
<groupId>com.foo</groupId>
<artifactId>mylibrary</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
You may find the answer to this similar question helpful as well.
I made it work by adding the repositories to the settings.xml like this:
<repositories>
<repository>
<id>mycompany-releases</id>
<url>https://servername/nexus/content/repositories/releases/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>mycompany-snapshots</id>
<url>https://servername/nexus/content/repositories/snapshots/</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
Then, the SNAPSHOT jar files were downloaded just fine. I suspect that when Maven knows it deals with a snapshot repo, it tries both with and without uniqueVersion (see Duncan Jones' answer).
Note that in our case these blocks had to be duplicated as pluginRepositories because we have custom Maven plugins.
Related
I develop a web application, and I am about to deploy in the server artifactory anonymously. I have distinguished the snapshot and release repositories with the corresponding artifactory url in the distributionManagement of my parent POM. The problem is that the deployment is always done in release and not in snapshot. Help me make the deposit in release and snapshot.
Here is my distributionManagement:
<distributionManagement>
<repository>
<id>My release</id>
<name>Release</name>
<uniqueVersion>true</uniqueVersion>
<layout>default</layout>
<url>repo/artifacotry/release</url>
</repository>
<snapshotRepository>
<id>My snapshot</id>
<name>Snapshot</name>
<uniqueVersion>false</uniqueVersion>
<layout>default</layout>
<url>repo/artifacotry/snapshot</url>
</snapshotRepository>
</distributionManagement>
So for my maven project I require jar dependencies that are available in public repositories and also jar dependencies that are on our company internal repository.
How do I configure my pom.xml so that I will retrieve the dependencies from public repositories and our company internal repository without synchronizing and uploading the stuff from public repos to the company internal repository.
In your settings.xml, which is usually in HOME_DIR/.m2 you need to add the company repository, maven central is included by default.
In the example below it will look for your artifact in each repo in order, starting with maven central.
<profile>
<id>extras</id>
<repositories>
<repository>
<id>release</id>
<name>libs-release</name>
<url>http://internal.corp:8091/artifactory/libs-release</url>
</repository>
<repository>
<id>snapshot</id>
<name>libs-snapshot</name>
<url>http://internal.corp:8091/artifactory/libs-snapshot-local</url>
</repository>
<repository>
<id>codelds</id>
<url>https://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Maven MILESTONE Repository</name>
<url>http://repo.springsource.org/libs-milestone</url>
</repository>
</repositories>
</profile>
I would also say that I set up our corporate repository so that is has a virtual repository to maven central. This means as people use artifacts they will be stored in the company repository. This is normal practice.
in our pom file we have a special profile that allow us to deploy artifacts to both our internal maven repo as well as external one which locate on google cloud.
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>nexus</id>
<name>Internal Releases</name>
<url>http://internal_instance_ip/nexus/content/repositories/releases</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus-snapshots</id>
<name>Internal Snapshots</name>
<url>http://internal_instance_ip/nexus/content/repositories/snapshots</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
<profiles>
<profile>
<id>gce</id>
<distributionManagement>
<repository>
<uniqueVersion>false</uniqueVersion>
<id>nexus-gce</id>
<name>External Releases</name>
<url>https://gce_instance_ip/content/repositories/releases</url>
<layout>default</layout>
</repository>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus-snapshots-gce</id>
<name>External Snapshots</name>
<url>https://gce_instance_ip/content/repositories/snapshots</url>
<layout>default</layout>
</snapshotRepository>
</distributionManagement>
</profile>
</profiles>
when I tried to deploy the project, it complained :
Return code is: 413, ReasonPhrase: Request Entity Too Large.
the project has lots of modules, the one that cause trouble doesn't need to be deployed to google cloud. How can i exclude that module from being deployed to the google cloud repo but still deployed to the internal repo?
You can exclude the module by passing the following argument on the command line:
--projects '!module-to-exclude'
From mvn --help:
-pl,--projects <arg> Comma-delimited list of specified
reactor projects to build instead
of all projects. A project can be
specified by [groupId]:artifactId
or by its relative path.
See also How to exclude a module from a Maven reactor build?
I've added two repositories to my pom:
<repositories>
<repository>
<id>objectify-appengine</id>
<url>http://objectify-appengine.googlecode.com/svn/maven</url>
</repository>
<repository>
<id>jboss</id>
<url>http://repository.jboss.org/maven2</url>
</repository>
</repositories>
but get 'Missing artifact ...' for all dependencies except jboss.(can't get dependencies from central and objectify)
Tried to add repositories to the settings.xml. But no effect.
What wrong?
Your repository is deprecated, update it this way :
<project >
<repositories>
<repository>
<id>JBoss Public repository</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
I'm defining a dependency in pom.xml in a Maven 3 project. Dependency is as follows:
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<scope>runtime</scope>
<version>2.2</version>
</dependency>
Repostory is described in pom as follows:
<repository>
<id>java.net</id>
<name>java.net</name>
<url>http://download.java.net/maven/2</url>
</repository>
Artifact is indeed present in the repository. It's easy to check. Despite that, Maven is trying to obtain the artifact from repo1.maven.org. What could be the reason of this? Maybe I make some crucial mistake in defining repository access? Other dependencies seem to do fine.
Plugin org.mortbay.jetty:maven-jetty-plugin:6.1.26 or one of its
dependencies could not be resolved: Could not find artifact
org.glassfish.web:el-impl:jar:2.2
in central (http://repo1.maven.org/maven2)
The repository that you have defined is used for dependencies, but not for plugins. Hence the error.
To address this, you need to define pluginRepositories:
<project>
<!-- ... -->
<pluginRepositories>
<pluginRepository>
<id>{repo.id}</id>
<url>{repo.url}</url>
</pluginRepository>
</pluginRepositories>
</project>
As to where you should specify - in pom.xml or settings.xml, read this SO post.
You need to check your maven settings.xml (Look into Maven folder: M2_HOME/conf).
The default repositories are defined there itself, and Maven central repository is taking precedence.
Define your repository in Maven's settings.xml like this:
<profiles>
<profile>
...
<repositories>
<repository>
<id>Java Net</id>
<name>Java Net</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://download.java.net/maven/2</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
...
</pluginRepositories>
...
</profile>
You can maybe overwrite the default Maven central repository location with yours if you don't want to do much configuration.
Cheers!
In my case, the real root issue was that the repo required authentication. However for some reason maven decided that it would be much better to not tell me that, and to instead use the first repo in the <repositories> list, and throw the Could not find artifact error for that repo.
After moving the repo that contained the package so it was the first one in the <repositories> list, it started showing me a "permission denied" message. Once maven was setup for authentication with the repo in question, the issue went away.
I had a similar problem however, another developer had set up a mirror in that I simply copy-pasted into my settings.xml file. Modifying the mirrorOf property to only include specific repos did the trick.
In addition to the above mentioned answers, make sure your settings.xml is saved as an xml file not a text file i.e. its not saved settings.xml.txt.