Are all maven mirrors the same? - maven

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/

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.

Maven Build Failure -- DependencyResolutionException

I'm installing a package that has Maven dependency and get a DependencyResolutionException when I try to clean it.
After cloning it, I navigate to the directory and run the following to install it with no error:
mvn install:install-file -Dfile=./lib/massbank.jar -DgroupId=massbank -DartifactId=massbank -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=./lib/metfusion.jar -DgroupId=de.ipbhalle.msbi -DartifactId=metfusion -Dversion=1.0 -Dpackaging=jar
Then:
mvn clean package
with the following console output:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< MassBank2NIST:MassBank2NIST >---------------------
[INFO] Building MassBank2NIST 0.0.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.450 s
[INFO] Finished at: 2021-04-07T01:08:28-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MassBank2NIST: Could not resolve dependencies for project MassBank2NIST:MassBank2NIST:jar:0.0.2-SNAPSHOT: Failed to collect dependencies at edu.ucdavis.fiehnlab.splash:core:jar:1.8: Failed to read artifact descriptor for edu.ucdavis.fiehnlab.splash:core:jar:1.8: Could not transfer artifact edu.ucdavis.fiehnlab.splash:core:pom:1.8 from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [EBI (http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/, default, releases+snapshots), releases (http://gose.fiehnlab.ucdavis.edu:55000/content/groups/public, default, releases+snapshots)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I can post the output of the debug logging switch if necessary, but it's quite long. I can also post the pom.xml, however it refers to the repositories as required from what I can tell.
I've searched for similar posts, but none seem to contain the same series of errors or similar. Can someone help me decipher these errors?
Thanks!
You don't have to downgrade Maven. What happens here is that since 3.8.1, Maven comes with a default configuration to block all HTTP (insecure) repositories. The best way would be to upgrade your repositories and make them secure (HTTPS).
However, you can tell Maven to allow downloading from your insecure repository by adding this mirror to your ~/.m2/settings.xml:
<mirror>
<id>insecure-repo</id>
<mirrorOf>external:http:*</mirrorOf>
<url>http://www.ebi.ac.uk/intact/maven/nexus/content/repositories/ebi-repo/</url>
<blocked>false</blocked>
</mirror>
Setting blocked to false will fix your issue. Note that above snippet assumes that the repository at www.ebi.ac.uk mirrors all insecure HTTP repositories (which is what external:http:* means).
You can also unblock individual repositories. For example, the JasperSoft repository is insecure, I unblock it with:
<mirror>
<id>jaspersoft-third-party-mirror</id>
<mirrorOf>jaspersoft-third-party</mirrorOf>
<url>http://jaspersoft.jfrog.io/jaspersoft/third-party-ce-artifacts/</url>
<blocked>false</blocked>
</mirror>
Open file ${MAVEN_HOME}/conf/settings.xml
And Comment these lines.
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>false</blocked>
</mirror>
If you do not have access to ~/.m2/settings.xml because your build is handled by cloud CI/CD or you want to share this solution with your team members. The best way is to create your own maven setting file in the project.
Create .mvn folder in your project.
Create custom-settings.xml file inside .mvn folder with such content (in this example we unblock http connection for releases.java.net mirror):
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
<mirrors>
<mirror>
<id>releases-java-net-http-unblocker</id>
<mirrorOf>releases.java.net</mirrorOf>
<name>releases.java.net</name>
<url>http://maven.java.net/content/repositories/releases/</url>
<blocked>false</blocked>
</mirror>
</mirrors>
</settings>
Create maven.config file inside .mvn folder with such content:
--settings ../.mvn/custom-settings.xml
Or you can just run mvn clean install --settings .mvn/custom-settings.xml.
The error "Blocked mirror for repositories" is referred to explicitly in Maven's release note for version 3.8.1:
How to fix when I get a HTTP repository blocked?
If the repository is defined in your pom.xml, please fix it in your source code.
If the repository is defined in one of your dependencies POM, you’ll get a message like:
[ERROR] Failed to execute goal on project test: Could not resolve dependencies for project xxx: Failed to collect dependencies at my.test:dependency:version -> my.test.transitive:transitive:version: Failed to read artifact descriptor for my.test.transitive:transitive:jar:version: Could not transfer artifact my.test.transitive:transitive:pom:version from/to maven-default-http-blocker (http://0.0.0.0/): Blocked mirror for repositories: [blocked-repository-id (http://blocked.repository.org, default, releases+snapshots)]
They go on to offer some ways to avoid the problem:
Options to fix are:
upgrade the dependency version to a newer version that replaced the obsolete HTTP repository URL with a HTTPS one,
keep the dependency version but define a mirror in your settings.
Plus, I suppose, the simpler, shorter-term option would be to roll back your version of Maven to anything prior to 3.8.1.
Use apache-maven-3.6.3, which uses http only
https://downloads.apache.org/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.zip
use apache-maven-3.8.1, adding the following in ~/.m2/settings.xml could solve such problem:
<mirrors>
<mirror>
<id>internal-repository</id>
<name>Maven Repository Manager running on https://repo1.maven.org/maven2</name>
<url>https://repo1.maven.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
Refer to this link https://maven.apache.org/guides/mini/guide-mirror-settings.html to see why the error occurred.
I had a similar problem but with Vaadin.
There is the simplest solution possible, and it is to replace all http:// with https://
This is an example :
<repository>
<id>vaadin-addons</id>
<url>https://maven.vaadin.com/vaadin-addons</url>
</repository>
This is due to latest maven blocks insecure HTTP connections. One possibility is adding a mirror to maven settings.xml. Best way is updating the pom file to refer to secure HTTPS repository if it is available. For example I faced the same issue with following config in pom.xml.
<repositories>
<repository>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
<checksumPolicy>ignore</checksumPolicy>
</releases>
<id>wso2-nexus</id>
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
</repository>
</repositories>
I was able to resolve the issue by updating URL as bellow. Here I referred to HTTPS repo which was available in my case.
<url>https://maven.wso2.org/nexus/content/groups/wso2-public/</url>
For me, I had to downgrade to the older version 3.6.3 from the site and the crazy problem is gone, hope maven community can fix this problem without us doing anything to our settings.xml.
apache-maven-3.6.3-bin will resolve the maven-default-http-blocker (http //0.0.0.0/) blocked Issue (fixed for me) it works for me
New mvn versions do not support http (insecure repos)
ultimately had to downgrade to mvn 3.5
brew uninstall maven
Instructions to install mvn 3.5 can be found at
https://formulae.brew.sh/formula/maven#3.5

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.

Issue with maven deployment in snapshotRepository of Nexus

While using the snapshotRepository to deploy my artifact using maven with distributionManagement
<distributionManagement>
<snapshotRepository>
<uniqueVersion>true</uniqueVersion>
<id>nexus</id>
<name>nexus Snapshots</name>
<url>http://127.0.0.1:8081/nexus/content/repositories/snapshots</url>
<layout>legacy</layout>
</snapshotRepository>
</distributionManagement>
I m stuck into the error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.6:
deploy (default-deploy) on project abc.parent: Deployment failed: repositor
y element was not specified in the POM inside distributionManagement element or
in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
The error looks that it is searching for repository element inside distributionManagement but i have defined snapshotRepository as per http://maven.apache.org/plugins/maven-deploy-plugin/usage.html and when I replace token with and url inside this with nexus releases repository url it works fine , I have read many suggestions and few at stackoverflow as well with same error but still struggling........................
The version of your project determines if it is going to use. snapshotRepository is ONLY going to be used if you version ends in "-SNAPSHOT", otherwise it will use the repository element.
If you do NOT use a -SNAPSHOT version... it will just upload to the repository you specify. It will, by defintion, be a release repo. Also this has nothing to do with Nexus but rather with how the Maven repository format works. Snapshot repositories are different from release repos and if you have a release (version does not end in -SNAPSHOT) you should upload to a release 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