Skip to content

Commit 7ccb2fc

Browse files
authored
ci: wrap nexus-staging-maven-plugin in a profile (#2585)
The nexus-staging-maven-plugin extension is wrapped by a profile "release-sonatype" because the extension interferes with maven-deploy-plugin. Example error: `[ERROR] Failed to execute goal org.sonatype.plugins:nexus-staging-maven-plugin:1.7.0:deploy (injected-nexus-deploy) on project google-api-client-bom: Execution injected-nexus-deploy of goal org.sonatype.plugins:nexus-staging-maven-plugin:1.7.0:deploy failed: Server credentials with ID "sonatype-nexus-staging" not found! -> [Help 1]` We use maven-deploy-plugin to upload artifacts to Artifact Registry, as well as to locally create bundle for Central Portal API. This follows googleapis/google-oauth-java-client@8e6ce3a.
1 parent 1445323 commit 7ccb2fc

File tree

2 files changed

+93
-15
lines changed

2 files changed

+93
-15
lines changed

google-api-client-bom/pom.xml

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,6 @@
110110
</dependencyManagement>
111111
<build>
112112
<plugins>
113-
<plugin>
114-
<groupId>org.sonatype.plugins</groupId>
115-
<artifactId>nexus-staging-maven-plugin</artifactId>
116-
<version>1.7.0</version>
117-
<extensions>true</extensions>
118-
<configuration>
119-
<serverId>sonatype-nexus-staging</serverId>
120-
<nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
121-
<autoReleaseAfterClose>false</autoReleaseAfterClose>
122-
</configuration>
123-
</plugin>
124113
<plugin>
125114
<groupId>org.apache.maven.plugins</groupId>
126115
<artifactId>maven-javadoc-plugin</artifactId>
@@ -157,6 +146,57 @@
157146
</build>
158147

159148
<profiles>
149+
<!-- Because the BOM artifact does not need to inherit other properties such as dependencies
150+
in the root pom.xml, this needs to define publication-related profiles. -->
151+
<profile>
152+
<!-- By default, we release artifacts to Sonatype, which requires
153+
nexus-staging-maven-plugin. -->
154+
<id>release-sonatype</id>
155+
<activation>
156+
<property>
157+
<!-- Only when we use the release-gcp-artifact-registry profile,
158+
which comes with artifact-registry-url property, this profile is
159+
turned off. -->
160+
<name>!artifact-registry-url</name>
161+
</property>
162+
</activation>
163+
<build>
164+
<plugins>
165+
<plugin>
166+
<groupId>org.sonatype.plugins</groupId>
167+
<artifactId>nexus-staging-maven-plugin</artifactId>
168+
<version>1.6.13</version>
169+
<extensions>true</extensions>
170+
<configuration>
171+
<serverId>sonatype-nexus-staging</serverId>
172+
<nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
173+
<autoReleaseAfterClose>false</autoReleaseAfterClose>
174+
</configuration>
175+
</plugin>
176+
</plugins>
177+
</build>
178+
</profile>
179+
<profile>
180+
<!-- Optionally, we can publish the artifacts to GCP Artifact Registry specifying
181+
this release-gcp-artifact-registry profile:
182+
mvn deploy -P=release-gcp-artifact-registry -P=-release-sonatype \
183+
-Dartifact-registry-url=artifactregistry://us-maven.pkg.dev/...
184+
-->
185+
<id>release-gcp-artifact-registry</id>
186+
<properties>
187+
<artifact-registry-url>artifactregistry://please-define-artifact-registry-url-property</artifact-registry-url>
188+
</properties>
189+
<distributionManagement>
190+
<repository>
191+
<id>gcp-artifact-registry-repository</id>
192+
<url>${artifact-registry-url}</url>
193+
</repository>
194+
<snapshotRepository>
195+
<id>gcp-artifact-registry-repository</id>
196+
<url>${artifact-registry-url}</url>
197+
</snapshotRepository>
198+
</distributionManagement>
199+
</profile>
160200
<profile>
161201
<id>release-sign-artifacts</id>
162202
<activation>

pom.xml

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,6 @@
505505
</execution>
506506
</executions>
507507
</plugin>
508-
<plugin>
509-
<groupId>org.sonatype.plugins</groupId>
510-
<artifactId>nexus-staging-maven-plugin</artifactId>
511-
</plugin>
512508
<plugin>
513509
<groupId>com.coveo</groupId>
514510
<artifactId>fmt-maven-plugin</artifactId>
@@ -722,5 +718,47 @@
722718
</plugins>
723719
</build>
724720
</profile>
721+
<profile>
722+
<!-- By default, we release artifacts to Sonatype, which requires
723+
nexus-staging-maven-plugin. -->
724+
<id>release-sonatype</id>
725+
<activation>
726+
<property>
727+
<!-- Only when we use the release-gcp-artifact-registry profile,
728+
which comes with artifact-registry-url property, this profile is
729+
turned off. -->
730+
<name>!artifact-registry-url</name>
731+
</property>
732+
</activation>
733+
<build>
734+
<plugins>
735+
<plugin>
736+
<groupId>org.sonatype.plugins</groupId>
737+
<artifactId>nexus-staging-maven-plugin</artifactId>
738+
</plugin>
739+
</plugins>
740+
</build>
741+
</profile>
742+
<profile>
743+
<!-- Optionally, we can publish the artifacts to GCP Artifact Registry specifying
744+
this release-gcp-artifact-registry profile:
745+
mvn deploy -P=release-gcp-artifact-registry -P=-release-sonatype \
746+
-Dartifact-registry-url=artifactregistry://us-maven.pkg.dev/...
747+
-->
748+
<id>release-gcp-artifact-registry</id>
749+
<properties>
750+
<artifact-registry-url>artifactregistry://please-define-artifact-registry-url-property</artifact-registry-url>
751+
</properties>
752+
<distributionManagement>
753+
<repository>
754+
<id>gcp-artifact-registry-repository</id>
755+
<url>${artifact-registry-url}</url>
756+
</repository>
757+
<snapshotRepository>
758+
<id>gcp-artifact-registry-repository</id>
759+
<url>${artifact-registry-url}</url>
760+
</snapshotRepository>
761+
</distributionManagement>
762+
</profile>
725763
</profiles>
726764
</project>

0 commit comments

Comments
 (0)