I have setup a nexus server and afterwards I had the opinion to simple deploy an artefact to this nexus server. Therefore I created a simple Java project with this pom:
<project xmlns="...">
<modelVersion>4.0.0</modelVersion>
<groupId>MyProject</groupId>
<artifactId>MyProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
My settings file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<settings ...>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<name>Nexus Public Mirror</name>
<mirrorOf>central</mirrorOf>
<url>http://it-nexus.domain:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Then I have tried to deploy my artefact with:
mvn deploy
and I got this Error:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-resources-plugin
:jar:2.6 in http://it-nexus.domain:8081/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of
nexus has elapsed or updates are forced -> [Help 1]
Actually I don't know what I am doing wrong!?
You've got a few things wrong (well, everything really).
First, you can remove profiles and everything under it, along with activeProfiles, from your server.xml file. Next, you need to add a servers entry, containing a server with the id, 'nexus' (assuming you're uploading to the same nexus instance you're using to mirror central), along with a username and password of some sort.
Then you have to have a distributionManagement section in your pom, referencing the same server you've specified in the settings.xml file, and configure the maven-deploy plugin. Documentation for that can be found here. You will also need an scm section.
The actual error you talk about is probably because your nexus server isn't actually configured to proxy/mirror central. Oh, and you should use * as the argument to mirrorOf.
Related
I'm a new guy on Maven and Nexus.
I have a problem to deploy my maven project (developped with IntelliJ) on my local Nexus.
You will find attached my maven settings.xml
My objective is to deploy my project without modify a pom.xml file, only the ~/.m2/settings.xml
I have tried the following command (which works) :
$ mvn clean deploy -DaltDeploymentRepository=nexus::default::http://192.168.1.8:8081/repository/maven-snapshots
But I want the same results with only :
$ mvn clean deploy
Any idea ?
Thanks
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.1.8:8081/repository/maven-public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>******</password>
</server>
</servers>
</settings>
You can add a <properties> section to your settings.xml and add
<altDeploymentRepository>nexus::default::http://192.168.1.8:8081/repository/maven-snapshots</altDeploymentRepository>
I setup a public repository in nexus which contains the groups of repositories we wish to access. We then use this as our main index in Eclipse for development and Bamboo for build.
I am adding in a couple of ZK repositories to this public repository - these repos have no indexes, and are unable to be scraped by Nexus. I presume this will prevent artifacts in them from being found. I have rebuilt the index for public in Nexus and in Eclipse with no luck.
Can I add the repositories in the setting.xml in eclipse? Currently this looks like the following:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>nexus</id>
<username>username</username>
<password>xxxx</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://<ip>:8400/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Search indexes are an optional repository feature. They are not used for artifact retrieval, they are used to support interactive search in UI's. Nexus will be able to pull artifacts from these proxy repositories without any problem. As artifacts are downloaded from the remote into the proxy repository's disk cache they will be added to the local search index.
i have below settings.xml. I have two pom files. one is specific to my internal project and another is specific to
external tool. Both points to separate repositories. I want to use single settings.xml so that dependecies are looked
into both repositories. Issue is when i run build on external tool pom, it sill looks into myProjectSpecificRepository but not inside http://URL2/nexus/content/groups/public. ( it only considering url given under mirror tag. I also tried giving second mirror tag with url as http://URL2/nexus/content/groups/public but no help)
I am not sure whats the issue?
<mirrors>
<mirror>
<id>My Id</id>
<mirrorOf>*</mirrorOf>
<url>http://myProjectSpecificRepository/url>
</mirror>
</mirrors>
</profiles>
<profile>
<id>project Specific profile</id>
......
<url>http://myProjectSpecificRepository/nexus/content/groups/public</url>
</profile>
<profile>
<id>External profile</id>
<repositories>
<repository>
<id>External releases</id>
<name>External profile name</name>
<url>http://URL2/nexus/content/groups/public</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>External profile plugin </id>
<name>External profile description</name>
<url>http://URL2/nexus/content/groups/public</url>
</pluginRepository>
</pluginRepositories>
</profile>
<activeProfiles>
<activeProfile>My Id</activeProfile>
<activeProfile>External profile</activeProfile>
</activeProfiles>
</profiles>
Maybe this is too granular, but I would like to order Maven Versions Plugin to use only specific repositories to check for (new versions). The reason for this is: I want the plugin to check only internal company dependencies (from local Nexus) and there is no reason why we should check external repos. (Takes some times and it's also a security issue in a way). I have the following setup in the parent ("config") POM:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.0</version>
<configuration>
<includes>
<include>com.mycompany.*:*</include>
</includes>
<serverId>automation-nexus</serverId>
</configuration>
</plugin>
The config above works fine in terms of not updating "external" dependencies, but "com.mycompany" artifacts are still queried from all other repositories. As you can see, I tried to use <serverId>, but that was just a guess, and it doesn't seem to do any "filtering" (I guess this is just a way to use specific credentials)
Any ideas if this is feasible or not?
You have to change your settings.xml instead and not the versions plugin configuration like this:
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
By using the above settings you will limit the access to the above group and furthermore you can search within the repository group instead of any external repository.
I am trying to run the command, mvn release:perform, but I get this error:
Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project git-demo:
Deployment failed: repository element
was not specified in the POM inside
distributionManagement element or in
-DaltDeploymentRepository=id::layout::url
parameter
Here's my pom.xml file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.sonatype.blog</groupId>
<artifactId>git-demo</artifactId>
<packaging>jar</packaging>
<version>1.1-SNAPSHOT</version>
<name>git-demo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<scm>
<connection>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</connection>
<url>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</url>
<developerConnection>scm:git:git#github.com:Christian-Achilli-KP/git-demo.git</developerConnection>
</scm>
<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>localSnap</id>
<name>RepositoryProxyRel</name>
<url>http://127.0.0.1:8080/nexus/content/repositories/releases/</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>MylocalSnap</id>
<name>RepositoryProxySnap</name>
<url>http://127.0.0.1:8080/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
</project>
Actually I can see the
repository
declaration inside the
distributionManagent
tag.
Here's my settings.xml:
<settings>
<servers>
<server>
<id>localSnap</id>
<username>deployment</username>
<password>****</password>
</server>
<server>
<id>MylocalSnap</id>
<username>deployment</username>
<password>****</password>
</server>
<server>
<id>myserver</id>
<username>tomcat</username>
<password>tomcat</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://127.0.0.1:8080/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<properties>
<project.build.sourceEncoding>MacRoman</project.build.sourceEncoding>
<project.reporting.outputEncoding>MacRoman</project.reporting.outputEncoding>
</properties>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Any advice why it complains?
Review the pom.xml file inside of target/checkout/. Chances are, the pom.xml in your trunk or master branch does not have the distributionManagement tag.
I got the same message ("repository element was not specified in the POM inside distributionManagement element"). I checked /target/checkout/pom.xml and as per another answer and it really lacked <distributionManagement>.
It turned out that the problem was that <distributionManagement> was missing in pom.xml in my master branch (using git).
After cleaning up (mvn release:rollback, mvn clean, mvn release:clean, git tag -d v1.0.0) I run mvn release again and it worked.
You can also override the deployment repository on the command line:
-Darguments=-DaltDeploymentRepository=myreposid::default::http://my/url/releases
The ID of the two repos are both localSnap; that's probably not what you want and it might confuse Maven.
If that's not it: There might be more repository elements in your POM. Search the output of mvn help:effective-pom for repository to make sure the number and place of them is what you expect.
For me, this was something as simple as a missing version for my artifact - "1.1-SNAPSHOT"