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

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>

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/

Mirror repository for codehous not picked up while maven build

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.

Maven cannot pull jars from Mirros

We have a central repository within intranet. I set mirror as follow. The issue is when I try to download a dependency that is not available in my local repository, the dependency cannot be downloaded completely. Only .lastUpdated file is downloaded in directory. I cannot figure out whey this weird thing happened. But it I comment the mirror setting, the dependency could be downloaded correctly. But I need some ourselves developed dependencies that are residing on central repository. That means I cannot bypass the central repository to search on internet. Does anyone come across this creepy issue?
<mirror>
<id>central-proxy</id>
<name>Central Repo</name>
<url>http://*.*.*.*.*/artifactory/repo</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>

How to create a local central repository for maven artifacts

My organization uses maven for all our projects. Every time we create new maven project, the artifacts are downloaded from maven central repository. But i want to create organization level local repository where all the maven artifacts are available and when new maven project created should look for the artifact in local repository and if not found, then only look in the maven central repository. Can anyone let me know how to do this.
Thanks.
You should take a look at Sonatype Nexus repository manager. It can be used as a proxy to cache remote repositories. After Nexus has been set up, you will just have to edit your settings.xml and add something like this:
<mirrors>
<mirror>
<id>nexus-proxy</id>
<name>Nexus Proxy</name>
<url>http://nexus.example.com/nexus/content/groups/public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
You could use Artifactory or a similar Repository Management tool

Resources