Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions .github/workflows/java-cloud-bom-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ jobs:
java-version: ${{matrix.java}}
cache: 'maven'
- run: java -version
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install modules locally
run: mvn install -B -ntp -Pquick-build -DskipTests=true -T 1C
- run: .kokoro/dependencies.sh
Expand All @@ -77,6 +79,8 @@ jobs:
java-version: 11
cache: maven
- run: java -version
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install modules locally
run: mvn install -B -ntp -Pquick-build -DskipTests=true -T 1C
- name: Install BOMs
Expand Down Expand Up @@ -107,6 +111,8 @@ jobs:
java-version: 11
cache: maven
- run: java -version
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install modules locally
run: mvn install -B -ntp -Pquick-build -DskipTests=true -T 1C
- name: Install BOMs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
java-version: 11
cache: maven
- run: java -version
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install modules locally
run: mvn install -B -ntp -Pquick-build -DskipTests=true -T 1C
- name: Pick Libraries BOM version
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/java-spanner-jdbc-quickperf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
distribution: temurin
java-version: 17
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Run tests
run: mvn test
working-directory: java-spanner-jdbc/samples/quickperf
2 changes: 2 additions & 0 deletions .github/workflows/java-spanner-jdbc-sample-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
distribution: temurin
java-version: 8
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Run sample tests
run: mvn --quiet --batch-mode test
working-directory: java-spanner-jdbc/samples/snippets
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
distribution: temurin
java-version: 17
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Run tests on GoogleSQL
run: mvn test
working-directory: java-spanner-jdbc/samples/spring-data-jdbc/googlesql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ jobs:
distribution: temurin
java-version: 17
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Run GoogleSQL sample tests
run: mvn test
working-directory: java-spanner-jdbc/samples/spring-data-mybatis/googlesql
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/sdk-platform-java-analyze_dependency.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
uses: stCarolas/setup-maven@07fbbe97d97ef44336b7382563d66743297e442f # v4.5
with:
maven-version: 3.8.2
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install dependency analyzer
shell: bash
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
java-version: 11
distribution: temurin
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- id: resolve-versions
name: Resolve Protobuf versions
env:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
java-version: 17
cache: maven
- run: java -version
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install maven modules
run: |
mvn install -B -ntp -DskipTests -Pquick-build
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/unmanaged_dependency_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ jobs:
distribution: temurin
java-version: 11
cache: maven
- name: Use GCP Maven Mirror
run: mkdir -p "${HOME}/.m2" && cp settings.xml "${HOME}/.m2/settings.xml"
- name: Install all modules
shell: bash
run: |
Expand Down
1 change: 1 addition & 0 deletions .kokoro/bigtable-conformance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh
setup_maven_mirror

# Print out Maven & Java version
mvn -version
Expand Down
5 changes: 1 addition & 4 deletions .kokoro/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh

# Use GCP Maven Mirror
mkdir -p ${HOME}/.m2
cp settings.xml ${HOME}/.m2
setup_maven_mirror

setup_application_credentials

Expand Down
4 changes: 4 additions & 0 deletions .kokoro/client-library-check-doclet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
## cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh
setup_maven_mirror

# Make artifacts available for 'mvn validate' at the bottom
pushd java-shared-config
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q --no-transfer-progress
Expand Down
4 changes: 4 additions & 0 deletions .kokoro/client-library-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
## cd to the parent directory, i.e. the root of the git repo
cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh
setup_maven_mirror

# Make artifacts available for 'mvn validate' at the bottom
pushd java-shared-config
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q
Expand Down
6 changes: 3 additions & 3 deletions .kokoro/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -564,15 +564,15 @@ function find_last_release_version {
echo "${parts[1]}"
}

# copies settings.xml from the root of sdk-platform-java into Maven's home
# folder
# copies settings.xml from the root of the repo into Maven's home folder
function setup_maven_mirror {
echo "Setup maven mirror"
mkdir -p "${HOME}/.m2"
cp "${commonScriptDir}/../settings.xml" "${HOME}/.m2"
cp "${commonScriptDir}/../settings.xml" "${HOME}/.m2/settings.xml"
}

