The main strategy for supporting both Hudson and Jenkins is to make the main pom structure neutral and then use two profiles to handle the version specifics. These profile which I have called hudson-publish and jenkins-publish is both represented in the settings.xml and the pom.xml.
pom.xml:
In order to create a pom that works for both sides, I have done the following things.
- Specified the parent version as 1.392. This is the latest pre-fork parent which do not suffer from the bug which prevents publishing of "requiresCoreVersion". Full specification is org.jvnet.hudson.plugins:plugin:1.392
- The groupId of the plug-in must be org.jvnet.hudson.plugins otherwise the publishing to maven central wont work.
- The basic items like name, description and url must be set. The Hudson update centre uses the URL and description.
- Remember to add license and developer information.
- Remember to override scm and issueManagment section.
- Don't specify distributionManagment outside the profiles.
- Configure the release plugin to only make deploy not site-deploy and use forked-path which is needed by the gpg plug-in.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.1</version>
<configuration>
<mavenExecutorId>forked-path</mavenExecutorId>
<goals>deploy</goals>
</configuration>
</plugin>
settings.xml:
There are some things that need to go into the settings.xml which are not profile specific. This is the list of server definitions, which you must add in order to provide username/passwords. I have server definitions for the following list
- sonatype-nexus-snapshots
- sonatype-nexus-staging
- maven.jenkins-ci.org
jenkins-publish profile:
In the settings.xml you need to specify the Jenkins maven repository
<repository>
<id>maven.jenkins-ci.org</id>
<name>Jenkins Repository</name>
<layout>default</layout>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
In the pom.xml specify the distributionManagment as:
<distributionManagement>
<repository>
<id>maven.jenkins-ci.org</id>
<url>http://maven.jenkins-ci.org:8081/content/repositories/releases/</url>
</repository>
</distributionManagement>
hudson-publish profile:
In the settings.xml you need to specify the Hudson maven repositories and your gpg passphrase.
<repositories>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<layout>default</layout>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<layout>default</layout>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<properties>
<gpg.passphrase>REPLACE_WITH_YOUR_OWNPASSPHRASE</gpg.passphrase>
</properties>
In the pom file, you need to specify both distributionManagment and configure the gpg plugin
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Full pom examle
You can look here for an example of a complete pom file
Top 25 Best Casinos in Canada (2021) - Mapyro
ReplyDeleteBest Casinos in 군포 출장안마 Canada (2021) · 1. Bovada Casino · 2. Café 포항 출장안마 Casino 속초 출장안마 · 3. 888 Casino 제주 출장샵 · 4. Casumo Casino · 5. Cafe Casino · 6. Red 제주 출장마사지 Tiger Casino