Skip to content

Commit 2a1771e

Browse files
committed
HBX-2994: Backport automated releases to branch 6.4
- Add 'reports' module - Modify pom.xml with following changes/additions: * Add needed properties for the CI run * Modify the 'distributionManagement' section with the needed deployment info * Add a 'build' section to (1) sign the artefacts to deploy (2) perform deployment to the sonatype repo (3) flatten the pom files * Add a 'profile' section for the release Signed-off-by: Koen Aers <[email protected]>
1 parent ef3ba0a commit 2a1771e

File tree

2 files changed

+280
-28
lines changed

2 files changed

+280
-28
lines changed

pom.xml

Lines changed: 180 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,24 @@
103103

104104
<!-- Plugins not managed by the JBoss parent POM: -->
105105
<maven-wrapper-plugin.version>3.3.2</maven-wrapper-plugin.version>
106+
<nexus-staging.plugin.version>1.7.0</nexus-staging.plugin.version>
107+
<flatten-maven-plugin.version>1.5.0</flatten-maven-plugin.version>
108+
109+
<!--
110+
We don't want to publish or sign any modules by default.
111+
Specific modules will override the setting at their own level.
112+
-->
113+
<deploy.skip>true</deploy.skip>
114+
<maven-deploy-plugin.skip>true</maven-deploy-plugin.skip>
115+
116+
<!-- Repository Deployment URLs -->
117+
<ossrh.releases.repo.id>ossrh</ossrh.releases.repo.id>
118+
<ossrh.releases.repo.name>Sonatype OSSRH Releases</ossrh.releases.repo.name>
119+
<ossrh.releases.repo.url>https://oss.sonatype.org/service/local/staging/deploy/maven2</ossrh.releases.repo.url>
120+
<ossrh.releases.repo.baseUrl>https://oss.sonatype.org</ossrh.releases.repo.baseUrl>
121+
<ossrh.snapshots.repo.id>ossrh</ossrh.snapshots.repo.id>
122+
<ossrh.snapshots.repo.name>Sonatype OSSRH Snapshots</ossrh.snapshots.repo.name>
123+
<ossrh.snapshots.repo.url>https://oss.sonatype.org/content/repositories/snapshots</ossrh.snapshots.repo.url>
106124

107125
<maven.compiler.target>11</maven.compiler.target>
108126
<maven.compiler.source>11</maven.compiler.source>
@@ -227,36 +245,17 @@
227245
</dependencies>
228246
</dependencyManagement>
229247

230-
<repositories>
248+
<distributionManagement>
231249
<repository>
232-
<snapshots>
233-
<enabled>false</enabled>
234-
</snapshots>
235-
<id>ossrh-releases-repository</id>
236-
<name>Sonatype OSSRH Releases</name>
237-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
250+
<id>${ossrh.releases.repo.id}</id>
251+
<name>${ossrh.releases.repo.name}</name>
252+
<url>${ossrh.releases.repo.url}</url>
238253
</repository>
239-
<repository>
240-
<snapshots>
241-
<enabled>true</enabled>
242-
</snapshots>
243-
<id>ossrh-snapshots-repository</id>
244-
<name>Sonatype OSSRH Snapshots</name>
245-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
246-
</repository>
247-
</repositories>
248-
249-
<distributionManagement>
250-
<repository>
251-
<id>ossrh-releases-repository</id>
252-
<name>Sonatype OSSRH Releases</name>
253-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
254-
</repository>
255-
<snapshotRepository>
256-
<id>ossrh-snapshots-repository</id>
257-
<name>Sonatype OSSRH Snapshots</name>
258-
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
259-
</snapshotRepository>
254+
<snapshotRepository>
255+
<id>${ossrh.snapshots.repo.id}</id>
256+
<name>${ossrh.snapshots.repo.name}</name>
257+
<url>${ossrh.snapshots.repo.url}</url>
258+
</snapshotRepository>
260259
</distributionManagement>
261260

