Skip to content

Commit 5428768

Browse files
committed
HSEARCH-5351 Switch to JReleaser for nexus publishing
1 parent 2b4fdeb commit 5428768

File tree

6 files changed

+90
-137
lines changed

6 files changed

+90
-137
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# Our build scripts - necessary for our release jobs
88
hibernate-noorm-release-scripts
99
hibernate-release-scripts
10+
jreleaser
1011

1112
#Checkstyle
1213
.checkstyle

build/reports/pom.xml

-32
Original file line numberDiff line numberDiff line change
@@ -214,38 +214,6 @@
214214
</dependency>
215215
</dependencies>
216216
</plugin>
217-
<!--
218-
Hack to deploy in the "reports" module without deploying the "reports" module itself.
219-
The default lifecycle bindings of the plugin is to "stage locally" every artifact throughout
220-
the maven execution, and only actually deploy the "locally staged" artifacts
221-
in the very last executed module, which happens to be this "reports" module.
222-
However, this "reports" module does not generate any artifact we want to deploy.
223-
Thus, we'd like to prevent even its POM from being deployed: just deploy the "locally staged" artifacts,
224-
without adding the POM from the "reports" module to these artifacts.
225-
The default lifecycle bindings of the plugin does not offer a configuration option to do that,
226-
so we have to explicitly bind it
227-
-->
228-
<plugin>
229-
<groupId>org.sonatype.plugins</groupId>
230-
<artifactId>nexus-staging-maven-plugin</artifactId>
231-
<extensions>false</extensions>
232-
<!-- The <configuration> element is inherited from the parent module. -->
233-
<executions>
234-
<!-- Skip the default deployment, as explained above we don't want it. -->
235-
<execution>
236-
<id>default-deploy</id>
237-
<phase>none</phase>
238-
</execution>
239-
<!-- ... but execute the deferred deployment for the other modules -->
240-
<execution>
241-
<id>deferred-deploy</id>
242-
<phase>deploy</phase>
243-
<goals>
244-
<goal>deploy-staged</goal>
245-
</goals>
246-
</execution>
247-
</executions>
248-
</plugin>
249217
</plugins>
250218
</build>
251219

ci/release/Jenkinsfile

