artifactory local repo in maven project - maven

I've setted artifactory in localhost (I'm trying on localhost before setting up my server), but when I use this repo in my maven project I can't retrieve my libs. Any suggestions?

Artifactory provides you with a small utility that generates a Maven settings file based on the repositories configured in Artifactory and your selections; assuming your repositories are properly configured, this utility normally does a good job.

Try (change id ClaudioStas to central):
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://localhost:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://localhost:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://localhost:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://localhost:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>

Related

Could not download maven-fail-safe-plugin. Giving me an error message

I have created a new maven project with serenity framework. I am getting this error in my new maven project
Plugin org.apache.maven.plugins:maven-failsafe-plugin:2.22.1 or one of
its dependencies could not be resolved: Failed to read artifact
descriptor for
org.apache.maven.plugins:maven-failsafe-plugin:jar:2.22.1: Could not
transfer artifact
org.apache.maven.plugins:maven-failsafe-plugin:pom:2.22.1 from/to
central (http://jcenter.bintray.com): Authorization failed for
http://jcenter.bintray.com/org/apache/maven/plugins/maven-failsafe-plugin/2.22.1/maven-failsafe-plugin-2.22.1.pom
403 Forbidden
You need change http to https
http://jcenter.bintray.com to https://jcenter.bintray.com
I found this way, just delete these line below in pom.xml and it's worked:
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>http://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
In my case, I had mistakenly removed jcenter configurations from the ~/.m2/settings.xml while my organization specific repositores. After adding it started working.
<?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>
...
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>bintray-plugins</name>
<url>https://jcenter.bintray.com</url>
</pluginRepository>
</pluginRepositories>
<id>bintray</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>bintray</activeProfile>
</activeProfiles>
</settings>

Jenkins maven release goes to lib-snapshot repository

I am having setup where Jenkins is used to release maven project to artifactory. I see everything is working fine what maven release do like incrementing pom versions, creating tag but it is not uploading to lib-release repo instead it is uploading it to lib-snapshot repo.
I verified my settings.xml and saw it uses different ids for snapshot and release repo. What else can I check to fix this issue?
This is my settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<!--<settings.version>1.0.1</settings.version>-->
<!--<settings.region>IL</settings.region>-->
<!--<settings.type>server</settings.type>-->
<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>
<id>artifactory_server</id>
<username>deploy_user</username>
<password>xxxxxxxxxxxxxxxxxxx</password>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots />
<releases>
<enabled>false</enabled>
</releases>
<id>artifactory-snapshots</id>
<name>libs-snapshot</name>
<url>http://artifactory.example.com/artifactory/libs-snapshot</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>artifactory-release</id>
<name>libs-release</name>
<url>http://artifactory.example.com/artifactory/libs-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>central</id>
<name>plugins-release</name>
<url>http://artifactory.example.com/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://artifactory.example.com/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
It's completely up to Maven and POM definitions.
By default every Jenkins run are threaten as Snapshots but you can control them by
Repositories with
<snapshots>
<enabled>false</enabled>
</snapshots>
And using maven-release-plugin https://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html

Project won't build when settings.xml exists

Following on from Unable to build maven project, pom.xml file not found, I'm finding that if settings.xml exists, the project fails to build. However I need settings.xml to tell maven how to find the Oracle ojdbc6.jar file.
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">
<servers>
<server>
<id>build_server</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://build_server:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://build_server:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://build_server:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://build_server:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
The pom.xml is quite large (649 lines) but if the above settings.xml does not exist, the project builds but then fails the unit tests as it can't connect to the Oracle DB. If the above settings.xml file does exist, the it can;t find artifacts in Artifactory that it does find if settings.xml doesn't exist.
The reposiories and distribution management section are:
<repositories>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://build_server:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://build_server:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://build_server:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://build_server:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
<pluginRepository>
<id>maven.oracle.com</id>
<name>oracle-maven-repo</name>
<url>https://maven.oracle.com</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<distributionManagement>
<repository>
<id>build_server</id>
<name>build_server-releases</name>
<url>http://build_server:8081/artifactory/libs-release-local</url>
</repository>
<snapshotRepository>
<id>build_server</id>
<name>build_server-snapshots</name>
<url>http://build_server:8081/artifactory/libs-snapshot-local</url>
</snapshotRepository>
</distributionManagement>
I'm thoroughly confused and am hoping for some guidance.
build_server (not its real name) runs artifactory on port 8081 and teamcity on 8111.
Thanks
OK, so the problem turned out to be the ID's. I changed the ID's in the pom.xml in the distributionManagement section to match the ID's in the pluginRepositories section and now it works.
I hope this helps someone else.

Where to get gwt-maven-plugin 2.8.0-SNAPSHOT

The gwt-maven-plugin documentation lists 2.8.0-SNAPSHOT as current version, and I'd like to evaluate the upcoming 2.8.0 GWT.
While version 2.7.0 is available directly from the Maven Central repository, I am unable to find the correct repository from which to retrieve the snapshot. Unfortunately I have been unable to find this information on the project's homepage.
Can anybody please provide me with a working <repository/> and <pluginRepository/> configuration to use in my pom.xml?
This worked for me:
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/google-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>snapshots-repo</id>
<!--<url>https://oss.sonatype.org/content/repositories/google-snapshots</url>-->
<url>https://oss.sonatype.org/content/repositories/public/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

Repositories specified in pom.xml are not used by maven?

I am compiling HBase using Maven3.
The pom from github https://github.com/cloudera/hbase/blob/cdh4-0.94.2_4.2.1/pom.xml specified some repositories to provide some external jars. But maven 3 doesn't look for jars from these repositories and just throws exception says the jar is not found from mirror.
Here is the repositories from pom.
<repositories>
<repository>
<id>cdh.repo</id>
<url>https://repository.cloudera.com/artifactory/cloudera-repos</url>
<name>Cloudera Repositories</name>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>cdh.snapshots.repo</id>
<url>https://repository.cloudera.com/artifactory/libs-snapshot-local</url>
<name>Cloudera Snapshots Repository</name>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>apache release</id>
<url>https://repository.apache.org/content/repositories/releases/</url>
</repository>
<repository>
<id>apache non-releases</id>
<name>Apache non-releases</name>
<url>http://people.apache.org/~stack/m2/repository</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>java.net</id>
<name>Java.Net</name>
<url>http://download.java.net/maven/2/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>codehaus</id>
<name>Codehaus Public</name>
<url>http://repository.codehaus.org/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>repository.jboss.org</id>
<url>http://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>ghelmling.testing</id>
<name>Gary Helmling test repo</name>
<url>http://people.apache.org/~garyh/mvn/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
-----------------------updated 2013-11-28 13:53----------------------------
My bad. The problem is
<mirrors>
<mirror>
<id>public</id>
<mirrorOf>*</mirrorOf>
<url>http://mavenrepo.mycorp.com:8081/nexus/content/repositories/public</url>
</mirror>
</mirrors>
<mirrorOf>*</mirrorOf> should be <mirrorOf>central</mirrorOf>. By using *, it will be used to handle all download request of all repos. And surely the repo of company doesn't mirror 3rd part repos resources
Posting my guess as an answer.
Your problem seems to be that in your settings.xml you have a <mirrors/> section which is overriding the repositories defined in your pom.xml.

Resources