Why does the jira try to download dependencies from different sources - maven

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.

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

Moving maven profiles in setting.xml to pom.xml

I am using maven3. I have some user specific profiles and activeProfiles tags defined in settings.xml and I want to move them to project's pom.xml.
But merely copying profiles and activeProfiles from settings.xml to pom.xml does not work and breaks build because it tries to find project's parent pom in maven central instead of artifactory. Here's my settings.xml profiles.
Maven reports problem:
Failure to find xxx:xxx:pom:19.2 in https://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
Can someone please help ?
{
<profiles>
<profile>
<id>group</id>
<repositories>
<repository>
<id>nb_releases</id>
<name>Releases</name>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://artifactory.xxxx.xxxx/nb-m2</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
<profile>
<id>snapshots-group</id>
<repositories>
<repository>
<id>nb_snapshots</id>
<name>Snapshots</name>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://artifactory.xxxx.xxxx/nb-m2-snapshot</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
<profile>
<id>plugins</id>
<pluginRepositories>
<pluginRepository>
<id>nb_plugins</id>
<name>Plugins</name>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>http://artifactory.xxx.xxx/nb-m2</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>group</activeProfile>
<activeProfile>snapshots-group</activeProfile>
<activeProfile>plugins</activeProfile>
</activeProfiles>
}
The tag <activeProfiles> can only be used in the settings.xml, not in the POM.
There are different possibilities to activate a profile which can be used in a POM:
https://maven.apache.org/guides/introduction/introduction-to-profiles.html

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

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

What is this parent (jboss-parent) that the parent pom in Wildfly Quickstart is pointing to?

<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>14</version>
<relativePath />
</parent>
Where should this parent go, once I find it? Or is it safe to ignore?
It's located on GitHub and Maven central.
You might not need it however depending on what you're doing. It's used to just pull in some default plugin versions and dependency versions.
Copy the settings.xml file from $MAVEN_HOME/conf to local .m2 directory.
Edit and add:
inside <profiles> node:
<profile>
<id>jboss-public-repository</id>
<repositories>
<repository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>jboss-public-repository-group</id>
<name>JBoss Public Maven Repository Group</name>
<url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url>
<layout>default</layout>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
Below </profiles> node in <settings> node:
<activeProfiles>
<activeProfile>jboss-public-repository</activeProfile>
</activeProfiles>

Resources