From d250eadcde8ecf7d3e2904d0637f8b502fe6f4d9 Mon Sep 17 00:00:00 2001 From: jialiang <2510095164@qq.com> Date: Wed, 31 Jan 2024 12:25:31 +0800 Subject: [PATCH] BIGTOP-4061: Improve support for Maven parallel build parameters (#1233) --- README.md | 4 +--- packages.gradle | 14 +++++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 09581822af..0ca23efe21 100644 --- a/README.md +++ b/README.md @@ -188,9 +188,7 @@ __On all systems, Building Apache Bigtop requires certain set of tools__ * __Enabling Parallel Build for packages(BIGTOP-4044)__ - Apache Bigtop defaults to non-parallel builds. Use -PbuildThreads=2C to activate Maven's parallel build feature and expedite compilation for compatible components. - - Append a digit and 'C' to -PbuildThreads= to set the CPU core count for concurrent builds. + Apache Bigtop defaults to non-parallel builds. Use -PbuildThreads with a number or a combination of numbers followed by 'C', such as '-PbuildThreads=2' or '-PbuildThreads=2C', to specify the number of CPU cores for Maven's parallel build feature, which can speed up the compilation process for compatible components. Consult the bigtop.bom file to verify component compatibility with parallel builds; those marked with maven_parallel_build = true support this option. diff --git a/packages.gradle b/packages.gradle index d78c47c770..b95f42d4c1 100644 --- a/packages.gradle +++ b/packages.gradle @@ -87,7 +87,7 @@ def generatePatch(String threadCount, String path) { --- a/.mvn/maven.config +++ b/.mvn/maven.config @@ -0,0 +1 @@ - +-T${threadCount} + +-T ${threadCount} \\ No newline at end of file """.stripIndent() @@ -97,6 +97,10 @@ def generatePatch(String threadCount, String path) { } } +def isValidMavenBuildThreads(threads) { + return threads.matches("\\d+C") || threads.matches("\\d+") +} + /** * To avoid breaking the compat with existing packages let's use the old style names */ @@ -453,8 +457,8 @@ def genTasks = { target -> into "$DEB_BLD_DIR/debian" } if (MAVEN_BUILD_THREADS && ENABLE_MAVEN_PARALLEL_BUILD) { - if (!MAVEN_BUILD_THREADS.matches("\\d+C")) { - throw new GradleException("Invalid MAVEN_BUILD_THREADS parameter. It must be a combination of numbers and 'C', such as '2C'.") + if (!isValidMavenBuildThreads(MAVEN_BUILD_THREADS)) { + throw new GradleException("Invalid MAVEN_BUILD_THREADS parameter. It must be either a number or a combination of numbers followed by 'C', such as '2' or '2C'.") } generatePatch(MAVEN_BUILD_THREADS, "$DEB_BLD_DIR/debian") } @@ -642,8 +646,8 @@ def genTasks = { target -> into "$PKG_BUILD_DIR/rpm/SOURCES" } if (MAVEN_BUILD_THREADS && ENABLE_MAVEN_PARALLEL_BUILD) { - if (!MAVEN_BUILD_THREADS.matches("\\d+C")) { - throw new GradleException("Invalid MAVEN_BUILD_THREADS parameter. It must be a combination of numbers and 'C', such as '2C'.") + if (!isValidMavenBuildThreads(MAVEN_BUILD_THREADS)) { + throw new GradleException("Invalid MAVEN_BUILD_THREADS parameter. It must be either a number or a combination of numbers followed by 'C', such as '2' or '2C'.") } generatePatch(MAVEN_BUILD_THREADS, "$PKG_BUILD_DIR/rpm/SOURCES") }