I have following .m2/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">
<profiles>
<profile>
<repositories>
<repository>
<id>jboss-ga-repository</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-ga-plugin-repository</id>
<url>http://maven.repository.redhat.com/techpreview/all</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
When I try run mvn install against my project it says:
[INFO] Unable to find resource 'org.jboss.bom.eap:jboss-javaee-6.0-with-tools:pom:6.4.0.GA' in repository central (https://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: org.jboss.bom.eap:jboss-javaee-6.0-with-tools
Reason: POM 'org.jboss.bom.eap:jboss-javaee-6.0-with-tools' not found in repository: Unable to download the artifact from any repository
org.jboss.bom.eap:jboss-javaee-6.0-with-tools:pom:6.4.0.GA
from the specified remote repositories:
central (https://repo1.maven.org/maven2)
for project org.jboss.bom.eap:jboss-javaee-6.0-with-tools
But it tried only central (https://repo1.maven.org/maven2). Why did it ignore repositories specified in settings.xml?
Profiles need to be activated in your Maven build. There are several ways to activate them (see http://maven.apache.org/guides/introduction/introduction-to-profiles.html). For example, you can activate it at the command line using:
mvn ... -Pprofile-1
But obviously you'll need to declare the profile ID in the <profile> node that you showed.
Related
Below is the Main POM file of my project
<repositories>
<repository>
<id>wf-dependencies</id>
<name>WorkFusion Nexus Repository - dependencies</name>
<url>https://repository.workfusion.com/content/groups/dependencies/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>wf-dependencies</id>
<url>https://repository.workfusion.com/content/repositories/wf-dependencies</url>
</pluginRepository>
</pluginRepositories>
When I do clean install on my local machine I get build success. But when This code goes through jenkins pipeline it gives us below error
Failed to execute goal on project pfs-eagle-bcb: Could not resolve dependencies for project
com.hpe.automation:pfs-eagle-bcb:jar:1.0.0: The following artifacts could not be resolved:
com.workfusion.automation.rpa:rpa-custom-elements:jar:1.4, com.workfusion.idp:idp-
commons:jar:2.0.6: Could not find artifact com.workfusion.automation.rpa:rpa-custom-
elements:jar:1.4 in wf-dependencies
(https://repository.workfusion.com/content/repositories/wf-dependencies/) -> [Help 1]
above two dependencies exist in content/groups but not in content/repositories. So I have configured both the repositories in my main pom.xml file still some how through jenkins it only checks in maven central repository and this repository- https://repository.workfusion.com/content/repositories/wf-dependencies/ not in content/groups
Also I have checked settings.xml file for jenkins, Only content/repositories - this dependency url is used and not content/groups
I´m trying to configure my maven to use a Nexus repository. What I´m trying to achieve should be very common: I want to have a Nexus repository working as a proxy for central dependencies and also two repositories for snapshots and releases. There´s plenty of documentation out there, but I am not able to get it running.
I edited my settings.xml so that it looks as follows:
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0
http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository>${M2_REPO}</localRepository>
<servers>
<server>
<id>nexus</id>
<username>myuser</username>
<password>mypass</password>
<url>https://snapshoturl</url>
</server>
<server>
<id>nexus-releases</id>
<username>myuser</username>
<password>mypass</password>
<url>https://releaseurl</url>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<url>https://groupurl</url>
<username>myuser</username>
<password>mypass</password>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>myprofile</id>
<repositories>
<repository>
<id>nexus</id>
<url>https://snapshoturl</url>
<username>myuser</username>
<password>mypass</password>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<!--<repository>
<id>nexus-releases</id>
<url>https://releaseurl</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>-->
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://groupurl</url>
<username>myuser</username>
<password>mypass</password>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>myprofile</activeProfile>
</activeProfiles>
</settings>
But I always get the following error message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-
plugin:2.7:deploy (default-deploy) on project share.logging: Failed to
retrieve remote metadata xxx:share.logging:1.0.0-SNAPSHOT/maven-
metadata.xml: Could not transfer metadata
xxx:share.logging:1.0.0-
SNAPSHOT/maven-metadata.xml from/to p19dai-internal (https://snapshoturl):
Not authorized , ReasonPhrase:Authorization Required. -> [Help 1]
Can anyone help me here? What am I missing?
The problem is in your pom file. The ID in the "distributionManagement" section needs to match an ID in the settings.xml file's "servers". That's how the deployment credentials are looked up by Maven.
Are you running the mvn build via eclipse or eclipse based IDE?
then go to Go to Window --> Preferences
look for maven in the list and then user settings give the path to your settings.xml in both the global settings and the user settings and click apply
also set your .m2 repo path
I have a moderate sized project with many modules depending on each other. When I run mvn compile or mvn package it works, but when I try to run mvn dependency:tree from the root directory it fails complaining that it cannot get an artifact from artifactory. Its true that the artifact does not exist in artifactory. It is one of the modules that I have written and that is a dependency of another module in my project. Why is mvn dependency:tree searching for this module in the artifactory when it should recognize that this is a first-party module? mvn package does not complain. Please advise. The maven error is like this
[ERROR] Failed to execute goal on project XXX: Could not resolve dependencies for project XXX: Could not transfer artifact YYY from/to repo (ZZZ): Failed to transfer file: YYY. Return code is: 503 , ReasonPhrase:Error. -> [Help 1]
This is my settings.xml in case its needed:
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<mirrors>
<mirror>
<mirrorOf>external:*</mirrorOf>
<name>repo</name>
<url>http://XXX/artifactory/repo/</url>
<id>repo</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Artifactory Central</name>
<url>http://XXX/artifactory/libs-release/</url>
</repository>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<id>snapshots</id>
<name>Artifactory Snapshots</name>
<url>http://XXX/artifactory/libs-snapshot/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Artifactory Plugins Central</name>
<url>http://XXX/artifactory/plugins-release/</url>
</pluginRepository>
<pluginRepository>
<releases>
<enabled>false</enabled>
</releases>
<id>snapshots</id>
<name>Artifactory Plugins Snapshots</name>
<url>http://XXX/artifactory/plugins-snapshot/</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
This is same issue as Maven doesn't recognize sibling modules when running mvn dependency:tree and the answer is to run:
mvn compile dependency:tree
(source: https://stackoverflow.com/a/1905927/147530)
'mvn package' skips 'validate' phase of Maven cycle.
This way you succeed with 'mvn package' and you never knew about any 'validate' issue.
I'm considering using using bintray to host some project dependencies in a maven repository. My problem is I'm using Ivy and I can't seem to figure out how to take this maven configuration (supplied by bintray):
<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://dl.bintray.com/content/example/external-deps</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://dl.bintray.com/content/example/external-deps</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>
and turn it into something that Ivy can use. Can anyone help me with this?
You can just add the repository like this:
<ivysettings>
<resolvers>
<ibiblio name="bintray"
m2compatible="true"
root="http://dl.bintray.com/content/example/external-deps"/>
</resolvers>
</ivysettings>
My pom file for the project has the following distribution management tag
<distributionManagement>
<repository>
<id>confiz-repo</id>
<url>http://10.10.10.230:8081/nexus/content/repositories/snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</distributionManagement>
i use mvn deploy and that gives me a success. So i know my artifact has been deployed successfully. Now my settings.xml file is as follows
<?xml version="1.0" encoding="UTF-8"?>
<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">
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>confiz-repo</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<mirrors>
<mirror>
<!-- The id of this mirror and the server instance above needs to be the same!-->
<id>confiz-repo</id>
<mirrorOf>*</mirrorOf>
<url> http://10.10.10.230:8081/nexus/content/groups/public/</url>
</mirror>
<mirror>
<!-- The id of this mirror and the server instance above needs to be the same!-->
<id>confiz-repo</id>
<mirrorOf>*</mirrorOf>
<url> http://10.10.10.230:8081/nexus/content/repositories/snapshots/</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>confiz-repo</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>confiz-repo</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Now when i include the dependency for the first project into my second project and run mvn clean install maven complains
[ERROR] Failed to execute goal on project merchant: Could not resolve dependencies for project com.onestopspot:merchant:apk:1.0.1-SNAPSHOT: Could not find artifact com.confiz.abc:my-artifact:jar:1.0-SNAPSHOT in confiz-repo (http://10.10.10.230:8081/nexus/content/groups/public/) -> [Help 1]
what am i doing wrong ?
EDIT - I can see my artifact deployed in nexus. So i am right in saying that the mvn deploy works correctly. But the path http://10.10.10.230:8081/nexus/content/groups/public/ from which nexus is trying to read does not contain my artifact.
Your second project is trying to grab artifact of first project from nexus which isn't exist there
You might want to deploy snapshot on nexus
If you don't want to do 1. run mvn clean install -o on second project in offline mode