You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by yh...@apache.org on 2024/10/17 16:52:15 UTC
(beam) 01/01: Using single temp maven local repository for release validation tasks
This is an automated email from the ASF dual-hosted git repository.
yhu pushed a commit to branch sharedmaven
in repository https://gitbox.apache.org/repos/asf/beam.git
commit b2df5f2ca61d6941778f420426f235471bf7f401
Author: Yi Hu <ya...@google.com>
AuthorDate: Thu Oct 17 12:51:58 2024 -0400
Using single temp maven local repository for release validation tasks
---
.../workflows/beam_PostRelease_NightlySnapshot.yml | 7 ++++
.../org/apache/beam/gradle/BeamModulePlugin.groovy | 8 +++++
release/src/main/groovy/TestScripts.groovy | 38 ++++++++++++++--------
3 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/.github/workflows/beam_PostRelease_NightlySnapshot.yml b/.github/workflows/beam_PostRelease_NightlySnapshot.yml
index 9b7fb2af2f2..0c4144af1a4 100644
--- a/.github/workflows/beam_PostRelease_NightlySnapshot.yml
+++ b/.github/workflows/beam_PostRelease_NightlySnapshot.yml
@@ -59,6 +59,9 @@ jobs:
uses: ./.github/actions/setup-environment-action
with:
java-version: default
+ - name: Setup temp local maven
+ id: setup_local_maven
+ run: echo "NEW_TEMP_DIR=$(mktemp -d)" >> $GITHUB_OUTPUT
- name: run PostRelease validation script
uses: ./.github/actions/gradle-command-self-hosted-action
with:
@@ -66,3 +69,7 @@ jobs:
arguments: |
-Pver='${{ github.event.inputs.RELEASE }}' \
-Prepourl='${{ github.event.inputs.SNAPSHOT_URL }}' \
+ -PmavenLocalPath='${{ steps.setup_local_maven.outputs.NEW_TEMP_DIR }}'
+ - name: Clean up local maven
+ if: steps.setup_local_maven.outcome == 'success'
+ run: rm -rf '${{ steps.setup_local_maven.outputs.NEW_TEMP_DIR }}'
diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
index dd3b129e6c3..988ab514a4d 100644
--- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
@@ -239,6 +239,9 @@ class BeamModulePlugin implements Plugin<Project> {
// pubsubTopic sets topics when executing streaming pipelines
String pubsubTopic
+
+ // Optional maven local path (absolute path does not include ".m2/repository"
+ String mavenLocalPath
}
// Reads and contains all necessary performance test parameters
@@ -2513,6 +2516,8 @@ class BeamModulePlugin implements Plugin<Project> {
def taskName = "run${config.type}Java${config.runner}"
def releaseVersion = project.findProperty('ver') ?: project.version
def releaseRepo = project.findProperty('repourl') ?: 'https://repository.apache.org/content/repositories/snapshots'
+ // shared maven local path for maven archetype projects
+ def sharedMavenLocal = project.findProperty('mavenLocalPath') ?: ''
def argsNeeded = [
"--ver=${releaseVersion}",
"--repourl=${releaseRepo}"
@@ -2532,6 +2537,9 @@ class BeamModulePlugin implements Plugin<Project> {
if (config.pubsubTopic) {
argsNeeded.add("--pubsubTopic=${config.pubsubTopic}")
}
+ if (sharedMavenLocal) {
+ argsNeeded.add("--mavenLocalPath=${sharedMavenLocal}")
+ }
project.evaluationDependsOn(':release')
project.task(taskName, dependsOn: ':release:classes', type: JavaExec) {
group = "Verification"
diff --git a/release/src/main/groovy/TestScripts.groovy b/release/src/main/groovy/TestScripts.groovy
index d5042aa6194..dc2438007ac 100644
--- a/release/src/main/groovy/TestScripts.groovy
+++ b/release/src/main/groovy/TestScripts.groovy
@@ -36,6 +36,7 @@ class TestScripts {
static String gcsBucket
static String bqDataset
static String pubsubTopic
+ static String mavenLocalPath
}
def TestScripts(String[] args) {
@@ -47,6 +48,7 @@ class TestScripts {
cli.gcsBucket(args:1, 'Google Cloud Storage Bucket')
cli.bqDataset(args:1, "BigQuery Dataset")
cli.pubsubTopic(args:1, "PubSub Topic")
+ cli.mavenLocalPath(args:1, "Maven local path")
def options = cli.parse(args)
var.repoUrl = options.repourl
@@ -73,6 +75,10 @@ class TestScripts {
var.pubsubTopic = options.pubsubTopic
println "PubSub Topic: ${var.pubsubTopic}"
}
+ if (options.mavenLocalPath) {
+ var.mavenLocalPath = options.mavenLocalPath
+ println "Maven local path: ${var.mavenLocalPath}"
+ }
}
def ver() {
@@ -189,11 +195,16 @@ class TestScripts {
}
}
- // Run a maven command, setting up a new local repository and a settings.xml with a custom repository
+ // Run a maven command, setting up a new local repository and a settings.xml with a custom repository if needed
private String _mvn(String args) {
- def m2 = new File(var.startDir, ".m2/repository")
+ String mvnlocalPath = var.mavenLocalPath
+ if (!(var.mavenLocalPath)) {
+ mvnlocalPath = var.startDir
+ }
+ def m2 = new File(mvnlocalPath, ".m2/repository")
m2.mkdirs()
- def settings = new File(var.startDir, "settings.xml")
+ def settings = new File(mvnlocalPath, "settings.xml")
+ if(!settings.exists()) {
settings.write """
<settings>
<localRepository>${m2.absolutePath}</localRepository>
@@ -209,16 +220,17 @@ class TestScripts {
</profile>
</profiles>
</settings>
- """
- def cmd = "mvn ${args} -s ${settings.absolutePath} -Ptestrel -B"
- String path = System.getenv("PATH");
- // Set the path on jenkins executors to use a recent maven
- // MAVEN_HOME is not set on some executors, so default to 3.5.2
- String maven_home = System.getenv("MAVEN_HOME") ?: '/home/jenkins/tools/maven/apache-maven-3.5.4'
- println "Using maven ${maven_home}"
- def mvnPath = "${maven_home}/bin"
- def setPath = "export PATH=\"${mvnPath}:${path}\" && "
- return _execute(setPath + cmd)
+ """
+ }
+ def cmd = "mvn ${args} -s ${settings.absolutePath} -Ptestrel -B"
+ String path = System.getenv("PATH");
+ // Set the path on jenkins executors to use a recent maven
+ // MAVEN_HOME is not set on some executors, so default to 3.5.2
+ String maven_home = System.getenv("MAVEN_HOME") ?: '/usr/local/maven'
+ println "Using maven ${maven_home}"
+ def mvnPath = "${maven_home}/bin"
+ def setPath = "export PATH=\"${mvnPath}:${path}\" && "
+ return _execute(setPath + cmd)
}
// Clean up and report error