+9-3
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,19 @@ pipeline {
6262
def developmentVersion = Version.parseDevelopmentVersion(params.DEVELOPMENT_VERSION)
6363
echo "Performing full release for version ${releaseVersion.toString()}"
6464

65-
withMaven(mavenSettingsConfig: params.RELEASE_DRY_RUN ? null : 'ci-hibernate.deploy.settings.maven',
66-
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
65+
withMaven(mavenSettingsConfig: null, mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
6766
configFileProvider([configFile(fileId: 'release.config.ssh', targetLocation: env.HOME + '/.ssh/config'),
6867
configFile(fileId: 'release.config.ssh.knownhosts', targetLocation: env.HOME + '/.ssh/known_hosts')]) {
6968
// using MAVEN_GPG_PASSPHRASE (the default env variable name for passphrase in maven gpg plugin)
7069
withCredentials([file(credentialsId: 'release.gpg.private-key', variable: 'RELEASE_GPG_PRIVATE_KEY_PATH'),
71-
string(credentialsId: 'release.gpg.passphrase', variable: 'MAVEN_GPG_PASSPHRASE')]) {
70+
string(credentialsId: 'release.gpg.passphrase', variable: 'JRELEASER_GPG_PASSPHRASE'),
71+
// TODO: HSEARCH-5354
72+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
73+
// to use the following env variable names to set the user/password:
74+
// JRELEASER_MAVENCENTRAL_USERNAME
75+
// JRELEASER_MAVENCENTRAL_TOKEN
76+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
77+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
7278
sshagent(['ed25519.Hibernate-CI.github.com', 'hibernate.filemgmt.jboss.org', 'hibernate-ci.frs.sourceforge.net']) {
7379
sh 'cat $HOME/.ssh/config'
7480
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'

ci/snapshot-publish/Jenkinsfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,19 @@ pipeline {
3535
script {
3636
withMaven(mavenSettingsConfig: 'ci-hibernate.deploy.settings.maven',
3737
mavenLocalRepo: env.WORKSPACE_TMP + '/.m2repository') {
38-
sh """mvn \
39-
-Pci-build \
40-
-DskipTests \
41-
clean deploy \
42-
"""
38+
withCredentials([// TODO: HSEARCH-5354
39+
// Once we switch to maven-central publishing (from nexus2) we need to add a new credentials
40+
// to use the following env variable names to set the user/password:
41+
// JRELEASER_MAVENCENTRAL_USERNAME
42+
// JRELEASER_MAVENCENTRAL_TOKEN
43+
usernamePassword(credentialsId: 'ossrh.sonatype.org', passwordVariable: 'JRELEASER_NEXUS2_PASSWORD', usernameVariable: 'JRELEASER_NEXUS2_USERNAME'),
44+
string(credentialsId: 'Hibernate-CI.github.com', variable: 'JRELEASER_GITHUB_TOKEN')]) {
45+
def version = sh(script: "mvn help:evaluate -Dexpression=project.version -q -DforceStdout", returnStdout: true).trim()
46+
echo "Current version: '${version}'"
47+
48+
sh 'git clone https://github.com/hibernate/hibernate-release-scripts.git'
49+
sh "bash -xe hibernate-release-scripts/snapshot-deploy.sh search ${version}"
50+
}
4351
}
4452
}
4553
}

jreleaser.yml

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
project:
2+
languages:
3+
java:
4+
groupId: org.hibernate.search
5+
6+
release:
7+
github:
8+
skipTag: true
9+
skipRelease: true
10+
tagName: '{{projectVersion}}'
11+
12+
# File signing is always active
13+
signing:
14+
mode: COMMAND
15+
active: RELEASE
16+
armored: true
17+
18+
# Deploy JARs and POMs to Maven Central
19+
deploy:
20+
maven:
21+
nexus2:
22+
maven-central:
23+
active: RELEASE
24+
url: https://oss.sonatype.org/service/local
25+
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
26+
closeRepository: true
27+
releaseRepository: false
28+
stagingRepositories:
29+
- target/staging-deploy/maven
30+
maven-central-snapshot:
31+
active: SNAPSHOT
32+
url: https://oss.sonatype.org/service/local
33+
snapshotUrl: https://oss.sonatype.org/content/repositories/snapshots/
34+
closeRepository: true
35+
releaseRepository: true
36+
javadocJar: false
37+
sign: false
38+
stagingRepositories:
39+
- target/staging-deploy/maven
40+
mavenCentral:
41+
maven-central:
42+
# TODO: HSEARCH-5354 Change to RELEASE once switching to Maven-Central:
43+
active: NEVER
44+
url: https://central.sonatype.com/api/v1/publisher
45+
snapshotSupported: false
46+
applyMavenCentralRules: true
47+
stagingRepositories:
48+
- target/staging-deploy/maven
49+
# Deployment identifier used for publication.
50+
# deploymentId: dd9991b0-18a7-41e7-b1fe-37b8ea936f85
51+
maven-central-snapshot:
52+
# TODO: HSEARCH-5354 Change to SNAPSHOT once switching to Maven-Central:
53+
active: NEVER
54+
url: https://central.sonatype.com/api/v1/publisher
55+
snapshotSupported: true
56+
applyMavenCentralRules: true
57+
javadocJar: false
58+
sign: false
59+
stagingRepositories:
60+
- target/staging-deploy/maven
61+
# Deployment identifier used for publication.
62+
# deploymentId: dd9991b0-18a7-41e7-b1fe-37b8ea936f85

pom.xml

+5-97
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@
270270
<version.enforcer.plugin>3.5.0</version.enforcer.plugin>
271271
<version.project-info.plugin>3.9.0</version.project-info.plugin>
272272
<version.japicmp.plugin>0.23.1</version.japicmp.plugin>
273-
<version.nexus-staging.plugin>1.7.0</version.nexus-staging.plugin>
274273
<version.deploy.plugin>3.1.4</version.deploy.plugin>
275-
<version.gpg.plugin>3.2.7</version.gpg.plugin>
276274
<version.flatten-maven-plugin>1.7.0</version.flatten-maven-plugin>
277275
<version.assembly.plugin>3.7.1</version.assembly.plugin>
278276
<version.buildhelper.plugin>3.6.0</version.buildhelper.plugin>
@@ -316,20 +314,13 @@
316314
<version.spotless-maven-plugin>2.44.4</version.spotless-maven-plugin>
317315
<version.maven-antrun-plugin>3.1.0</version.maven-antrun-plugin>
318316

319-
<!-- Repository Deployment URLs -->
320-
321-
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
322-
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</ossrh.releases.repo.url>
323-
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org/</ossrh.releases.repo.baseUrl>
324-
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
325-
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
326-
327317
<!--
328318
We don't want to publish or sign any modules by default.
329319
Specific modules will override the setting at their own level.
330320
-->
331321
<deploy.skip>true</deploy.skip>
332-
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
322+
<!-- We always publish to a local directory, JReleaser is supposed to take care of publishing to Nexus: -->
323+
<altDeploymentRepository>local::file:${maven.multiModuleProjectDirectory}/target/staging-deploy/maven</altDeploymentRepository>
333324

334325
<!-- Can be overridden by subprojects if dependency convergence cannot be achieved -->
335326
<enforcer.dependencyconvergence.skip>false</enforcer.dependencyconvergence.skip>
@@ -555,39 +546,13 @@
555546
</executions>
556547
</plugin>
557548
<!-- We want to deploy the public BOM, so we manage this plugin in the root pom. -->
558-
<plugin>
559-
<groupId>org.sonatype.plugins</groupId>
560-
<artifactId>nexus-staging-maven-plugin</artifactId>
561-
<version>${version.nexus-staging.plugin}</version>
562-
<configuration>
563-
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
564-
</configuration>
565-
</plugin>
566-
<!-- We want to disable this plugin as soon as possible, hence we manage it in the root pom. -->
567549
<plugin>
568550
<groupId>org.apache.maven.plugins</groupId>
569551
<artifactId>maven-deploy-plugin</artifactId>
570552
<version>${version.deploy.plugin}</version>
571-
</plugin>
572-
<!-- Public BOM must be also signed, so we manage this plugin in the root pom. -->
573-
<plugin>
574-
<groupId>org.apache.maven.plugins</groupId>
575-
<artifactId>maven-gpg-plugin</artifactId>
576-
<version>${version.gpg.plugin}</version>
577-
<executions>
578-
<execution>
579-
<id>sign-artifacts</id>
580-
<phase>verify</phase>
581-
<goals>
582-
<goal>sign</goal>
583-
</goals>
584-
<configuration>
585-
<skip>${deploy.skip}</skip>
586-
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
587-
<bestPractices>true</bestPractices>
588-
</configuration>
589-
</execution>
590-
</executions>
553+
<configuration>
554+
<skip>${deploy.skip}</skip>
555+
</configuration>
591556
</plugin>
592557
<!-- Public BOM will be flattened too, so we manage this plugin in the root pom. -->
593558
<plugin>
@@ -1140,43 +1105,9 @@
11401105
</plugins>
11411106
</pluginManagement>
11421107
<plugins>
1143-
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
11441108
<plugin>
11451109
<groupId>org.apache.maven.plugins</groupId>
11461110
<artifactId>maven-deploy-plugin</artifactId>
1147-
<configuration>
1148-
<skip>${maven-deploy-plugin.skip}</skip>
1149-
</configuration>
1150-
</plugin>
1151-
<!--
1152-
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
1153-
in order to work around a problem in the "reports" module (see that module's POM for more info).
1154-
-->
1155-
<plugin>
1156-
<groupId>org.sonatype.plugins</groupId>
1157-
<artifactId>nexus-staging-maven-plugin</artifactId>
1158-
<extensions>false</extensions><!-- This is essential: do not put true here -->
1159-
<configuration>
1160-
<serverId>${ossrh.releases.repo.id}</serverId>
1161-
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
1162-
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
1163-
<!-- oss.sonatype.org has been very slow when closing repositories lately;
1164-
let's raise the timeout until we switch to s01.sonatype.org -->
1165-
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
1166-
</configuration>
1167-
<executions>
1168-
<execution>
1169-
<id>default-deploy</id>
1170-
<phase>deploy</phase>
1171-
<goals>
1172-
<!--
1173-
This will only put artifacts in a staging directory.
1174-
See the "reports" module for actual deployment, at the end of the build.
1175-
-->
1176-
<goal>deploy</goal>
1177-
</goals>
1178-
</execution>
1179-
</executions>
11801111
</plugin>
11811112
<plugin>
11821113
<groupId>org.apache.maven.plugins</groupId>
@@ -1249,19 +1180,6 @@
12491180
</plugins>
12501181
</build>
12511182

1252-
<distributionManagement>
1253-
<repository>
1254-
<id>${ossrh.releases.repo.id}</id>
1255-
<name>OSSRH Releases Repository</name>
1256-
<url>${ossrh.releases.repo.url}</url>
1257-
</repository>
1258-
<snapshotRepository>
1259-
<id>${ossrh.snapshots.repo.id}</id>
1260-
<name>OSSRH Snapshots Repository</name>
1261-
<url>${ossrh.snapshots.repo.url}</url>
1262-
</snapshotRepository>
1263-
</distributionManagement>
1264-
12651183
<reporting>
12661184
<plugins>
12671185
<plugin>
@@ -1347,14 +1265,6 @@
13471265
<!-- We want this execution to happen before moditect (which executes at package phase) -->
13481266
<javadoc.generate.jar.phase>prepare-package</javadoc.generate.jar.phase>
13491267
</properties>
1350-
<build>
1351-
<plugins>
1352-
<plugin>
1353-
<groupId>org.apache.maven.plugins</groupId>
1354-
<artifactId>maven-gpg-plugin</artifactId>
1355-
</plugin>
1356-
</plugins>
1357-
</build>
13581268
</profile>
13591269

13601270
<profile>
@@ -1800,10 +1710,8 @@
18001710
-->
18011711
<id>reproducibility-check</id>
18021712
<properties>
1803-
<maven-deploy-plugin.skip>false</maven-deploy-plugin.skip>
18041713
<maven.javadoc.skip>true</maven.javadoc.skip>
18051714
<skipTests>true</skipTests>
1806-
<gpg.skip>true</gpg.skip>
18071715
</properties>
18081716
</profile>
18091717

0 commit comments

Comments
 (0)