262261
<build>
@@ -271,8 +270,161 @@
271270
<distributionType>bin</distributionType>
272271
</configuration>
273272
</plugin>
273+
<!-- Published artifacts have to be signed: -->
274+
<plugin>
275+
<groupId>org.apache.maven.plugins</groupId>
276+
<artifactId>maven-gpg-plugin</artifactId>
277+
<executions>
278+
<execution>
279+
<id>sign-artifacts</id>
280+
<phase>verify</phase>
281+
<goals>
282+
<goal>sign</goal>
283+
</goals>
284+
<configuration>
285+
<skip>${deploy.skip}</skip>
286+
<homedir>${env.RELEASE_GPG_HOMEDIR}</homedir>
287+
</configuration>
288+
</execution>
289+
</executions>
290+
</plugin>
291+
<plugin>
292+
<groupId>org.sonatype.plugins</groupId>
293+
<artifactId>nexus-staging-maven-plugin</artifactId>
294+
<version>${nexus-staging.plugin.version}</version>
295+
<extensions>false</extensions><!-- This is essential: do not put true here -->
296+
<configuration>
297+
<skipNexusStagingDeployMojo>${deploy.skip}</skipNexusStagingDeployMojo>
298+
<serverId>${ossrh.releases.repo.id}</serverId>
299+
<!-- The following, by default, is only used for actual releases, not for snapshot deployments -->
300+
<nexusUrl>${ossrh.releases.repo.baseUrl}</nexusUrl>
301+
<!-- oss.sonatype.org has been very slow when closing repositories lately;
302+
let's raise the timeout until we switch to s01.sonatype.org -->
303+
<stagingProgressTimeoutMinutes>60</stagingProgressTimeoutMinutes>
304+
</configuration>
305+
</plugin>
306+
<plugin>
307+
<groupId>org.codehaus.mojo</groupId>
308+
<artifactId>flatten-maven-plugin</artifactId>
309+
<version>${flatten-maven-plugin.version}</version>
310+
<configuration>
311+
<outputDirectory>${project.build.directory}</outputDirectory>
312+
<!-- Keep things like url, inceptionYear, authors...
313+
everything that's required by the OSSRH Maven repository -->
314+
<flattenMode>ossrh</flattenMode>
315+
<!-- To make sure that `hibernate-tools-gradle` module that has a pom packaging will also publish the flattened pom -->
316+
<updatePomFile>true</updatePomFile>
317+
</configuration>
318+
<executions>
319+
<execution>
320+
<id>flatten-pom</id>
321+
<phase>process-resources</phase>
322+
<goals>
323+
<goal>flatten</goal>
324+
</goals>
325+
</execution>
326+
</executions>
327+
</plugin>
274328
</plugins>
275329
</pluginManagement>
330+
<plugins>
331+
<!-- Skip the deploy plugin explicitly: we use nexus-staging-maven-plugin instead -->
332+
<plugin>
333+
<groupId>org.apache.maven.plugins</groupId>
334+
<artifactId>maven-deploy-plugin</artifactId>
335+
<configuration>
336+
<skip>${maven-deploy-plugin.skip}</skip>
337+
</configuration>
338+
</plugin>
339+
<!--
340+
Configure the nexus-staging-maven-plugin explicitly (without <extension>true</extension>)
341+
in order to work around a problem in the "reports" module (see that module's POM for more info).
342+
-->
343+
<plugin>
344+
<groupId>org.sonatype.plugins</groupId>
345+
<artifactId>nexus-staging-maven-plugin</artifactId>
346+
<executions>
347+
<execution>
348+
<id>default-deploy</id>
349+
<phase>deploy</phase>
350+
<goals>
351+
<!--
352+
This will only put artifacts in a staging directory.
353+
See the "reports" module for actual deployment, at the end of the build.
354+
-->
355+
<goal>deploy</goal>
356+
</goals>
357+
</execution>
358+
</executions>
359+
</plugin>
360+
<plugin>
361+
<groupId>org.codehaus.mojo</groupId>
362+
<artifactId>flatten-maven-plugin</artifactId>
363+
</plugin>
364+
<plugin>
365+
<groupId>org.apache.maven.plugins</groupId>
366+
<artifactId>maven-enforcer-plugin</artifactId>
367+
<executions>
368+
<execution>
369+
<id>enforce-java-version</id>
370+
<goals>
371+
<goal>enforce</goal>
372+
</goals>
373+
<configuration>
374+
<!--
375+
We want to override the rules for this configuration to remove the bannedRepositories rule from the JBoss parent.
376+
-->
377+
<rules combine.self="override">
378+
<requireJavaVersion>
379+
<message>To build this project JDK ${jdk.min.version} (or greater) is required. Please install it.</message>
380+
<version>${jdk.min.version}</version>
381+
</requireJavaVersion>
382+
</rules>
383+
</configuration>
384+
</execution>
385+
</executions>
386+
</plugin>
387+
</plugins>
276388
</build>
277389

390+
<profiles>
391+
<profile>
392+
<id>release</id>
393+
<activation>
394+
<property>
395+
<name>performRelease</name>
396+
<value>true</value>
397+
</property>
398+
</activation>
399+
<build>
400+
<plugins>
401+
<plugin>
402+
<groupId>org.apache.maven.plugins</groupId>
403+
<artifactId>maven-gpg-plugin</artifactId>
404+
</plugin>
405+
</plugins>
406+
</build>
407+
</profile>
408+
409+
<!--
410+
WARNING: this MUST be the very last profile,
411+
so that the "report" module is the very last module,
412+
in particular when deploying artifacts to a Nexus repository.
413+
See the "build/reports" module POM for more information.
414+
-->
415+
<profile>
416+
<id>build-reports-as-last-module</id>
417+
<activation>
418+
<property>
419+
<name>!some.property.that.will.never.exist</name>
420+
</property>
421+
</activation>
422+
<modules>
423+
<module>reports</module>
424+
</modules>
425+
</profile>
426+
427+
<!-- DO NOT ADD ANY PROFILE AFTER THIS: see above -->
428+
</profiles>
429+
278430
</project>

reports/pom.xml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2016 - 2024 Red Hat, Inc.
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" basis,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
18+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
19+
<modelVersion>4.0.0</modelVersion>
20+
<parent>
21+
<groupId>org.hibernate.tool</groupId>
22+
<artifactId>hibernate-tools-parent</artifactId>
23+
<version>6.4.11-SNAPSHOT</version>
24+
</parent>
25+
<artifactId>hibernate-tools-reports</artifactId>
26+
27+
<name>Hibernate Tools Reports</name>
28+
<description>Hibernate Tools build reports</description>
29+
<packaging>pom</packaging>
30+
31+
<dependencies>
32+
<dependency>
33+
<groupId>org.hibernate.tool</groupId>
34+
<artifactId>hibernate-tools-utils</artifactId>
35+
<version>${project.version}</version>
36+
</dependency>
37+
<dependency>
38+
<groupId>org.hibernate.tool</groupId>
39+
<artifactId>hibernate-tools-orm</artifactId>
40+
<version>${project.version}</version>
41+
</dependency>
42+
<dependency>
43+
<groupId>org.hibernate.tool</groupId>
44+
<artifactId>hibernate-tools-orm-jbt</artifactId>
45+
<version>${project.version}</version>
46+
</dependency>
47+
<dependency>
48+
<groupId>org.hibernate.tool</groupId>
49+
<artifactId>hibernate-tools-maven</artifactId>
50+
<version>${project.version}</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.hibernate.tool</groupId>
54+
<artifactId>hibernate-tools-gradle</artifactId>
55+
<version>${project.version}</version>
56+
</dependency>
57+
<dependency>
58+
<groupId>org.hibernate.tool</groupId>
59+
<artifactId>hibernate-tools-ant</artifactId>
60+
<version>${project.version}</version>
61+
</dependency>
62+
</dependencies>
63+
64+
<build>
65+
<plugins>
66+
<!--
67+
Hack to deploy in the "reports" module without deploying the "reports" module itself.
68+
The default lifecycle bindings of the plugin is to "stage locally" every artifact throughout
69+
the maven execution, and only actually deploy the "locally staged" artifacts
70+
in the very last executed module, which happens to be this "reports" module.
71+
However, this "reports" module does not generate any artifact we want to deploy.
72+
Thus, we'd like to prevent even its POM from being deployed: just deploy the "locally staged" artifacts,
73+
without adding the POM from the "reports" module to these artifacts.
74+
The default lifecycle bindings of the plugin does not offer a configuration option to do that,
75+
so we have to explicitly bind it
76+
-->
77+
<plugin>
78+
<groupId>org.sonatype.plugins</groupId>
79+
<artifactId>nexus-staging-maven-plugin</artifactId>
80+
<extensions>false</extensions>
81+
<!-- The <configuration> element is inherited from the parent module. -->
82+
<executions>
83+
<!-- Skip the default deployment, as explained above we don't want it. -->
84+
<execution>
85+
<id>default-deploy</id>
86+
<phase>none</phase>
87+
</execution>
88+
<!-- ... but execute the deferred deployment for the other modules -->
89+
<execution>
90+
<id>deferred-deploy</id>
91+
<phase>deploy</phase>
92+
<goals>
93+
<goal>deploy-staged</goal>
94+
</goals>
95+
</execution>
96+
</executions>
97+
</plugin>
98+
</plugins>
99+
</build>
100+
</project>

0 commit comments

Comments
 (0)