How to setup new local artifactory for maven? - 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>

Related

RED lines in Maven POM [duplicate]

The development machine cannot access the internet, and take about 60s to timeout. When I try to build, I see
Downloading: http://repo.maven.apache.org/maven2/com/google/gsa-connector/2.8.0/gsa-connector-2.8.0.pom
However, I have the following in my POM:
<repository>
<id>bb-nexus</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>nexus-3rdparty</id>
<url>http://repo.dev.bloomberg.com/content/repositories/thirdparty/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
It always tries to go to repo.maven first. I even tried to add to D:\.m2\settings.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
</mirror>
</mirrors>
based on http://maven.apache.org/guides/mini/guide-mirror-settings.html yet it continues to try repo.maven first. I'm using Apache Maven 3.0.4 (r1232337; 2012-01-17 03:44:56-0500)
I can't use -o because it still needs to access the local repo.dev.
Here is with 'effective-settings':
D:\Users\chloe\Projects\team\confluence-plugin>mvn help:effective-settings
[INFO] Scanning for projects...
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-install-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins:maven-install-plugin/maven-metadata.xml from/to central (
http://repo.maven.apache.org/maven2): Connection to http://repo.maven.apache.org refused
...
[INFO]
[INFO] --- maven-help-plugin:2.1.1:effective-settings (default-cli) # bb-confluence-plugin ---
[INFO]
Effective user-specific configuration settings:
<?xml version="1.0" encoding="UTF-8"?>
...
<settings xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLoca
tion="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<localRepository xmlns="http://maven.apache.org/SETTINGS/1.1.0">d:\.m2\repository</localRepository>
<pluginGroups xmlns="http://maven.apache.org/SETTINGS/1.1.0">
<pluginGroup>org.apache.maven.plugins</pluginGroup>
<pluginGroup>org.codehaus.mojo</pluginGroup>
</pluginGroups>
</settings>
[INFO] ------------------------------------------------------------------------
All pom files inherit from the maven super POM
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
which contains this entry:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
Try setting this in your pom (with <id>central</id>):
<repositories>
<repository>
<id>central</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
Overriding the central repository
How it works:
Most organizations will need to set up one or more shared repositories, since not everyone can deploy, or simply download from the central Maven repository.To publish releases for use across different environments within their network, organization's will typically want to set up what is referred to as an internal repository.
When using this repositories for your projects, there are two choices: use it as a mirror, or have it override the central repository. You would use it as a mirror if it is intended to be a copy of the central repository exclusively, and if it's acceptable to have developers configure this in their settings. Or like in this case that you want to prevent access to the central repository for greater control, to configure the repository from the project level instead of in each user's settings, or to include your own artifacts in the same repository, you should override the central repository.
Also, Is very important to have in mind, at this point, the resolution process conducted by the maven dependencies, which have two main blocks settings for repositories:
related to the decencies will be listed within us ;
related to plugins that will be added within the nodes or used during the life cycle.
The Solution:
As an object oriented framework Maven has all POMs have an implicit parent the Super POM. Under its definitions lay down both dependencies and plugins first resolver repositories configurations:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
To override the central repository with your internal repository, you must define a repository in a settings file and/or POM that uses the identifier central (<id>central</id>). Usually, this must be defined as both a regular repository and a plugin repository to ensure all access is consistent. For example:
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo.dev.bloomberg.com/content/groups/public</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
Related link: Coderwall - Stopping maven from trying to access its Central Repository
Try setting the following in the reporting/plugins block
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.9</version>
<configuration>
<dependencyLocationsEnabled>false</dependencyLocationsEnabled>
</configuration>
</plugin>

Nexus group by SNAPSHOT

I have Nexus with builds repository. How I can group my versions on folders named snapshot-x.x ?
Repository have snapshot type. User deployment have all privileges.
I run maven as mvn versions:set -DnewVersion=$VERSION and mvn clean deploy -B -Pbuild -Dbuild.version=$VERSION
My settings.xml work only releases repo ;-(
<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>
</server>
</servers>
<profiles>
<profile>
<id>build</id>
<repositories>
<repository>
<id>nexus-repo</id>
<name>Nexus repo</name>
<url>http://<MY-HOST>:8081:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-repo</id>
<name>Nexus repo </name>
<url>http://<MY-HOST>:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<altDeploymentRepository>
-DaltDeploymentRepository=builds::default::http://deployment:<MY_PASS>#<MY-HOST>:8081/content/repositories/builds
</altDeploymentRepository>
</properties>
</profile>
</profiles>
</settings>
<activeProfiles>
<activeProfile>build</activeProfile>
</activeProfiles>
I'm not sure what you are asking for? A repository has a fixed format which comprises of groupId:artifactId:version ?
There you see com/soebes/examples/j2ee is the groupId: com.soebes.examples.j2eee and than artifactId: app plus the version 1.1.2-SNAPSHOT with the underlying versions for a single SNAPSHOT

Jenkins Maven job unable to access plugins for deployment from repositories

I am new to Jenkins. As part of POC i tried to deploy a basic SOA project from command line "mvn pre-integration-test", it was successfully deployed to localhost weblogic server. However, when tried Jenkin's job polling svn code, its failing repeatedly with following error msg:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\testAppSairu
Updating protocol://xxx/svn/testAppSairu/branches/testAppSairu at revision '2015-10-19T18:08:19.290 +0530'
At revision 2
no change for protocol://xxx/svn/testAppSairu/branches/testAppSairu since the previous build
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Parsing POMs
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer com.oracle.soa:sar-common:pom:12.1.3-0-0 from protocol://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact com.oracle.soa:sar-common:pom:12.1.3-0-0 from/to central (protocol://repo.maven.apache.org/maven2): Connection to protocol://repo.maven.apache.org refused and 'parent.relativePath' points at no local POM # line 21, column 13
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
Note: I used maven sync plugin to install and push weblogic home into local repository and also Archiva managed repository. While running mvn compile/pre-integration-test i am able to deploy it successfully but failing here since its unable to access plugins.
.m2 settings.xml file:
<?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">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
<profiles>
<profile>
<id>default</id>
</pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
<pluginRepository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<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>
<id>dev-group</id>
<name>Dev Group</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev-group</url>
<layout>default</layout>
</repository>
<repository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</repository>
<repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/snapshots</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
<mirrors>
<mirror>
<id>dev-mirror</id>
<name>All Else</name>
<url>http://localhost:8088/repository/dev-group</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>maven.oracle.com</id>
<username>OTN username</username>
<password>OTN password</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>
<server>
<id>dev</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>dev-group</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<activeProfiles>
<activeProfile>defualt</activeProfile>
</activeProfiles>
</settings>
As suggested in docs.oracle.com/middleware/1213/core/MAVEN.pdf, i have downloaded wagon-http-2.8-shaded.jar and placed underapache-maven-3.3.3\lib\ext folder. Updated repository, server details etc in settings.xml. But still issue is not resolved.
My intention is to deploy a simgle SOA 12c project using Jenkin's maven job part of Continuous Integration flow. Please suggest if i am missing anything here. I am rookie on this so any help will save my day. Thanks!

How to disable usage of public maven repo

I've setup a maven repository(Artifactory) in my LAN which has no internet access. I've also change my maven settings.xml to use this internal repo only. However when I try to create a maven project, it still try to access the public repo(http://repo1.maven.org/maven2) for some downloads. Where has I done wrong?
For example, when I perform the following:
mvn archetype:generate -DgroupId=demo.john -DartifactId=struts2demo
-DarchetypeGroupId=org.apache.struts
-DarchetypeArtifactId=struts2-archetype-starter
-DinteractiveMode=false
there is the following waring reported:
... ...
[INFO] Generating project in Batch mode
[WARNING] Error reading archetype catalog http://repo1.maven.org/maven2
org.apache.maven.wagon.TransferFailedException: repo1.mavne.org
at org.apache.maven.wagon.shared. ...
... ...
Sometimes the it build successfully with this waring, but sometime it won't.
Below is my maven's settings.xml
<?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>
<id>central</id>
<username>admin</username>
<password>password</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<mirrors>
<mirror>
<id>my-company-repo</id>
<name>A maven repo in local network</name>
<url>http://my.internal.server/artifactory/repo<url>
</mirror>
<mirrorOf>*</mirrorOf>
</mirrors>
<profiles>
<profile>
<id>artifactory</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://my.internal.server/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://my.internal.server/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://my.internal.server/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://my.internal.server/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>

Maven deploy error

I have maven project with several modules. Need to deploy all modules(jars and one resulting war) into remote Artifactory server.
So in settings.xml I am added config:
<?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>central</id>
</server>
<server>
<username>admin</username>
<password>password</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<id>central</id>
<name>libs-release</name>
<url>http://192.168.1.120:8088/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://192.168.1.120:8088/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://192.168.1.120:8088/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Main pom have section:
<distributionManagement>
<repository>
<id>central</id>
<url>http://192.168.1.120:8088/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://192.168.1.120:8088/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
And all modules have 1.0-SNAPSHOT version.
But when executing the command: >mvn deploy, the Following error occured:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy
(default-deploy) on project jobic: Failed to deploy artifacts: Could
not transfer artifact *project-name:project-nam*e:pom:0.0.1 from/to central
(http://192.168.1.120:8088/artifactory/libs-release-local): Failed to
transfer file:
http://192.168.1.120:8088/artifactory/libs-release-local/project-name/project-name/0.0.1/project-name-0.0.1.pom.
Return code is: 401 -> [Help 1]
How to deal with it?
UPDATE:
Ok, I got it. The 401 error says: 401 = "Unauthorized" . So I added proper username/password into settings.xml. Seems work now.
Have one last question: it is right, that I am using SNAPSHOT suffix in the version? Is it proper behavior for situation, when I need do deploy all modules onto remote repo? How to deal with situation, when the one module was broken and my coworkers need to use previous version of this module?
It might be because it is written incorrectly.
You can change it hhttp to http and try again.

Resources