Can't compile Spring Roo project when using Nexus - maven

Can't compile Spring Roo (1.2.3.RELEASE) project when using Nexus.
mvn says can't find roo.annotations:jar
[ERROR] Failed to execute goal on project Roo123: Could not resolve dependencies for project com.example.roo:Roo123:jar:0.1.0.BUILD-SNAPSHOT: Failure to find org.springframework.roo:org.springframework.roo.annotations:jar:1.2.3.RELEASE in http://192.168.16.232: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]
However this jar is already in local maven repository.
When disabling Nexus, by renaming .m2\settings.xml, it works fine.
settings.xml has just 1 mirror configured
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://192.168.16.232:8081/nexus/content/groups/public</url>
</mirror>
How to configure Nexus?
(Adding http://spring-roo-repository.springsource.org/release as proxy repository doesn't help)
UPDATE: add picture. Adding spring-roo-repository on the left side doesn't help.
Two long answeres below doesn't help either.

It's not enough to configuration a mirrorof only you have to configure the following:
<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>
Apart from your configuration you need to delete your local repository and retry the build. Have you configured Nexus correctly to have access to the internet like maven central etc. ?

I don't know if you have admin access to your Nexus install, but you have to add a new proxy repository to your Nexus install.
The repo you have to add is
http://spring-roo-repository.springsource.org/release
You should have a settings file like below (slightly different than khmarbaise's version):
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>central</id>
<username>your-user</username>
<password>your-user</password>
</server>
<server>
<id>mirror</id>
<username>your-user</username>
<password>your-user</password>
</server>
</servers>
<mirrors>
<mirror>
<id>mirror</id>
<url>https://url.to.your.nexus</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>defaultprofile</id>
<repositories>
<repository>
<id>central</id>
<name>Repository for your artifacts</name>
<url>https://url.to.your.nexus</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Repository for your artifacts</name>
<url>https://url.to.your.nexus</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<activeProfiles>
<activeProfile>defaultprofile</activeProfile>
</activeProfiles>
</settings>
You have to override central (see above), so that Maven won't connect to the default central (repo1.maven.org).

Related

Nexus server with unexpected behavior

I've installed a local nexus on my computer to use it as a mirror of the numerous nexus servers that my company have.
I think it's working because if I access the following URL oin my browse:
http://localhost:2312/repository/my_repo/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
It's show the content of the .pom file.
But when I run mvn clean install on prompt, I got the following:
Failed to transfer file: http://localhost:2312/repository/my_repo/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom. Return code is: 504 , ReasonPhrase:Gateway Timeout.
On my maven settings.xml I put this:
<mirrors>
<mirror>
<id>Nexus</id>
<name>Nexus Local</name>
<url>http://localhost:2312/repository/my_repo/</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
What am I missing?
Have you setup your settings.xml 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>

set to NOT connect to specific nexus repository

There is on nexus repository which my application always connects in the building process. I don't find where this repository is set so:
is it possible to set in the pom.xml that do not connect to a specific repository?
settings.xml file is the correct location to configure 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>

maven - multiple repository lookup configuration

I'm using maven v3.0.1 for my projects. I've projects which depends on artifacts from a corporate remote repository. Also I had a local archiva repository in company which hold local artifacts, which are not in to corporate remote repository.
I would like to make the settings.xml in such a way that for all projects, it will lookup for the specified artifact first in the corporate remote repository, if not found there, look up for the artifact in the local archiva repository.
I added local repository in <repository> tag and enabled the profile for that <activeProfile>. But the looking up is not happening as expected. On analysis found that mirrorOf setting plays a role there. Following are my settings.xml.
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://corporate-repo: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>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
<repository>
<id>spring-snapshot</id>
<name>Spring Maven SNAPSHOT Repository</name>
<url>http://repo.springsource.org/libs-snapshot</url>
</repository>
<repository>
<id>internal</id>
<name>Local Release Repository</name>
<url>http://local-repo:8081/repository/internal</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
How can I modify the settings.xml to do the lookup as I required ? Whether any way to provide two urls in the mirrorOf settings. I tried
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://corporate-repo:8081/nexus/content/groups/public,http://local-repo:8081/repository/internal</url>
</mirror>
No errors in xml parsing, but lookup is not working. Can any one shed light on how to resolve this issue
I experimented with lot of options and finally resolved by tweaking the mirrorOf settings to <mirrorOf>*,!internal</mirrorOf>
So mirror settings are,
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*,!internal</mirrorOf>
<url>http://corporate-repo:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
* ensures that for all request except internal repo !internal do lookup in corporate repo. For internal repo, do look up in local-repo configured with repository id as internal

Using Nexus repository instead of public Maven in Idea Intellij

How can I force Idea Intellij to download from Nexus repository instead of Maven Public repo?
Where can I configure that in Idea properties?
It's not defined in pom.xml files and I'd prefer not to.
Not sure if it will work also on Idea Intellij ( I am using spring source studio - eclipse clon) , but should because maven configuration is in settings.xml in .M2 directory which is located in your home directory. Just use something like this ( my server is running on nexus-server:8081):
<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">
<servers>
<server>
<id>releases</id>
<username>user-name</username>
<password>your-password</password>
</server>
<server>
<id>snapshots</id>
<username>user-name</username>
<password>your-password</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus-server:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Disable 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>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

Prefetch maven-metadata.xml with nexus

With the maven3 configuration file settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<!--<host>webproxy</host>-->
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://richter-local.de:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<servers>
<server>
<id>nexus</id>
</server>
</servers>
<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>
<updatePolicy>interval:10080</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>interval:10080</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
</settings>
and a nexus maven proxy (version 2.7.2-03) I have to wait for a bunch of very slow downloads of maven-metadata.xml file every day after 00:00 a.m. (take about 5 mintues together for some KB which ought to be transfered within seconds). How can I prefetch those file in order to download them my local nexus instance?
It sounds like you have one or more proxy repositories that have remotes that are responding very slowly. Once a day the cache timeouts for these expires, resulting in very slow retrieval.
See here for information on how to debug this, and configure Nexus to prevent the issue from occurring again:
https://support.sonatype.com/entries/25884097-Troubleshooting-slow-maven-metadata-xml-download-speeds

Resources