I have maven project X and when I add the maven dependency below:
<dependency>
<groupId>com.paypal.sdk</groupId>
<artifactId>paypal-base</artifactId>
<version>1.1.0</version>
</dependency>
the maven project fails to build. It shows the error below:
Could not resolve dependencies for project X : Could not find artifact com.paypal.sdk:paypal-base:jar:1.1.0 in central (https://company.jfrog.io/organization/libs-release) -> [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 checked in the following link and the jar was present. So the jar isn't missing from the dependency.
Also I have tried to run:
mvn -U clean install
And didn't resolve the issue.
Below is the configuration of the settings.xml file in the hidden folder.m2:
<?xml version="1.0"?>
<settings>
<servers>
<server>
<username>XUSER</username>
<password>XPASSWORD</password>
<id>central</id>
</server>
<server>
<username>XUSER</username>
<password>XPASSWORD</password>
<id>snapshots</id>
</server>
</servers>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>artifactory</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://company.jfrog.io/organization/libs-release</url>
</repository>
<repository>
<snapshots/>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://company.jfrog.io/organization/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://company.jfrog.io/organization/libs-release</url>
</pluginRepository>
<pluginRepository>
<snapshots/>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://company.jfrog.io/organization/libs-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
I will appreciate any help in fixing this issue.
Kind Regards,
Rando.
P.S
I did a little experiment. Downloaded the content from link and place them on the .m2/repository/com/paypal/sdk/1.1.0 folder and the build was successful. I don't know why isn't imported automatically.
This is a quick fix to bypass the problem.
<project>
...
</dependencies>
<repositories>
<repository>
<id>mWSO2 Dist</id>
<name>WSO2 Dist</name>
<url>http://dist.wso2.org/maven2/</url>
</repository>
</repositories>
</project>
I check in the maven corporate repository and the PayPal SDK dependency was not present. After adding the PayPal SDK manually in the jfrog artifactory I removed the WSO2 Dist repository from the project pom.xml file.
This solution is better because my project is not dependent on external repository.
Related
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.
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
I'm trying to use nexus to proxy central repository which is quite slow.
So. I've configured maven according tutorial.
<settings>
<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>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
Everything is working fine and fast. But I faced with problem when I've tried to use custom repository specified in pom.xml (this repo is needed only for concrete project)
So. I'm talking about:
<pluginRepositories>
<pluginRepository>
<id>dtrott</id>
<url>http://maven.davidtrott.com/repository</url>
</pluginRepository>
</pluginRepositories>
from: https://github.com/dtrott/maven-protoc-plugin#readme
error message:
Error resolving version for plugin 'com.google.protobuf.tools:maven-protoc-plugin' from the repositories [local (C:\Users\valden\.m2\repository), nexus (http://localhost:8081/nexus/content/groups/public)]: Plugin not found in any plugin repository -> [Help 1]
In maven settings.xml I've changed next line:
<mirrorOf>*</mirrorOf>
to
<mirrorOf>central</mirrorOf>
and it is working now...
One option is to add the custom repository to your Nexus as a proxied repository (type proxy). Then you don't have to put anything extra in your pom.
So I have a project and I do regular releases to maven without a problem. I now want to make available a SNAPSHOT version of this project. So I do 'mvn clean deploy'. Everything works as you can see below:
[INFO] Retrieving previous build number from sonatype-nexus-snapshots
Uploading: https://oss.sonatype.org/content/repositories/snapshots/me/soliveirajr/menta-regex/0.9.6-SNAPSHOT/menta-regex-0.9.6-20111010.153035-2.jar
5K uploaded (menta-regex-0.9.6-20111010.153035-2.jar)
I go to my sonatype manager and I can find the snapshot:
But now when I try to use this snapshot as a dependency on some other project in another machine I get:
<dependency>
<groupId>me.soliveirajr</groupId>
<artifactId>menta-regex</artifactId>
<version>0.9.6-SNAPSHOT</version>
</dependency>
Missing:
1) me.soliveirajr:menta-regex:jar:0.9.6-SNAPSHOT
Try downloading the file manually from the project website.
Then, install it using the command:
mvn install:install-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file
Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=me.soliveirajr -DartifactId=menta-regex -Dversion=0.9.6-SNAPSHOT -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
So how do I force maven to download the SNAPSHOT version to my local (.m2) repository?
Just add this to your ~/.m2/settings.xml:
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
</profiles>
For the sake of completeness, I would like to add that it is also possible by modifying the pom.xml of a project, simply add
<repositories>
<repository>
<id>oss.sonatype.org-snapshot</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
to your list of repositories.
In my opinion, this is a better solution than modifying ~/.m2/settings.xml. The pom.xml file will also be available for other project participants through Git and allow them to download the snapshots as well.
Source: this answer
You can enable snapshots in repository config (~/.m2/settings.xml):
<settings>
<profiles>
<profile>
<repositories>
<repository>
<snapshots> <<<<<<<<<<<
<enabled>true</enabled> << ADD THIS
</snapshots> <<<<<<<<<<<
. . .
</settings>
See maven.apache.org/settings.html#Repositories for more properties.