Mirror repository for codehous not picked up while maven build - maven

I am getting below error while maven build. I have added mirror repository for nexus.codehaus.org but still its going for codehaus.
Maven Build Error :-
org.apache.maven.plugins:maven-enforcer-plugin:1.2 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-enforcer-plugin:jar:1.2: Could not transfer artifact org.apache.maven.plugins:maven-enforcer-plugin:pom:1.2 from/to mojo-snapshot (https://nexus.codehaus.org/content/repositories/codehaus-snapshots/): nexus.codehaus.org: Unknown host nexus.codehaus.org -> [Help 1]
Mirror repositories I have added in setting.xml:-
<mirror>
<id>no-codehaus-releases</id>
<name>codehaus releases</name>
<url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
<mirrorOf>codehaus-releases,codehaus,mule-deps,codehaus.org</mirrorOf>
</mirror>
<mirror>
<id>no-codehaus-snapshots</id>
<name>codehaus snapshots</name>
<url>https://repository.mulesoft.org/snapshots/</url>
<mirrorOf>codehaus-snaphosts</mirrorOf>
</mirror>
Please let me know if i missed anything.

Related

Maven not pulling dependency from correct repository

I have 3 repositories setup in our Nexus Repository manager
COMPANY_maven-proxy -> proxies https://repo1.maven.org/maven2/
COMPANY_maven-redhat-proxy -> proxies https://maven.repository.redhat.com/ga/
3rd-Party-Tools -> our companies homegrown 3rdParty dependencies
When I run the mvn install command it pulls everything I'm looking for from each of these repositories (the dependency itself and the transitive dependencies). All except for one!
org.jboss.seam.integration:jboss-seam-int-jbossas:pom:7.0.0.GA
This dependency lives in the Redhat maven repository:
<dependency>
<groupId>org.jboss.seam.integration</groupId>
<artifactId>jboss-seam-int-jbossas</artifactId>
<version>7.0.0.GA</version>
<type>pom</type>
</dependency>
For whatever reason, this one dependency is looking under the COMPANY_maven-proxy repository instead of the COMPANY_maven-redhat-proxy repository.
Here's what I have for my settings.xml:
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<mirrors>
<mirror>
<!--This sends everything to COMPANY_maven-proxy that isn't in COMPANY_maven-redhat-proxy -->
<id>COMPANY_maven-proxy</id>
<url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
<mirrorOf>*,!COMPANY_maven-redhat-proxy</mirrorOf>
</mirror>
<mirror>
<!-- This sends everything to COMPANY_maven-redhat-proxy that isn't in COMPANY_maven-proxy -->
<id>COMPANY_maven-redhat-proxy</id>
<url>http://FQDN:8081/nexus/repository/COMPANY_maven-redhat-proxy/</url>
<mirrorOf>*,!COMPANY_maven-proxy</mirrorOf>
</mirror>
<mirror>
<!--This sends everything else to 3rd-Party-Tools -->
<id>3rd-Party-Tools</id>
<url>http://FQDN:8081/nexus/repository/3rd-Party-Tools/</url>
<mirrorOf>!COMPANY_maven-proxy,!COMPANY_maven-redhat-proxy</mirrorOf>
</mirror>
</mirrors>
</settings>
Here's the error I get:
Failed to collect dependencies at org.jboss.seam.integration:jboss-seam-int-
jbossas:pom:7.0.0.GA: Failed to read artifact descriptor for org.jboss.seam.integration:jboss-
seam-int-jbossas:pom:7.0.0.GA: Could not find artifact org.jboss.seam.integration:jboss-seam-
int:pom:7.0.0.GA in COMPANY_maven-proxy (http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/) -> [Help 1]
I've tried multiple combination's within the <mirrorOf> tag but nothing has worked. I've even put this transitive depency in my pom under <dependencies> and/or <dependencyManagement>.
Any help on this would be appreciated!
Thanks!
The mirrors are for already existing repositories declared. In your settings.xml you do not have repositories listed, but the default Maven Central. Thus it makes sense to define just a mirror of Maven Central, redirecting to the company's Nexus repo. with a rare trick, one could register a mirror for any external repos, for example:
<mirror>
<id>public</id>
<mirrorOf>central</mirrorOf>
<name>Let the default Maven Central repository is resolved in the local Nexus' public repository</name>
<url>http://FQDN:8081/nexus/repository/COMPANY_maven-proxy/</url>
</mirror>
Any mirror from your example should be registered in the pom.xml as repositories.
Edited:
removed the second ("other") mirror, as the example was adapted from a case where the repository manager to direct to runs at localhost.

Are all maven mirrors the same?

I have following error when using mvn clean install to build janusgraph examples
[ERROR] Non-resolvable parent POM for
org.janusgraph:janusgraph-examples:[unknown-version]:
Could not find artifact org.janusgraph:janusgraph:pom:0.4.0 in alimaven
(http://maven.aliyun.com/nexus/content/groups/public/)
and 'parent.relativePath' points at wrong local POM
# line 3, column 13 -> [Help 2]
According to the error, I opened my setting.xml of maven, The mirror conf is
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirrors>
It says it could not find in this mirror, so would it work if I change another mirror? Are all the mirrors the same (except for the network speed)?
No, there is a large number of different Maven repositories with different content. Usually, though, you draw most of your content from MavenCentral:
https://repo1.maven.org/maven2/

why can't i upload artifact to archiva (Unauthorized), but i can download from it with admin user?

I'm working with archiva for about a year now,
I upload my jars manually through archiva GUI,and it's working fine.
Now I want to upload an artifact with maven deploy,the problem is that I get 401-Unauthorized.
bare in mind that:
1.) I can download from this repository with no problem .
2.) I use admin user .
3.) I can upload with this user manually.
this is the log that I get:
[com:apinterface.parent] Downloading: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/maven-metadata.xml
[11:43:39][Step 1/3] [INFO] ------------------------------------------------------------------------
[11:43:39][Step 1/3] [ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project apinterface.parent: Failed to deploy artifacts: Could not transfer artifact com:apinterface.parent:pom:1.0-20140924.084338-1 from/to snapshots (http://xx.xx.xx.xx:9080/archiva/repository/snapshots): Failed to transfer file: http://xx.xx.xx.xx:9080/archiva/repository/snapshots/com/apinterface.parent/1.0-SNAPSHOT/apinterface.parent-1.0-20140924.084338-1.pom. Return code is: 401, ReasonPhrase: Unauthorized. -> [Help 1]
This should be because you haven't configured Maven to use the Archiva Username/Password for uploading artifacts during the deploy phase.
I assume you have already configured the distributionManagement section in your pom file.
<distributionManagement>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshots</name>
<url>http://xx.xx.xx.xx:9080/archiva/repository/snapshots/</url>
</snapshotRepository>
<repository>
<id>releases</id>
<name>Internal Releases</name>
<url>http://xx.xx.xx.xx:9080/archiva/repository/releases</url>
</repository>
</distributionManagement>
You should have servers with matching ids in your Maven Settings file (like in the sample below) to configure the username/password which maven should use while uploading(deploy) the artifacts
<settings>
<servers>
<server>
<id>snapshots</id>
<username>archiva-user</username>
<password>archiva-pwd</password>
</server>
<server>
<id>releases</id>
<username>archiva-user</username>
<password>archiva-pwd</password>
</server>
</servers>
</settings>
Optionally, you can give free access for the download by adding the Guest user access to the repositories at:
Manage -> Users (Tab)
Edit the roles and in "Repository Manager Repository Observer" select the free access repositories

Local Nexus Repository Acting Like A Proxy For Some Maven Artifacts

I am using my own version of the Nexus web app repository installed on my local machine. I have Nexus configured with only one repository, the one where I store my snapshots:
http://localhost:8081/nexus/content/repositories/MySnapshots/
Note that after the Nexus installation I removed all the default repositories and added just my own. (Perhaps this was a bad idea?)
When I do a mvn clean install I noticed that some of the 3rd party artifacts are downloading straight from the remote repository. For example, here is one of the output lines from the build:
Downloading: http://repo.maven.apache.org/maven2/com/sun/org/apache/xml/internal/resolver/...
The strange thing is that I see other artifacts are going through my local Nexus to ultimately get to the artifact:
Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/org/apache/maven/wagon/wagon-provider-api...
Notice how the first part of the download url is my local repository but everything after MySnapshots is from apache.org.
It's almost like my Nexus repository is acting like a proxy to maven.apache.org for some artifact downloads but for others it goes straight to the source.
Can anyone tell me why this is happening?
I would't be bothered so much by this if all my builds succeeded all the time but sometimes, when I am compile large projects, I get build failures due to not being able to find an artifact.
For example, when I try to build another project that depends on eclipse jdt stuff I get the following error:
Downloading: http://localhost:8081/nexus/content/repositories/MySnapshots/eclipse/jdt/core/eclipse.jdt.core
Could not find artifact eclipse.jdt.core:eclipse.jdt.core
I am not sure if this means that my Nexus is not configured properly or if there really is no artifact eclipse.jdt.com. If the downloads were not going through my local Nexus repository I would then investigate the pom/settings.xml files. Instead this makes me wonder if it's due to my Nexus configuration.
If you would like to see my settings.xml for Maven and my pom file for the project I am building when I see this you can view them here:
settings.xml: http://pastebin.com/NvLr5bEA
pom.xml: http://pastebin.com/PJ0P3RaK
If you like to use the local nexus as a proxy as usual than you have to configure the settings.xml like this:
<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>
The tricky thing is the mirror thing which reroutes every call to the configured nexus instance.
Things you mentioned like eclipse parts can be problematic, cause only a few artifacts are available via maven central. Furthermore you should leave the defaults like maven central, release repository and the snapshots repository unchanged, cause these are the repository you need.
I don't think its a proxy issue , upto my understanding for the first case when it is downloading from Maven Central Repo , it might be possible that same artifact is not available in your nexus repository , that's why it is going to Maven Central Repo.
In the second case it is available in your nexus so reactor didn't try to download it from Maven Central Repo.

How to setup a local mirror of eclipse artifacts for mvn tycho plugin?

If this is due to a timeout, then how can I setup an internal mirror to improve performance and reduce risk of timeout
Problem
Maven build downloads eclipse p2 artifacts via tycho plugin and times out during the build.
[ERROR] Internal error: org.eclipse.tycho.core.osgitools.OsgiManifestParserException:
Exception parsing OSGi MANIFEST /opt/atlassian/bamboo-agent-home/xml-data/build-dir/m2repo
/p2/osgi/bundle/org.eclipse.swt/3.100.1.v4234e/org.eclipse.swt-3.100.1.v4234e.jar:
error in opening zip file -> [Help 1]
Nexus Pro can handle p2 repositories but I don't think Nexus OSS can.
Create P2 Repository in Nexus Pro (url http://download.eclipse.org/releases/juno/)
Create P2 Repository group in Nexus Pro
Add P2 Repository to P2 Repository group
Modify your settings.xml to add in a p2 mirror
The first mirror is for maven, the 2nd for tycho eclipse p2 repositories
<mirrors>
<mirror>
<id>internal-repository</id>
<name>Maven Repository Manager running on repo.mycompany.com</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
<mirror>
<id>p2-repository</id>
<name>p2 Repository mirror</name>
<url>http://localhost:8081/nexus/content/groups/p2groups/</url>
<layout>p2</layout>
<mirrorOfLayouts>p2</mirrorOfLayouts>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

Resources