function install_repo_modules {
setup_maven_mirror
target_projects="$1"
projects_arg=""
if [ -n "${target_projects}" ]; then
Expand Down
4 changes: 4 additions & 0 deletions .kokoro/dashboard.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ set -eo pipefail
scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh
setup_maven_mirror

outputFile="$scriptDir/../java-cloud-bom/dashboard/target/tmp/output.txt"

if [[ "${JOB_TYPE}" == "dashboard-units-check" ]]; then
Expand Down
1 change: 1 addition & 0 deletions .kokoro/dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cd ${scriptDir}/..

# include common functions
source ${scriptDir}/common.sh
setup_maven_mirror

# Print out Java
java -version
Expand Down
8 changes: 4 additions & 4 deletions .kokoro/presubmit/downstream-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
## cd to the parent directory, i.e. the root of the git repo
cd "${scriptDir}/../.."

# include common functions
source "${scriptDir}/../common.sh"
setup_maven_mirror

# Build and install the entire monorepo to local cache (including the under-test java-shared-config)
mvn -B -ntp install -Dcheckstyle.skip -Dfmt.skip -DskipTests

# Get the version of java-shared-config under test
VERSION_POM=java-shared-config/java-shared-config/pom.xml
SHARED_CONFIG_VERSION=$(sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -)

# Use GCP Maven Mirror (as in original script)
mkdir -p "${HOME}/.m2"
cp java-shared-config/settings.xml "${HOME}/.m2"

# Update the shared-config version in the local java-showcase parent
pushd java-showcase
modify_shared_config
Expand Down
23 changes: 0 additions & 23 deletions java-shared-config/settings.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ validate_protobuf_compatibility_script_inputs

monorepoRoot=$(realpath "${scriptDir}/../../..")

# Use GCP Maven Mirror from monorepo root
mkdir -p "${HOME}/.m2"
cp "${monorepoRoot}/settings.xml" "${HOME}/.m2/settings.xml"

# Declare a map of downstream handwritten libraries and the relevant artifacts to test. The map stores a
# K/V pairing of (Key: module name, Value: comma separate list of Group ID:Artifact ID pairings). Note: The
# value list doesn't hold the version and this needs to be parsed from the monorepo's versions.txt file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ validate_protobuf_compatibility_script_inputs

monorepoRoot=$(realpath "${scriptDir}/../../..")

# Use GCP Maven Mirror from monorepo root
mkdir -p "${HOME}/.m2"
cp "${monorepoRoot}/settings.xml" "${HOME}/.m2/settings.xml"

# MODULES_UNDER_TEST Env Var accepts a comma separated list of monorepo submodules to test. For Github CI,
# this will be a single module as Github will build a matrix of modules with each being tested in parallel.
# For local invocation, you can pass a list of modules to test multiple modules together.
Expand Down
6 changes: 3 additions & 3 deletions sdk-platform-java/.kokoro/presubmit/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ function find_last_release_version {
echo "${parts[1]}"
}

# copies settings.xml from the root of sdk-platform-java into Maven's home
# folder
# copies settings.xml from the root of the monorepo into Maven's home folder
function setup_maven_mirror {
echo "Setup maven mirror"
mkdir -p "${HOME}/.m2"
cp "${commonScriptDir}/../../settings.xml" "${HOME}/.m2"
cp "${commonScriptDir}/../../../settings.xml" "${HOME}/.m2/settings.xml"
}

function install_repo_modules {
setup_maven_mirror
target_projects="$1"
projects_arg=""
if [ -n "${target_projects}" ]; then
Expand Down
1 change: 1 addition & 0 deletions sdk-platform-java/.kokoro/presubmit/downstream-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fi
scriptDir=$(realpath "$(dirname "${BASH_SOURCE[0]}")")
cd "${scriptDir}/../.." # git repo root
source "$scriptDir/common.sh"
setup_maven_mirror

# Publish this repo's modules to local maven to make them available for downstream libraries
mvn install --projects '!gapic-generator-java' \
Expand Down
3 changes: 1 addition & 2 deletions sdk-platform-java/.kokoro/presubmit/showcase-native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ cd "${scriptDir}/../.." # git repo root
source "$scriptDir/common.sh"

# Use GCP Maven Mirror
mkdir -p "${HOME}/.m2"
cp settings.xml "${HOME}/.m2"
setup_maven_mirror

# Publish this repo's modules to local maven to make them available for downstream libraries
mvn install --projects '!gapic-generator-java' \
Expand Down
57 changes: 55 additions & 2 deletions settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,60 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<!-- This file contains settings used by .kokoro/build.sh. These are global
configs used by almost every build script.
<!--
Why we use an active <profile> with <repositories> instead of <mirrors>:

1. Exclusive Proxy Limitation of <mirrors>:
In Maven, a <mirrorOf> tag acts as an exclusive 1:1 replacement/proxy for a repository.
If an artifact returns 404 from the mirror (e.g. due to replication lag for brand-new
releases published to Maven Central minutes ago), Maven treats Central as exhausted
and immediately fails the build without querying Central root.

2. Prioritized Search Chain with Automatic Fallback:
By declaring the Google Cloud Storage mirror inside an active <profile> as a <repository>
and <pluginRepository>, Maven prepends the GCS mirror to its search list ahead of the
built-in Super POM's 'central' repository:
1. Local cache & reactor (~/.m2/repository)
2. 'google-maven-central' (GCS CDN mirror, serving ~99% of requests without 429 rate limits)
3. 'central' (https://repo.maven.apache.org/maven2 - queried automatically if missing from GCS)

3. settings.xml Schema Requirement:
In Maven's settings.xml specification, <repositories> cannot be declared directly at
the root <settings> level and must reside within <profiles><profile>. The <activeProfiles>
block below ensures this profile is unconditionally active for every build.
-->
<profiles>
<profile>
<id>google-maven-mirror</id>
<repositories>
<repository>
<id>google-maven-central</id>
<name>Google Maven Central Mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@suztomo I remember we decided not to use Google mirror at some point. What was the rational?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It's b/418098560.

<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>google-maven-central</id>
<name>Google Maven Central Mirror</name>
<url>https://maven-central.storage-download.googleapis.com/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>google-maven-mirror</activeProfile>
</activeProfiles>
</settings>
Loading