Artifactory 3rd party jar - maven

I've added a 3rd party jar into my artifactory (libs-release repos, and its the microsoft jdbc 4 connector).
The problem i have is that maven/apache servicemix fail to download the jar as they have the following setup, and it seems like they always attempt to download stuff from the remote-repos first.
<mirrors>
<mirror>
<mirrorOf>*</mirrorOf>
<name>remote-repos</name>
<url>http://...:8081/artifactory/remote-repos</url>
<id>remote-repos</id>
</mirror>
</mirrors>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://...:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots/>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://...:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://...:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots/>
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://...:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
Any ideas whats wrong/how i can fix this? A temp fix is to install the jar into my local repos, but i dont want to do that on other work pcs.
Cheers.

'remote-repos' repository in Artifactory is a virtual repository which aggregates, well, remote repositories :) Since you added your jar to your local repository, it can't be resolved from 'remote-repos'. Pointing your mirror-any to 'repo' should do the job.

Related

How to use Spring Snapshots with Nexus Repository

We have no problem building Spring Boot RELEASE projects with our Nexus repository which proxies maven-central and use a maven-public group. A Spring Boot SNAPSHOT project won't build, because Maven cannot resolve the SNAPSHOT dependencies. Spring SNAPSHOTS get downloaded, but then we get this error message.
Failure to find org.springframework.cloud:spring-cloud-starter-zipkin:jar:2.2.0.BUILD-SNAPSHOT
in http://[host]:8081/repository/[snapshots] was cached in the local
repository, resolution will not be reattempted until the update
interval of [snapshots] has elapsed or updates are forced
Here are the settings:
<settings>
<mirrors>
<mirror>
<id>nexus-proxy-maven-central</id>
<name>maven-central</name>
<url>http://[host]/repository/maven-central</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>maven-public</id>
<name>maven-public</name>
<url>http://[host]/repository/maven-public</url>
<layout>default</layout>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<name>Spring Milestone Repository</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
<pluginRepository>
<id>maven-public</id>
<name>maven-public</name>
<url>http://[host]/repository/maven-public</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<servers>
<server>
<id>[snapshots]</id>
<username>*</username>
<password>*</password>
</server>
<server>
<id>[releases]</id>
<username>*</username>
<password>*</password>
</server>
<server>
<id>maven-public</id>
<username>*</username>
<password>*</password>
</server>
<server>
<id>maven-central</id>
<username>*</username>
<password>*</password>
</servers>
</settings>
The pom looks like this:
<distributionManagement>
<repository>
<id>[releases]</id>
<url>https://[host]/repository/[releases]/</url>
</repository>
<snapshotRepository>
<id>[snapshots]</id>
<url>https://[host]/repository/[snapshots]/</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>repository.spring.snapshot</id>
<name>Spring Snapshot Repository</name>
<url>http://repo.spring.io/snapshot</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
<repository>
<id>repository.spring.milestone</id>
<name>Spring Milestone Repository</name>
<url>http://repo.spring.io/milestone</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>[releases]</id>
<name>[releases]</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots><enabled>false</enabled></snapshots>
<url>http://[host]/repository/[releases]</url>
<layout>default</layout>
</repository>
<repository>
<id>[snapshots]</id>
<name>[snapshots]</name>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
<url>http://[host]/repository[snapshots]</url>
<layout>default</layout>
</repository>
</repositories>
I've trying building with and without a Nexus proxy for Spring Snapshots, but it didn't help.
The problem is that 2.2.0.BUILD-SNAPSHOT is not publically available at http://repo.spring.io/snapshot at this time. The highest version available is 2.1.2.BUILD-SNAPSHOT. I was working with a Pivotal employee who must have access to higher build numbers earlier than the public. I backed my pom.xml down to 2.1.1.RELEASE and it worked.

cannot download snapshot from nexus

I set up a nexus repo for maven, I have deployed a snapshot but I can't get it anyway. No problem on release version.
Snapshot in the repo
what I get in my local repo
cannot get the jar
can get the metadata
Maven Setting
<mirror>
<id>maven-public</id>
<mirrorOf>*</mirrorOf>
<name>maven-public</name>
<url>http://nexus:8081/repository/maven-public/</url>
</mirror>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>public</id>
<name>maven-public</name>
<url>http://nexus:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<url>http://nexus:8081/repository/maven-public/</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
If the metadata is getting cached . try using mvn -U to the update the cached local repository.

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 configure Maven to use HTTPS when connecting to repo.maven.apache.org

I would like to secure the connection to repo.maven.apache.org when resolving dependencies (I wolud like to secure all connections made by Maven actually), but I'm not used to Maven configuration... My user settings.xml contains the following repositories and pluginRepositories sections:
<profiles>
<profile>
<id>main</id>
<repositories>
<repository>
<id>central</id>
<url>https://repo.maven.apache.org</url>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>https://repo.maven.apache.org</url>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
However Maven is unable to resolve dependencies with that setup.
Open the file $MAVEN_HOME/conf/settings.xml (where $MAVEN_HOME is the folder in which Maven has been installed) in a text editor. Then, add the following to the <mirrors>...</mirrors> section in this file:
<mirror>
<id>central-secure</id>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>

Instruct Maven to download third party plugin from https://oss.sonatype.org/content

There is a plugin I want to use on https://oss.sonatype.org/content/repositories/snapshots/
I know the maven command to run the plugin but how do I instruct Maven where the plugin should be downloaded from ?
I think I need to update my settings file to something like :
<mirrors>
<mirror>
<id>???</id>
<name>???</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</mirror>
</mirrors>
Is this correct ?
You should add a repository to your pom, that way the build will remain portable and other developers who build your code will not need to update their settings.xml.
This should do the job:
<repositories>
<repository>
<id>repo-id</id>
<name>repo-name</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
</repositories>
The best solution is to use the configuration in your current for only testing like this:
<project>
...
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>http://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>
...
</project>
or change your settings appropriately like this:
<settings>
...
<profiles>
<profile>
<id>apache</id>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Maven Plugin Snapshots</name>
<url>http://repository.apache.org/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
...
</settings>
of course with activation of the profile. Or change the configuration of your repository manager.

Resources