Maven ignores a repository - maven

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

Related

Unable to download maven fmt-maven-plugin dependency

I am trying to add fmt-maven-plugin (https://mvnrepository.com/artifact/com.coveo/fmt-maven-plugin/2.13) as dependency so I added below code in my POM xml file
<dependency>
<groupId>com.coveo</groupId>
<artifactId>fmt-maven-plugin</artifactId>
<version>2.13</version>
</dependency>
Also I have below repo details in my settings.xml
<profile>
<id>maven-https</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
But I get below error while running build,
[ERROR] Plugin com.spotify.fmt:fmt-maven-plugin:2.13 or one of its dependencies could not be resolved: Could not find artifact com.spotify.fmt:fmt-maven-plugin:jar:2.13 in central (https://repo1.maven.org/maven2) -> [Help 1]
My understanding is maven could not download fmt-maven-plugin:2.13 from given https://repo1.maven.org/maven2 repo but I am not sure what repo to add in order to download fmt-maven-plugin. Can anyone suggest me?

Error building with Service Now connector v5.0.0 for Mule 3.7.1

I've been trying to do some tests with the new ServiceNow connector and Mule 3.7.1 but when I try to build the project and run it, it fails with the following error:
Failed to execute goal on project xxx: Could not resolve dependencies for project xxx:mule:0.0.1-SNAPSHOT: Failed to collect dependencies at org.mule.modules:mule-module-servicenow:jar:5.0.0: Failed to read artifact descriptor for org.mule.modules:mule-module-servicenow:jar:5.0.0: Could not transfer artifact org.mule.modules:mule-module-servicenow:pom:5.0.0 from/to mule-ee-releases (https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/): 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
I believe I have added the correct information into the correct sections in pom.xml
<inclusion>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-servicenow</artifactId>
</inclusion>
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>mule-module-servicenow</artifactId>
<version>5.0.0</version>
</dependency>
<repository>
<id>mulesoft-releases1</id>
<name>MuleSoft Repository</name>
<url>http://repository-master.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots1</id>
<name>MuleSoft Snapshot Repository</name>
<url>http://repository-master.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
I had to change the id of the two new repositories, since my pom already had repositories of those id's.
Can anyone shed any light on this for me?
Do you have the EE maven credentials set settings.xml? I was able to build an empty application using mule-module-servicenow with the following auto-generated (by dragging the connector from Anypoint pallet onto canvas) repositories:
<repositories>
<repository>
<id>Central</id>
<name>Central</name>
<url>http://repo1.maven.org/maven2/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-snapshots</id>
<name>MuleSoft Snapshots Repository</name>
<url>http://repository.mulesoft.org/snapshots/</url>
<layout>default</layout>
</repository>
<repository>
<id>mule-ee-releases</id>
<name>MuleEE Releases Repository</name>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/releases-ee/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mulesoft-release</id>
<name>mulesoft release repository</name>
<layout>default</layout>
<url>http://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

Cannot download "internal" SNAPSHOT artefacts from Apache archiva

I am using maven 3.0 and Apache Archiva as remote internal repository (configured as mirrior in settings.xml) but I am having problems downloading SNAPSHOT artifacts.
Failed to execute goal on project IntegrationTests: Could not resolve dependencies for project com.br.bigdata:IntegrationTests:jar:1.0-SNAPSHOT: Could not find artifact com.br.bigdata:HBaseSchema:jar:1.0-SNAPSHOT in archiva.default (.../archiva/repository/internal/) -> [Help 1]
I checked similar posts here but couldn't resolve my problem.
I checked the Archiva repository, artifact is present, correct pom versions etc.
In my pom the dependency is specified:
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>HBaseSchema</artifactId>
<version>${version.hbaseSchema}</version>
<scope>test</scope>
</dependency>
The artifact pom:
<groupId>com.br.bigdata</groupId>
<artifactId>HBaseSchema</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>HBaseSchema</name>
<description>Logical HBase schema</description>
Sorted. This needs to be added to settings.xml
<mirror>
<id>archiva.snapshots</id>
<url>http://localhost:8080/archiva/repository/snapshots</url>
<mirrorOf>snapshots</mirrorOf>
</mirror>
and
<profile>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>internal</id>
<name>Archiva Managed Internal Repository</name>
<url>https://lab-insighttc:8080/archiva/repository/internal</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<name>Archiva Managed Internal Repository</name>
<url>https://lab-insighttc:8080/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>

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