I have 3 repositories in my settings.xml because I need artifacts from all of them. Whenever a dependency is not found, Maven tries
Downloading: http://some.server/mvn2repo/releases/org/apache/lucene/lucene-core/2.9.1/...
[INFO] Unable to find resource 'org.apache.lucene:lucene-core:pom:2.9.1' in repository
Downloading: http://some.server/mvn2repo/3rdParty/org/apache/lucene/lucene-core/2.9.1/...
[INFO] Unable to find resource 'org.apache.lucene:lucene-core:pom:2.9.1' in repository
Downloading: http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.9.1/lucene-core-2.9.1.pom
<success>
all repositories, but most of the time finds the artifact in central (repo1) of course. I want Maven to check this repo first. I tried order of declarations in settings.xml, but did not work. According to fgysin I also tried the reverse order, which didn't change anything.
My Maven version:
C:\>mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_15
Java home: C:\Program Files\Java\jdk1.6.0_15\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows vista" version: "6.0" arch: "amd64" Family: "windows"
My settings.xml
<profiles>
<profile>
<id>space</id>
<repositories>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>s1-releases</id>
<name>System One Releases</name>
<url>http://some.server/mvn2repo/releases</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>s1-3rdParty</id>
<name>System One 3rd Party Releases</name>
<url>http://some.server/mvn2repo/3rdParty</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>space</activeProfile>
</activeProfiles>
As far as I know, the order of the repositories in your pom.xml will also decide the order of the repository access.
As for configuring repositories in settings.xml, I've read that the order of repositories is interestingly enough the inverse order of how the repositories will be accessed.
Here a post where someone explains this curiosity:
http://community.jboss.org/message/576851
None of these answers were correct in my case.. the order seems dependent on the alphabetical ordering of the <id> tag, which is an arbitrary string. Hence this forced repo search order:
<repository>
<id>1_maven.apache.org</id>
<releases> <enabled>true</enabled> </releases>
<snapshots> <enabled>true</enabled> </snapshots>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
</repository>
<repository>
<id>2_maven.oracle.com</id>
<releases> <enabled>true</enabled> </releases>
<snapshots> <enabled>false</enabled> </snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
Also, consider to use a repository manager such as Nexus and configure all your repositories there.
Related
There is a private artifact being imported to a maven project. The artifact is being stored in a folder named repository. Was using f/w snippet to import the dependency
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/repository</url>
</repository>
</repositories>
The project was last built on December, 2019 using Apache Maven 3.3.9. Now the build is throwing following error:
[ERROR] Failed to execute goal on project target-jar: Could not resolve dependencies for project a.package:target-jar:jar:0.0.1-SNAPSHOT:
Failed to collect dependencies at private.package:private-artifact:jar:1.1.1:
Failed to read artifact descriptor for private.package:private-artifact:jar:1.1.1:
Could not transfer artifact private.package:private-artifact:pom:1.1.1 from/to central-backup (http://repo.maven.apache.org/maven2):
Failed to transfer file: http://repo.maven.apache.org/maven2/private/package/private-artifact/1.1.1/private.package:private-artifact-1.1.1.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]
Tried f/w solution but no luck.
New repo info in pom.xml:
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>local-repo</id>
<url>file://${basedir}/repository</url>
</repository>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Since a few days, my maven build on gitlab (maven:3.6.3-jdk-11) tries to access central.maven.org and fails with
Caused by: org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact javax.media:jai_core:jar:1.1.3 from/to central.maven.org (http://central.maven.org/maven2): Transfer failed for http://central.maven.org/maven2/javax/media/jai_core/1.1.3/jai_core-1.1.3.jar
...
Caused by: java.net.UnknownHostException: central.maven.org: Name or service not known
I haven't changed the settings.xml. It looks like this:
...
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo1.maven.org/maven2/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
...
That is, I haven't configured a lookup for central.maven.org.
Even the maven super pom does not contain this url, according to
https://maven.apache.org/ref/3.6.3/maven-model-builder/super-pom.html
Where does this come from and how can I fix this?
I want to build a java application that runs a sqoop job, does some hdfs operations and alters metadata in hive.
To achie all this, I have created a maven project, but i run into dependency issues all the time.
Can somebody give me a example pom.xml, so I can start to write my application?
Thank you!
HDP Maven Artifacts
pom.xml repositories
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>hortonworks.extrepo</id>
<name>Hortonworks HDP</name>
<url>http://repo.hortonworks.com/content/repositories/releases</url>
</repository>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>hortonworks.other</id>
<name>Hortonworks Other Dependencies</name>
<url>http://repo.hortonworks.com/content/groups/public</url>
</repository>
Add <dependency> section for example, hadoop-common:2.7.3.2.5.0-37 where that is the hadoop version + HDP version
I'm trying to get eclipse to accept a remote repo. Here's my maven settings.xml
<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
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository/>
<interactiveMode/>
<usePluginRegistry/>
<offline/>
<pluginGroups/>
<servers>
<server>
<id>***-releases</id>
<username>MyUsername</username>
<password>secret</password>
</server>
<server>
<id>***-snapshots</id>
<username>MyUsername</username>
<password>secret</password>
</server>
<server>
<id>***-public</id>
<username>MyUsername</username>
<password>secret</password>
</server>
<server>
<id>***-custom-releases</id>
<username>MyUsername</username>
<password>secret</password>
</server>
</servers>
<mirrors>
<mirror>
<id>jboss-public</id>
<name>JBoss Public Nexus Repository</name>
<url>https://repository.jboss.org/nexus/content/groups/public/</url>
<mirrorOf>jboss</mirrorOf>
</mirror>
<mirror>
<id>MyCentral</id>
<url>http://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<proxies/>
<profiles>
<profile>
<id>repository</id>
<repositories>
<repository>
<id>repository</id>
<name>repository</name>
<url>file:/C:/Users/myUsername/.m2/repository/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>***-releases</id>
<url>https://www.***/nexus/content/repositories/***-releases/</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>***-snapshots</id>
<url>https://www.***/nexus/content/repositories/***-snapshots/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>***-public</id>
<url>https://www.***/nexus/content/groups/public/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>***-custom-releases</id>
<url>https://www.***.de/nexus/content/repositories/***-custom-releases/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>fusesource</id>
<url>http://repo.fusesource.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>***-public</id>
<url>https://www.***/nexus/content/groups/public/</url>
</pluginRepository>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>***-releases</id>
<url>https://www.***/nexus/content/repositories/***-releases/</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>repository</activeProfile>
</activeProfiles>
If I run mvn clean install from the terminal or eclipse, the build succeeds. However, if I click "Maven->Update Project" in Eclipse, I get the following error message:
Project build error: Non-resolvable parent POM for ***:***:*** Failure to transfer ***:***:pom:*** from https://www.***/nexus/content/repositories/***-snapshots/ was cached in the local repository, resolution will not be reattempted until the update interval of ***-snapshots has elapsed or updates are forced.
Original error: Could not transfer artifact ***:***:pom:*** from/to ***-snapshots (https://www.***/nexus/content/repositories/***-snapshots/): Received fatal alert: handshake_failure and 'parent.relativePath' points at wrong local POM pom.xml /*** line 4 Maven pom Loading Problem
The "'parent.relativePath' points at wrong local POM" doesn't worry me, since the parent pom is in the remote repository and since there is no connection to it, the error makes sense to me.
In eclipse I've set my maven-installation to ".../myMaven" under "preferences->Maven->Installations". However, in the same menu, eclipse tells me this: "Note: Embedded runtime is always used for dependency resolution". I'm guessing that's the reason why the resolution works when running mvn clean install but doesn't work when I'm trying to update the project with eclipse.
I've also set the Environmentvariable 'MAVEN_OPTS' to this:
-Djavax.net.ssl.trustStore=C:\cacerts\trust.jks -Djavax.net.ssl.trustStorePassword=secret -Djavax.net.ssl.keyStore=C:\cacerts\PC2***.pfx -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=secret
These settings seem fine to me, since I can build from the terminal.
How can I bring eclipse to use the same configs when running "update project"?
I'm a bit new to Maven. I thought I was getting a pretty good handle on it. I guess not.
I want to set up a dependency on SVNKit 1.7.0-alpha1. According to their website, They have a releases repo located at http://maven.tmatesoft.com/content/repositories/releases/
Also, they shared:
GroupId: org.tmatesoft.svnkit
ArtifactIds: svnkit, ...
version: 1.3.7, 1.3.8-SNAPSHOT, 1.7.0-alpha1, 1.7.0-SNAPSHOT
So, I added the following to my pom.xml:
<dependency>
<groupId>org.tmatesoft.svnkit</groupId>
<artifactId>svnkit</artifactId>
<version>1.7.0-alpha1</version>
</dependency>
And
<repositories>
<repository>
<id>tmatesoft-releases</id>
<url>http://maven.tmatesoft.com/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>tmatesoft-snapshots</id>
<url>http://maven.tmatesoft.com/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>tmatesoft-releases</id>
<url>http://maven.tmatesoft.com/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>tmatesoft-snapshots</id>
<url>http://maven.tmatesoft.com/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
...
</distributionManagement>
</repositories>
But when I do a maven build on the project, it doesn't appear to even check the repo I provided.
Any thoughts on where I'm going wrong here?
UPDATE
Found the answer. One of our company's more experienced buildmasters gave me a bit of background on how a nexus server works. I had a sneaking suspicion that the dependencyManagement section was relevant.
To fix this (if you have a Nexus server), you'll have to add the third-party repo to the Nexus Server. Then it should work fine.
Found the answer. One of our company's more experienced buildmasters gave me a bit of background on how a nexus server works. I had a sneaking suspicion that the dependencyManagement section was relevant.
To fix this (if you have a Nexus server), you'll have to add the third-party repo to the Nexus Server. Then it should work fine.