Using multiple repositories in maven cause download failure - maven

I have som trouble when using multiple repositories in maven. Ass additinal information we use artifactory as local repository.
I have the following maven settings
<?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">
<servers>
<server>
<username></username>
<password></password>
<id>central</id>
</server>
<server>
<username></username>
<password></password>
<id>snapshots</id>
</server>
<server>
<username></username>
<password></password>
<id>Dataproces</id>
</server>
<server>
<username></username>
<password></password>
<id>Dataproces-snapshot</id>
</server>
</servers>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>https://server/artifactory/libs-snapshot</url>
</repository>
<repository>
<id>Dataproces</id>
<name>Dataproces-releases</name>
<url>https://server/artifactory/libs-release-local</url>
</repository>
<!-----------PROBLEM------------>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>Dataproces-snapshot</id>
<name>Dataproces-snapshot</name>
<url>https://server/artifactory/libs-snapshot-local</url>
</repository>
<!-----------PROBLEM------------>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>https://server/artifactory/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>https://server02:8439/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>https://server02:8439/artifactory/pluginssnapshot</url>
</pluginRepository>
</pluginRepositories>
<properties>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</properties>
</profile>
</profiles>
<!-- activeProfiles | List of profiles that are active for all builds. | -->
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
If I outcomment the "Dataproces-snapshot" it installs fine, but when I add the repository maven suddenly wont install, because of the missing pom. The error log :
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building MinSagSilkeborg Controller 0.1
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://server02:8439/artifactory/libs-snapshot-local/dk/kmd/doc2mail/webservice/1/webservice-1.pom
[INFO] Downloading: https://server02:8439/artifactory/libs-snapshot-local/dk/kmd/doc2mail/jcommander/1/jcommander-1.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.401 s
[INFO] Finished at: 2016-04-06T11:47:03+02:00
[INFO] Final Memory: 15M/741M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project MinSagSilkeborg-Controller: Could not resolve dependencies for project dk.dataproces.MinSagSilkeborg:MinSagSilkeborg-Controller:jar:0.1: Failed to collect dependencies at dk.kmd.doc2mail:webservice:jar:1: Failed to read artifact descriptor for dk.kmd.doc2mail:webservice:jar:1: Could not transfer artifact dk.kmd.doc2mail:webservice:pom:1 from/to Dataproces-snapshot (https://server/artifactory/libs-snapshot-local): Failed to transfer https://server/artifactory/libs-snapshot-local/dk/kmd/doc2mail/webservice/1/webservice-1.pom. Error code 409, Conflict -> [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
How come maven installs without any problem when the specified repository is outcommented ?
I know the pom file for the artifact is missing.

Related

Unable to get *.tar.gz files from Nexus Repository

I'm tring to install Maven Wrapper and get "Error installing the Maven Wrapper.: Server returned HTTP response code: 401" from my Nexus Repository.
To reproduce the error I can just remove a local cache of Maven Wrapper and try to install it to an empty folder:
rm -R ~/.m2/repository/io/takari/maven-wrapper/0.5.6/
mvn -N io.takari:maven:wrapper -Dmaven=3.8.4
The output:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven:0.7.7:wrapper (default-cli) # standalone-pom ---
Downloading from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.pom
Downloaded from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.pom (2.4 kB at 15 kB/s)
Downloading from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
Downloaded from nexus: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar (51 kB at 1.5 MB/s)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.103 s
[INFO] Finished at: 2022-03-21T10:45:51+05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.takari:maven:0.7.7:wrapper (default-cli) on project standalone-pom: Error installing the Maven Wrapper.: Server returned HTTP response code: 401 for URL: http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.tar.gz -> [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/MojoExecutionException
pom and jar files are downloaded just fine. The problem is with tar.gz file only.
Here is my settings.xml:
<?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">
<servers>
<server>
<id>nexus</id>
<username>admin</username>
<password>1</password>
</server>
</servers>
<mirrors>
<mirror>
<id>nexus</id>
<url>http://localhost:8081/repository/maven-public</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<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>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
The URL http://localhost:8081/repository/maven-public/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.tar.gz?describe is retrived just fine in a browser:
Code 200
Content-Type application/x-gzip
Size 51848
Error 401 is unauthorize error
Did you try to put an autologin config file in your user's home directory already?
Example: /Users/my_username/.netrc
machine nexus.somewhere.com
login correct_user
password correct_password
You also need to ensure the account is available and have valid permission to target lib

Trying to access Oracle's Maven repository

I'm attempting to access Oracle's repository. Oracle doesn't make it easy. However, I'm attempting to follow the documentation that Oracle provided.
I've:
Approved the licensing agreement on my system (in case there's some sort of cookie that needs to be set).
Set both M2_HOME and MAVEN_HOME to /usr/share/apache-maven.
Created an Oracle account.
Added the Oracle Repository to my settings.xml file.
Downloaded wagon-http 2.8 and put it in my $M2_HOME/libs/ext directory.
Generated a master password and put it in $HOME/.m2/settings-security.xml
Generated an encrypted password.
Added the Oracle Maven Repository to my $HOME/.m2/settings.xml file as specified.
Configured HTTP Wagon and added that to my $HOME/.m2/settings.xml file.
My project POM looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.vegicorp</groupId>
<artifactId>testMe</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>testMe</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>process-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>wls-api</artifactId>
<version>12.1.2</version>
</dependency>
</dependencies>
</project>
My settings.xml looks like this:
<?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">
<servers>
<server>
<username>qazwart</username>
<password>swordfish</password>
<id>central</id>
</server>
<server>
<username>qazwart</username>
<password>swordfish</password>
<id>snapshots</id>
</server>
<server>
<id>maven.oracle.com</id>
<username>qazwart#foo.com</username>
<password>{swordfish=}</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<id>maven.oracle.com</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://repo.vegicorp.net/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://repo.vegicorp.net/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://repo.vegicorp.net/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://repo.vegicorp.net/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
When I run Maven, I get this:
$ mvn clean package
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building testMe 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: https://maven.oracle.com/commons-io/commons-io/2.4/commons-io-2.4.pom
Downloading: http://repo.vegicorp.net/artifactory/libs-release/commons-io/commons-io/2.4/commons-io-2.4.pom
Downloaded: http://repo.vegicorp.net/artifactory/libs-release/commons-io/commons-io/2.4/commons-io-2.4.pom (10 KB at 69.4 KB/sec)
Downloading: https://maven.oracle.com/com/oracle/wls-api/12.1.2/wls-api-12.1.2.pom
Downloading: http://repo.vegicorp.net/artifactory/libs-release/com/oracle/wls-api/12.1.2/wls-api-12.1.2.pom
Downloading: http://repo.vegicorp.net/artifactory/libs-snapshot/com/oracle/wls-api/12.1.2/wls-api-12.1.2.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.787 s
[INFO] Finished at: 2015-06-15T16:37:56-04:00
[INFO] Final Memory: 9M/156M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project testMe: Could not resolve dependencies for project com.vegicorp:testMe:jar:1.0-SNAPSHOT: Failed to collect dependencies at com.oracle:wls-api:jar:12.1.2: Failed to read artifact descriptor for com.oracle:wls-api:jar:12.1.2: Could not transfer artifact com.oracle:wls-api:pom:12.1.2 from/to maven.oracle.com (https://maven.oracle.com): Not authorized , ReasonPhrase:Unauthorized. -> [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
It appears that I don't have access to the Oracle repository although I accepted the licensing agreement and am using the account I've created. Is there something I'm missing? If I remove the reference to wls-api.jar in my pom.xml, it works.
From your settings.xml I can see that you use Artifactory. Why won't you define Oracle's repository as a remote in Artifactory? That will make the access much easier. Here's a simple guide on how to do so.
And, of course, here's the official user guide on it.
I am with JFrog, the company behind Bintray and [artifactory], see my profile for details and links.
For anybody that has spent any time fighting with this ... make sure that the ID of the oracle repository in your POM is the same as the ID of the server defined in your Settings.xml.
This is not documented anywhere but it appears that maven just does not request authorization if these IDs do not match. It does not attempt it based upon the URL as other solutions appear to suggest.
I think you missed accepting the Oracle Maven repository terms and conditions. https://www.oracle.com/webapps/maven/register/license.html

Maven ignores a repository

I'm unable to get Maven download an artifact
<dependency>
<groupId>org.jboss.test-jsf</groupId>
<artifactId>jsf-mock</artifactId>
<version>1.1.9</version>
<scope>test</scope>
</dependency>
This dependency isn't in the Maven Central. I've added the proper repository to my settings.
<profiles>
<profile>
<id>barbucha</id>
</profile>
<repositories>
<repository>
<id>jboss</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-plug</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profiles>
Then I build things using the barbucha profile. However maven doesn't use the JBoss repository at all. It tries to get the missing dependency from Central instead. It tries to download the dependency twice and then fails:
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/jboss/test-jsf/jsf-mock/1.1.9/jsf-mock-1.1.9.pom
[WARNING] The POM for org.jboss.test-jsf:jsf-mock:jar:1.1.9 is missing, no dependency information available
[INFO] Downloading: http://repo.maven.apache.org/maven2/org/jboss/test-jsf/jsf-mock/1.1.9/jsf-mock-1.1.9.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project: Could not resolve dependencies for project: Could not find artifact org.jboss.test-jsf:jsf-mock:jar:1.1.9 in central (http://repo.maven.apache.org/maven2) -> [Help 1]
The behavior is very strange and sadly critical to me. I googled a long time, but nothing found, what can cause the problem. The only reason can be the profile if not activated. But that isn't my case.
Oh, it was so simple - my settings are just malformed:
<profiles>
<profile>
<id>barbucha</id>
</profile> <<< this must be at the end (at <!-- #1 --->)
<repositories>
... <!-- this part must be inside of profile -->
</pluginRepositories>
<!-- #1 --->
</profiles>
I apologize. (Hopefully it may help to someone.)

How to setup new local artifactory for maven?

I've read many questions and articles on this and tons of other sites, I still can't get this working.
I have maven configured to perform my builds, and now want to put the artifacts into a repository. I installed artifactory in tomcat, it appears to be working.
If I execute a "mvn clean install", the messages indicate that the artifacts are being uploaded to the local maven repository instead of artifactory:
[INFO] --- maven-install-plugin:2.3.1:install (default-install) # my-app ---
[INFO] Installing C:\maven_projects\my-app\my-app\target\my-app-1.0-SNAPSHOT.jar to C:\Users\Administrator\.m2\repository\com\mycompany\app\my-app\1.0
-SNAPSHOT\my-app-1.0-SNAPSHOT.jar
[INFO] Installing C:\maven_projects\my-app\my-app\pom.xml to C:\Users\Administrator\.m2\repository\com\mycompany\app\my-app\1.0-SNAPSHOT\my-app-1.0-SNAPSHOT.pom
If I execute a "mvn deploy:deploy-file, specifying the repository, the messages indicate the artifacts are being uploaded into artifactory, but they are not there:
mvn deploy:deploy-file -DrepositoryId=libs-release-local -Durl=http://localhost:8080/artifactory/libs-release-local -D
groupId=com.mycompany.app -DartifactId=my-app -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=target/my-app-1.0-SNAPSHOT.jar
[...]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building my-app 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) # my-app ---
Downloading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/maven-metadata.xml
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.jar
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.pom
The POM.XML file is:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>central</id>
<url>http://localhost:8080/artifactory/libs-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/libs-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://localhost:8080/artifactory/plugins-release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://localhost:8080/artifactory/plugins-snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>sademo</id>
<name>sademo-releases</name>
<url>http://localhost:8080/artifactory/ext-release-local</url>
</repository>
<snapshotRepository>
<id>sademo</id>
<name>sademo-snapshots</name>
<url>http://localhost:8080/artifactory/ext-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
</project>
The settings.xml file is:
<?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">
<servers>
<server>
<username>admin</username>
<password>password</password>
<id>sademo</id>
</server>
<server>
<username>admin</username>
<password>password</password>
<id>sademo-releases</id>
</server>
</servers>
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>remote-repos</name>
<url>http://localhost:8080/artifactory/remote-repos</url>
<id>remote-repos</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>sademo</id>
<name>libs-release</name>
<url>http://localhost:8080/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>sademo-snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8080/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://localhost:8080/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://localhost:8080/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Any ideas on how I can get the "mvn clean install" to upload the jar into artifcatory?
In maven
mvn install
is intended to install the artifacts into the local repository and NOT into the remote repository.
To upload the artifacts to the remote repository you need to say:
mvn deploy
The mvn deploy will use the entries from distributionManagement to upload the artifacts to the given repository.
In your examples the pom should not contain any configurations for repositories, cause you have already done it in the settings.xml file.
Apart from that it looks that your configuration is not 100% correct, cause the message:
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.jar
Uploading: http://localhost:8080/artifactory/libs-release-local/com/mycompany/app/my-app/1.0-SNAPSHOT/my-app-1.0-20130202.014428-1.pom
shows the location where the artifacts have been put into. In this case libs-release-local but the artifacts are SNAPSHOT's and not releases.
I would say to change the following:
<repository>
<snapshots />
<id>sademo-snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8080/artifactory/libs-snapshot</url>
</repository>
into:
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>sademo-snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8080/artifactory/libs-snapshot</url>
</repository>

Dependency resolution configuration in Artifactory

Recently we started to work with Artifactory. We configured settings.xml as Artifactory proposed. However we have problems downloading jars while running "mvn compile", even if they appear in Artifactory repo. Adding explicitly repo1-cache solves the compilation problem but download is performed from remote repository rather than from Artifactory.
<repository>
<id>My Repository</id>
<name>MyRepository-releases</name>
<url>http://mvn-srv:8081/artifactory/repo1</url>
</repository>
What should be added to settings.xml in for resolving automatically dependencies and fetching them from artifactory rather than accessing remote servers each time?
settings.xml:
<?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>libs-release</name>
<url>http://mvn-srv:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://mvn-srv:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://mvn-srv:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://mvn-srv:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<servers>
<server>
<id>MyRepository</id>
</server>
</servers>
Compilation error:
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.355s
[INFO] Finished at: Wed Nov 14 14:52:31 IST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project common: Could not resolve dependencies for project com.myc
ompany.app:common:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: commons-jxpath:co
mmons-jxpath:jar:1.3-osgi, xpp3:xpp3_min:jar:1.1.3.4.O-osgi, net.java.dev.stax-utils:stax-utils:jar:
20080702-osgi, net.sf.saxon:saxon:jar:8.9.0.4-osgi, net.sf.saxon:saxon-dom:jar:8.9.0.4-osgi, net.sf.
saxon:saxon-xqj:jar:8.9.0.4, dom4j:dom4j:jar:1.6.1-osgi, mx4j:mx4j-jmx:jar:2.1.1-osgi, mx4j:mx4j-imp
l:jar:2.1.1-osgi, mx4j:mx4j-tools:jar:2.1.1-osgi, mx4j:mx4j-remote:jar:2.1.1-osgi, com.yourkit:yjp-c
ontroller-api-redist:jar:9.0.8, org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1-osgi, common
s-codec:commons-codec:jar:1.3-osgi, commons-httpclient:commons-httpclient:jar:3.1-osgi, quartz:quart
z-all:jar:1.6.6: Could not find artifact commons-jxpath:commons-jxpath:jar:1.3-osgi in central (http
://mvn-srv:8081/artifactory/libs-release) -> [Help 1]
Adding to #duncan-jones excellent answer, great way to troubleshoot resolution is performing Trace Artifact Retrieval call, in your case:
http://mvn-srv:8081/artifactory/libs-release/commons-jxpath/commons-jxpath/1.3-osgi/commons-jxpath-1.3-osgi.jar?trace
BTW, I don't even see the 1.3-osgi version in repo1.
You need to ensure your virtual repositories map to the real repositories you expect.
For example, libs-release will typically map to both internal and external release repositories. Perhaps this is mis-configured, resulting in it not hitting the repositories you want.
In Artifactory, go to the Admin page and look at Configuration > Repositories. At the bottom of the page, take a look at your virtual repositories. Double-clicking on them will show you what is included.
For me, libs-release includes libs-release-local, ext-release-local and remote-repos. The latter is another virtual repository that maps to all the external repositories listed in my installation, e.g. codehaus, repo1, jboss, google-code, ...
Perhaps one of these virtual repositories is missing repo1?

Resources