Skip to content

Commit 44f21cd

Browse files
jDramaixcopybara-github
authored andcommitted
Refactor sonatype deployment script to use maven for packaging and deployment.
This cl introduces/configures differents maven plugins to achieve its goal: - maven-jar-plugin: to build the jar file from classes present on the file system instead of using file classes coming from the maven compile step. - build-helper-maven-plugin: to attach source and javadoc jars as maven artifacts. - maven-gpg-plugin: to sign all the maven artifacts before deployment - nexus-staging-maven-plugin: to deploy the artifacts to sonatype. Note that plugin is still configured to deploy to the legacy OSSRH sonatype repo. Change needed to deploy to central,sonatype will be provided in a follow-up cl. The plugin configuration will be shared between projects. This cl also: - simplify bazel build by automatically constructing file paths and bazel targets, - add `sonatype-auto-release` option to automatically release the artifacts after deployment allowing using the script in a CI context. PiperOrigin-RevId: 780912766
1 parent e7016d3 commit 44f21cd

File tree

2 files changed

+216
-154
lines changed

2 files changed

+216
-154
lines changed

maven/build_section.xml

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<properties>
2+
<classesDirectory>${project.artifactId}-classes</classesDirectory>
3+
<javadocFile>${project.artifactId}-javadoc.jar</javadocFile>
4+
<sourcesFile>${project.artifactId}-sources.jar</sourcesFile>
5+
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
6+
</properties>
7+
8+
<build>
9+
<plugins>
10+
<plugin>
11+
<groupId>org.apache.maven.plugins</groupId>
12+
<artifactId>maven-jar-plugin</artifactId>
13+
<version>3.4.2</version>
14+
<configuration>
15+
<classesDirectory>${classesDirectory}</classesDirectory>
16+
</configuration>
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.codehaus.plexus</groupId>
20+
<artifactId>plexus-io</artifactId>
21+
<!-- We need at least 3.5.1 to avoid https://github.com/codehaus-plexus/plexus-io/issues/109. Once we upgrade maven-jar-plugin itself to a version new enough to depend on 3.5.1 or higher, we can remove this override. -->
22+
<version>3.5.1</version>
23+
</dependency>
24+
</dependencies>
25+
</plugin>
26+
<plugin>
27+
<groupId>org.codehaus.mojo</groupId>
28+
<artifactId>build-helper-maven-plugin</artifactId>
29+
<version>1.9.1</version>
30+
<executions>
31+
<execution>
32+
<id>attach-artifacts</id>
33+
<phase>package</phase>
34+
<goals>
35+
<goal>attach-artifact</goal>
36+
</goals>
37+
<configuration>
38+
<artifacts>
39+
<artifact>
40+
<file>${javadocFile}</file>
41+
<type>jar</type>
42+
<classifier>javadoc</classifier>
43+
</artifact>
44+
<artifact>
45+
<file>${sourcesFile}</file>
46+
<type>jar</type>
47+
<classifier>sources</classifier>
48+
</artifact>
49+
</artifacts>
50+
</configuration>
51+
</execution>
52+
</executions>
53+
</plugin>
54+
<plugin>
55+
<groupId>org.apache.maven.plugins</groupId>
56+
<artifactId>maven-gpg-plugin</artifactId>
57+
<version>3.2.7</version>
58+
<executions>
59+
<execution>
60+
<id>sign-artifacts</id>
61+
<phase>verify</phase>
62+
<goals>
63+
<goal>sign</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
<plugin>
69+
<groupId>org.sonatype.plugins</groupId>
70+
<artifactId>nexus-staging-maven-plugin</artifactId>
71+
<version>1.7.0</version>
72+
<extensions>true</extensions>
73+
<configuration>
74+
<serverId>ossrh</serverId>
75+
<nexusUrl>${nexusUrl}</nexusUrl>
76+
</configuration>
77+
</plugin>
78+
</plugins>
79+
</build>

0 commit comments

Comments
 (0)