Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: GAPIC library BOM in monorepo_script bootstrap #7991

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,12 @@ For Day 1 cutover, once we have main branch:
- Update `googleapis_commit.txt` to an appropriate value
- Update `.github/workflows/googleapis_hermetic_sync.yaml` to point to
the main branch.

### The BOM coverage and its version

Review the artifact name "google-cloud-gapic-bom" in the bom directory and
configure the version managed by Release Please. Ensure the BOM is part of the
entire release pipeline.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ddixit14 This message is for you in near future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will keep this in mind.


Confirm the effective-pom (`mvn help:effective-pom`) of the BOM covers the same
member of the google-cloud-bom except the handwritten libraries.
90 changes: 90 additions & 0 deletions bom.pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?xml version='1.0' encoding='UTF-8'?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-gapic-bom</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-gapic-bom:current} -->
<name>Google Cloud Java BOM</name>
<url>https://github.com/googleapis/java-cloud-bom</url>
<description>
BOM for the libraries in google-cloud-java repository. Users should not
depend on this artifact explicitly because this BOM is an implementation
detail of the Libraries BOM.
</description>
<dependencyManagement>
BOM_ARTIFACT_LIST
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably need <dependencies> before the placeholder, and a closing one after.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the check failed with Error: Malformed POM /home/runner/work/google-cloud-java/google-cloud-java/monorepo/google-cloud-java/bom/pom.xml: Unrecognised tag: 'dependency' (position: START_TAG seen ...<dependencyManagement>\n <dependency>... @16:17) @ /home/runner/work/google-cloud-java/google-cloud-java/monorepo/google-cloud-java/bom/pom.xml, line 16, column 17.

</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.13</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype-nexus-staging</serverId>
<nexusUrl>https://google.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.12.0</version>
<configuration>
<skipDeploy>true</skipDeploy>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>release</id>
<activation>
<property>
<name>performRelease</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
39 changes: 39 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,42 @@ awk -v MODULE=' <module>CoverageAggregator</module>' '/<\/modules>/{print MOD

git add --all
git commit -am 'feat: create CoverageAggregator module'

# generate BOM of the artifacts in this repository
bom_lines=""
for bom_directory in $(find . -name 'google-*-bom' | sort); do
pom_file="${bom_directory}/pom.xml"
groupId_line=$(grep --max-count=1 'groupId' "${pom_file}")
artifactId_line=$(grep --max-count=1 'artifactId' "${pom_file}")
version_line=$(grep --max-count=1 'x-version-update' "${pom_file}")

if [[ $version_line == *"<version>0"* ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another method is to read the .repo-metadata.json for each library, which specifies whether it's preview or not. It might be more reliable. Also, why not do this in the main loop above where we iterate over repos.txt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea.

why not do this in the main loop above where we iterate over repos.txt?

I feel it's better to split the logic of BOM generation as separate one. No technical reason.

# Not including non-GA libraries, except those that happened to be included
# already in google-cloud-bom.
if [[ $artifactId_line != *"google-cloud-datalabeling"* ]] \
&& [[ $artifactId_line != *"google-cloud-errorreporting"* ]] \
&& [[ $artifactId_line != *"google-cloud-logging-logback"* ]] \
&& [[ $artifactId_line != *"google-cloud-mediatranslation"* ]] \
&& [[ $artifactId_line != *"google-cloud-nio"* ]] \
&& [[ $artifactId_line != *"google-cloud-notification"* ]] \
&& [[ $artifactId_line != *"google-cloud-phishingprotection"* ]]; then
continue
fi
fi

bom_lines+=" <dependency>
${groupId_line}
${artifactId_line}
${version_line}
<type>pom</type>
<scope>import</scope>
</dependency>
"
done

mkdir bom
awk -v "dependencyManagements=$bom_lines" '{gsub(/BOM_ARTIFACT_LIST/,dependencyManagements)}1' \
../../bom.pom.xml > bom/pom.xml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The directly should match the artifact name if possible: google-cloud-gapic-bom.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.


git add bom/pom.xml
git commit -am 'feat: create bom module'
1 change: 1 addition & 0 deletions parent.pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
</properties>

<modules>
<module>bom</module>
</modules>

<build>
Expand Down