Nexus group by SNAPSHOT - maven

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

Related

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

Jenkins Maven job unable to access plugins for deployment from repositories

I am new to Jenkins. As part of POC i tried to deploy a basic SOA project from command line "mvn pre-integration-test", it was successfully deployed to localhost weblogic server. However, when tried Jenkin's job polling svn code, its failing repeatedly with following error msg:
Started by user anonymous
Building in workspace C:\Program Files (x86)\Jenkins\workspace\testAppSairu
Updating protocol://xxx/svn/testAppSairu/branches/testAppSairu at revision '2015-10-19T18:08:19.290 +0530'
At revision 2
no change for protocol://xxx/svn/testAppSairu/branches/testAppSairu since the previous build
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Parsing POMs
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
Setting environment Jenkins.Repository = protocol://localhost:8088/repository/dev
ERROR: Failed to parse POMs
org.apache.maven.project.ProjectBuildingException: Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM: Failure to transfer com.oracle.soa:sar-common:pom:12.1.3-0-0 from protocol://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. Original error: Could not transfer artifact com.oracle.soa:sar-common:pom:12.1.3-0-0 from/to central (protocol://repo.maven.apache.org/maven2): Connection to protocol://repo.maven.apache.org refused and 'parent.relativePath' points at no local POM # line 21, column 13
at org.apache.maven.project.DefaultProjectBuilder.build(DefaultProjectBuilder.java:364)
Note: I used maven sync plugin to install and push weblogic home into local repository and also Archiva managed repository. While running mvn compile/pre-integration-test i am able to deploy it successfully but failing here since its unable to access plugins.
.m2 settings.xml file:
<?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">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<offline>false</offline>
<profiles>
<profile>
<id>default</id>
</pluginRepositories>
<pluginRepository>
<id>maven.oracle.com</id>
<url>https://maven.oracle.com</url>
</pluginRepository>
<pluginRepository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>maven.oracle.com</id>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<url>https://maven.oracle.com</url>
<layout>default</layout>
</repository>
<repository>
<id>dev-group</id>
<name>Dev Group</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev-group</url>
<layout>default</layout>
</repository>
<repository>
<id>dev</id>
<name>Dev</name>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/dev</url>
<layout>default</layout>
</repository>
<repository>
<id>snapshots</id>
<name>Archiva Managed Snapshot Repository</name>
<releases>
<enabled>false</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<url>http://localhost:8088/repository/snapshots</url>
<layout>default</layout>
</repository>
</repositories>
</profile>
</profiles>
<mirrors>
<mirror>
<id>dev-mirror</id>
<name>All Else</name>
<url>http://localhost:8088/repository/dev-group</url>
<mirrorOf>*</mirrorOf>
</mirror>
</mirrors>
<servers>
<server>
<id>maven.oracle.com</id>
<username>OTN username</username>
<password>OTN password</password>
<configuration>
<basicAuthScope>
<host>ANY</host>
<port>ANY</port>
<realm>OAM 11g</realm>
</basicAuthScope>
<httpConfiguration>
<all>
<params>
<property>
<name>http.protocol.allow-circular-redirects</name>
<value>%b,true</value>
</property>
</params>
</all>
</httpConfiguration>
</configuration>
</server>
<server>
<id>dev</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>dev-group</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<activeProfiles>
<activeProfile>defualt</activeProfile>
</activeProfiles>
</settings>
As suggested in docs.oracle.com/middleware/1213/core/MAVEN.pdf, i have downloaded wagon-http-2.8-shaded.jar and placed underapache-maven-3.3.3\lib\ext folder. Updated repository, server details etc in settings.xml. But still issue is not resolved.
My intention is to deploy a simgle SOA 12c project using Jenkin's maven job part of Continuous Integration flow. Please suggest if i am missing anything here. I am rookie on this so any help will save my day. Thanks!

Using Nexus repository instead of public Maven in Idea Intellij

How can I force Idea Intellij to download from Nexus repository instead of Maven Public repo?
Where can I configure that in Idea properties?
It's not defined in pom.xml files and I'd prefer not to.
Not sure if it will work also on Idea Intellij ( I am using spring source studio - eclipse clon) , but should because maven configuration is in settings.xml in .M2 directory which is located in your home directory. Just use something like this ( my server is running on nexus-server:8081):
<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>
<id>releases</id>
<username>user-name</username>
<password>your-password</password>
</server>
<server>
<id>snapshots</id>
<username>user-name</username>
<password>your-password</password>
</server>
</servers>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://nexus-server:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Disable 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>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>

Maven FTP repository

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>

Resources