How to set up a new local artificial stone for maven?

I read a lot of questions and articles about this and many other sites, I still can not get it to work.

I have maven configured to run my builds and now I want to put artifacts in the repository. I installed artifactory in tomcat, it works.

If I run "mvn clean install", the messages indicate that artifacts are being downloaded 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 run "mvn deploy: deploy-file", specifying a repository, messages indicate that artifacts are loaded 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 

POM.XML file:

 <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> 

Settings.xml file:

 <?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 "mvn clean install" to load the jar into artifcatory?

+4
source share
1 answer

In maven

 mvn install 

Designed to install artifacts to the local repository and NOT to the remote repository. To upload artifacts to a remote repository, you need to say:

 mvn deploy 

Mvn deployment will use records from distributionManagement to load artifacts into this repository.

In your examples, pom should not contain configurations for repositories, because you have already done this in the settings.xml file.

Also, it looks like your configuration is not 100% correct, the message is called:

 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 place where artifacts were placed. In this case, libs-release is local, but artifacts are SNAPSHOT and are not released.

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> 

in

 <repository> <snapshots> <enabled>true</enabled> </snapshots> <id>sademo-snapshots</id> <name>libs-snapshot</name> <url>http://localhost:8080/artifactory/libs-snapshot</url> </repository> 
+9
source

All Articles