Maven FTP repository - ftp

I have setup a maven repository on my webserver using FTP.
The deployment works as expected, but when I wnat to install a submodule it does not find the files on the webserver, because it is trying to download from a wrong location.
I have setup the maven repo with a folder for snapshots and one for releases:
/ftp-dir/
releases/
snapshots/
The root pom file has fllowing distributionManagement:
<distributionManagement>
<repository>
<id>repo-id</id>
<url>ftp://my-ftp/releases</url>
</repository>
<snapshotRepository>
<id>develman.repository</id>
<url>ftp://my-ftp/snapshots</url>
</snapshotRepository>
</distributionManagement>
If I run mvn deploy with a -SNAPSHOT version it deploys the files into the snapshots directory as expected.
But when I delete my local repository and try to install a submodule maven cannot find the artifact. My settings.xml looks like this:
<servers>
<server>
<id>repo-id</id>
<username>username</username>
<password>password</password>
</server>
</servers>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>repository-id</id>
<name>my repository</name>
<url>http://my-website-address.com</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
aven tries to download from http://my-website-address.com/... and not from http://my-website-address.com/snapshots as expected.
What is my problem?

I had to change my repositories definition to two seperate repositories (1 for snapshot, 1 for release):
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>repository-release-id</id>
<name>my release repository</name>
<url>http://my-website-address.com/releases</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
</releases>
</repository>
<repository>
<id>repository-snapshot-id</id>
<name>my snapshot repository</name>
<url>http://my-website-address.com/snapshots</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

Related

How to configure multiple repositories in Maven rightly

I need to add fast-md5 to dependencies which lays at https://repo.spring.io/plugins-release/, so I configure settings.xml like
<profiles>
<profile>
<id>main</id>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>centralx</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
</repository>
<repository>
<id>spring</id>
<url>https://repo.spring.io/plugins-release/</url>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>main</activeProfile>
</activeProfiles>
But now all dependencies are missing. The error message is
Missing artifact commons-io:commons-io:jar:2.5
So How to configure multiple repositories?

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.

how to solve the warning Unrecognised tag: 'snapshotPolicy'?

When maven build there is a warning:
[WARNING] Unrecognised tag: 'snapshotPolicy' (position: START_TAG seen ...</url>\n <snapshotPolicy>... #269:27) # C:\Program Files\JetBrains\IntelliJ IDEA 2017.1.2\plugins\maven\lib\maven3\conf\settings.xml, line 269, column 27
The config file section is:
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://172.16.1.79:8082/repository/maven-public/</url>
<snapshotPolicy>always</snapshotPolicy>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
Is there a problem?
the demo config is as follow:
<profile>
<id>jdk-1.4</id>
<activation>
<jdk>1.4</jdk>
</activation>
<repositories>
<repository>
<id>jdk14</id>
<name>Repository for JDK 1.4 builds</name>
<url>http://www.myhost.com/maven/jdk14</url>
<layout>default</layout>
<snapshotPolicy>always</snapshotPolicy>
</repository>
</repositories>
</profile>
how to solve the warning Unrecognised tag: 'snapshotPolicy' , I can't found the maven office website here
See how the offending tag goes within releases and snapshots tags. Placed there, it works.
<!--http://maven.apache.org/settings.html#Activation-->
<profiles>
<profile>
<id>nexus</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://172.16.1.79:8082/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>daily</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>

Nexus group by SNAPSHOT

I have Nexus with builds repository. How I can group my versions on folders named snapshot-x.x ?
Repository have snapshot type. User deployment have all privileges.
I run maven as mvn versions:set -DnewVersion=$VERSION and mvn clean deploy -B -Pbuild -Dbuild.version=$VERSION
My settings.xml work only releases repo ;-(
<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">
<servers>
<server>
</server>
</servers>
<profiles>
<profile>
<id>build</id>
<repositories>
<repository>
<id>nexus-repo</id>
<name>Nexus repo</name>
<url>http://<MY-HOST>:8081:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus-repo</id>
<name>Nexus repo </name>
<url>http://<MY-HOST>:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<altDeploymentRepository>
-DaltDeploymentRepository=builds::default::http://deployment:<MY_PASS>#<MY-HOST>:8081/content/repositories/builds
</altDeploymentRepository>
</properties>
</profile>
</profiles>
</settings>
<activeProfiles>
<activeProfile>build</activeProfile>
</activeProfiles>
I'm not sure what you are asking for? A repository has a fixed format which comprises of groupId:artifactId:version ?
There you see com/soebes/examples/j2ee is the groupId: com.soebes.examples.j2eee and than artifactId: app plus the version 1.1.2-SNAPSHOT with the underlying versions for a single SNAPSHOT

maven repositories order

I have a maven repo which stores all the artifacts under
http://example.com/content/public
I have a second repo which stores different artifacts under
http://example.com/content/type1
By default for all the builds I want to get the artifacts from "content/public"
But for one specific usecase when a flag is switched on I want to get artifacts from "content/type1"
If an artifact is not present then I want to look for it in "content/public"
My apache-maven/3.04./conf/settings.xml looks like this
<mirrors>
<mirror>
<!-- This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*,!type1</mirrorOf>
<url>http://example.com/content/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!-- Enable snapshots for the built in central repo to direct -->
<!-- all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled><updatePolicy>never</updatePolicy></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
<properties>
<!-- Default this property so we can create references easily. -->
<nexusHostName>example.com</nexusHostName>
</properties>
</profile>
</profiles>
<activeProfiles>
<!-- make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
My profile in the pom.xml looks like this
<profile>
<id>type1-build</id>
<activation>
<property>
<name>type1</name>
<value>true</value>
</property>
</activation>
<repositories>
<repository>
<id>type1</id>
<name>Type1 Repo</name>
<url>http://${nexusHostName}/content/groups/type1/</url>
<layout>default</layout>
<!-- Enforce strict checksums and always update releases and snapshots -->
<releases>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://${nexusHostName}/content/groups/public/</url>
<layout>default</layout>
<!-- Enforce strict checksums and always update releases and snapshots -->
<releases>
<enabled>false</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<checksumPolicy>fail</checksumPolicy>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
</profile>
Even after doing this when i run a goal like mvn goal1 -Dtype1=true it still looks for artifacts in "content/public"
Can someone please tell me what is that I am doing wrong
Just change the order of your repositories content/type1 first and then content/public

Resources