Snaphot repository issue - maven

We have installed Archiva with the two repositories set by default.
Here is my settings.xml:
<server>
<id>mycompany-release</id>
<username>admin</username>
<password>******</password>
</server>
<server>
<id>mycompany-snapshots</id>
<username>admin</username>
<password>******</password>
</server>
<mirror>
<id>mycompany-release</id>
<url>http://X.X.X.X:8080/archiva/repository/internal/</url>
<mirrorOf>external:*</mirrorOf>
</mirror>
<mirror>
<id>mycompany-snapshots</id>
<url>http://X.X.X.X:8080/archiva/repository/snapshots/</url>
<mirrorOf>apache.snapshots</mirrorOf>
</mirror>
<profile>
<id>repo</id>
<repositories>
<repository>
<id>mycompany-release</id>
<url>http://X.X.X.X:8080/archiva/repository/internal/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>mycompany-snapshots</id>
<url>http://X.X.X.X:8080/archiva/repository/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<activeProfiles>
<activeProfile>repo</activeProfile>
</activeProfiles>
I have a parent project that I use to set the common configuration for all the projects. The version of this parent project is 1-SNAPSHOT. So, in all the other projects, the parent section points to this parent project with version 1-SNAPSHOT (without relative path element). If I deploy my parent project to the archiva repository, it is there. If I try to run any command on another project, as mvn clean, it works since the parent project was installed during deployment. But, if I delete manually the parent project from my local repository and try to run the same command, Maven returns an error saying :
Non resolvable parent POM: Could not find artifact
com.mycompany:Parent:pom:1-SNAPSHOT in mycompany-release
(http://X.X.X.X:8080/archiva/repository/internal/) and
'parent.relativePath' points at wrong local POM
It seems that the parent project is looked up in the release repository while I expected it's looked up in the snapshot repository.
Thanks for your help
EDIT: Here is one part of the child POM:
<parent>
<groupId>com.mycompany</groupId>
<artifactId>Parent</artifactId>
<version>1-SNAPSHOT</version>
</parent>
<groupId>com.mycompany</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
If I remove the parent section and run mvn help:effective-pom, I get (only repositories is shown):
<repositories>
<repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>mycompany-release</id>
<url>http://X.X.X.X:8080/archiva/repository/internal/</url>
</repository>
<repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>mycompany-snapshots</id>
<url>http://X.X.X.X:8080/archiva/repository/snapshots/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
NOTE: if I replace the parent version by 1 (instead of 1-SNAPSHOT), it works.

I found what was the issue. The problematic line in the settings.xml is:
<mirrorOf>external:*</mirrorOf>
Indeed, it caused Maven to consider the mycompany-release repository as a mirror of mycompany-snapshots repository. But, this repository doesn't mirror snapshots. I replaced this line by:
<mirrorOf>central</mirrorOf>
Now, the mycompany-release repository mirror only the Maven central repository and not the mycompany-snapshots repository, so it looks up the snapshots artifacts in the mycompany-snapshots repository.
Thanks Andrew for your help! I didn't now there was a possibility to display the full log.

Related

Overriding central works in profile, but not directly?

I've spend a lot of time looking for error in maven configuration.
I've overriden central with internal caching repository:
<activeProfiles>
<activeProfile>internal</activeProfile>
</activeProfiles>
<profiles>
<profile>
<id>internal</id>
<repositories>
<repository>
<id>central</id>
<url>https://internal.rep/nexus/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</profile>
</profiles>
However, that configuration was not working on the build server. There were attempts made to download artifacts from central maven repository.
I've found out that there, in settings.xml, the repositories section was declared directly in <settings> and not in profile:
<settings>
<repositories>
<repository>
<id>central</id>
<url>https://internal.rep/nexus/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</settings>
which I've initially ignored, because it shouldn't make any difference. It did.
But why are repositories ignored, that are defined not in profile? There was no warning about invalid settings.xml, the maven behaved as if those tags were not there...
Do generally everything in settings.xml need to be declared in profile? I'm using Maven 3.8

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>

Why does the jira try to download dependencies from different sources

I have a jira trying to download dependencies from the server. I have a repository that is configured and works great. This repository duplicates data from the server (in fact it is a secure gateway).
BUT somehow jira tries to connect directly to the server, at the same time it refers to the repository: 3
I thought that in jira connection with the network and with the Internet is configured in maven. Maybe I'm wrong ?
here are the settings of the mavena setting.xml lying in (atlassian-plugin-sdk-6.2.14 \ apache-maven-3.2.1 \ conf)
<?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">
<profiles>
<profile>
<repositories>
<repository>
<id>maven-public</id>
<url>http://n7701-sys274:8081/artifactory/maven-public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>maven-external</id>
<url>http://n7701-sys274:8081/artifactory/maven-external</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>maven2</id>
<url>http://n7701-sys274:8081/artifactory/maven2/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
<repository>
<id>public</id>
<url>http://n7701-sys274:8081/artifactory/public/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://n7701-sys274:8081/artifactory/public/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>maven2</id>
<url>http://n7701-sys274:8081/artifactory/maven2/</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>maven-external</id>
<url>http://n7701-sys274:8081/artifactory/maven-external</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
<pluginRepository>
<id>maven-public</id>
<url>http://n7701-sys274:8081/artifactory/maven-public</url>
<releases>
<enabled>true</enabled>
<checksumPolicy>warn</checksumPolicy>
</releases>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
Unless I am mistaken your problem is that:
you properly configure maven to retrieve artifacts from your artifactory server
maven downloads a batch of artifacts from artifactory and resolves them
maven then tries to download transitive dependencies from maven central
Maven central is a special pre-configured repository, injected through automatic POM inheritance.
So your artifacts are resolved both in the repositories defined in your own settings.xml and in maven central
In a nutshell, you need to define in your settings.xml that your artifactory server acts as a mirror to maven central, with the following snippet
...
<mirrors>
<mirror>
<id>central-proxy</id>
<name>Artifactory proxy of central repo</name>
<url>http://n7701-sys274:8081/artifactory/maven-public</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
Note that closely related to this question is Disable Maven central repository
My answer is a combination of the solutions to this question.

How to determine what repositories I need to add to Sonatype Nexus for Mule ESB

We have been building MuleESB using Maven. Everything has been working fine.
However, we recently added Sonatype Nexus as a repository manager.
Now, building MuleESB using Maven which is now configured to mirror our internal public Nexus URL, many transitive dependencies are not found and the build fails.
I have to go and look which transitive dependency is not found, find which public repository it sits on by looking at the pom files, and then add that as a proxied repository on Nexus. I am repeating this for every unresolved dependency.
Note that I have added the mulesoft releases and snapshot repository. It appears to be the transitive dependencies which are found in other repositories (not the Mulesoft one) which are failing.
What is the best/easiest way to make sure all required repositories are added to our Sonatype Nexus repository?
--- EDIT ----
So far I have found that if I add the following repositories to Nexus, I can build Mule ESB Community Edition as all dependencies are found.
http://xqj.net/maven/
http://repository.mulesoft.org/snapshots/
http://repository.mulesoft.org/releases/
https://repository.mulesoft.org/nexus/content/groups/public/
http://repo.jfrog.org/artifactory/plugins-releases-local/
https://repo1.maven.org/maven2/
You are following the right process:
Identify the repositories you need access to
Create a proxy repository for each one, make sure to set the appropriate policy (snapshot vs release), for proxying groups make sure to create two proxy repositories with the same URL and different policy if it has mixed content
Add the repositories to the group through which you access the Nexus repository manager, keep in mind that the order in the group is important, keep large, performant ones as well as your internal repositories at the top
In your list you can probably remove the artifactory repository since the artifacts will be in the other repositories. Also the maven.org (Central Repository) is already preconfigured in the Nexus Repository Manager so you probably don't have to add it.
It is best to add one repo at a time and try a build either from a fresh install (deleted local Maven repository) or force updates with -U on your mvn invocation.
If you need more info, you can find all this and more in the documentation.
Here is the maven settings I use with Mule development.
You can use it to figure out how to set up your repository.
<?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">
<localRepository>/Users/MuleDev/.m2/repository</localRepository>
<pluginGroups>
</pluginGroups>
<proxies>
</proxies>
<servers>
<server>
<id>mule-nexus-ee-releases</id>
<username>xxx</username>
<password>xxx</password>
</server>
<server>
<id>mule-ci-releases</id>
<username>xxxx</username>
<password>xxx</password>
</server>
<server>
<id>mule-ci-snapshots</id>
<username>xxxx</username>
<password>xxx</password>
</server>
<server>
<id>mule-ee-releases</id>
<username>xxxx</username>
<password>xxx</password>
</server>
<server>
<id>mule-ee-snapshots</id>
<username>xxxx</username>
<password>xxxxx</password>
</server>
<server>
<id>mule-ee-thirdparty</id>
<username>xxxxx</username>
<password>xxxx</password>
</server>
<server>
<id>mule-ee-dependencies</id>
<username>xxxx</username>
<password>xxxx</password>
</server>
<server>
<id>mule-third-party</id>
<username>xxxx</username>
<password>xxxx</password>
</server>
</servers>
<mirrors>
</mirrors>
<profiles>
<profile>
<id>default-profile</id>
<repositories>
<repository>
<id>jboss</id>
<url>https://repository.jboss.org/nexus/content/repositories/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>mule-releases</id>
<name>Mule Releases Repository</name>
<url>http://repository.mulesoft.org/releases/</url>
</repository>
<repository>
<id>mule-ee-releases</id>
<name>MuleEE Releases Repository</name>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>mule-ee-thirdparty</id>
<name>Local repository for thirdparty</name>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/ext-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
<repository>
<id>mule-ee-dependencies</id>
<name>Mule EE Dependencies</name>
<url>https://repository-master.mulesoft.org/nexus/content/groups/mule-ee-dependencies/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>mule-nexus-ee-releases</id>
<name>Mule EE Releases Repository</name>
<url>https://repository.mulesoft.org/nexus-ee/content/repositories/releases-ee/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>mule-nexus-releases</id>
<name>Mule CE Releases Repository</name>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>codehaus-mule-repo</id>
<name>codehaus-mule-repo</name>
<url>
https://repository-master.mulesoft.org/nexus/content/groups/public/
</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>mule-ee-snapshots</id>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
</pluginRepository>
<pluginRepository>
<id>mule-ee-releases</id>
<url>https://repository-master.mulesoft.org/nexus/content/repositories/ci-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
<layout>default</layout>
</pluginRepository>
<pluginRepository>
<id>mule-nexus-releases</id>
<name>Mule CE Releases Repository</name>
<url>https://repository.mulesoft.org/nexus/content/repositories/releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
</settings>
The pom used on github for the community development can be used, here's the link
https://github.com/mulesoft/mule/blob/mule-3.x/pom.xml

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>

Resources