From e2516352c82e15df75d4c560fbbd29b2d3734c77 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Wed, 23 Oct 2024 10:44:09 +0200 Subject: [PATCH] Fix publishing of the BOM artifact Signed-off-by: Fabio Di Fabio --- build.gradle | 68 ++++++++++++++++++++++++++----------------- platform/build.gradle | 3 +- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 74520552e9d..5d7735adae2 100644 --- a/build.gradle +++ b/build.gradle @@ -514,7 +514,14 @@ subprojects { return result } - if (sourceSetIsPopulated("main") || sourceSetIsPopulated("testSupport")) { + def hasPlugin = { pluginName -> + def result = project.getPluginManager().hasPlugin(pluginName) + def projectName = project.name + logger.info("Project = " + projectName + (result ? " has" : "has not") + " plugin " + pluginName) + return result + } + + if (hasPlugin("java-platform") || sourceSetIsPopulated("main") || sourceSetIsPopulated("testSupport")) { apply plugin: 'maven-publish' publishing { @@ -528,36 +535,42 @@ subprojects { } } } + publications { - mavenJava(MavenPublication) { - groupId "io.consensys.linea-besu.internal" - version "${project.version}" - if (sourceSetIsPopulated("main")) { - from components.java - artifact sourcesJar - artifact javadocJar - } + if(!hasPlugin("java-platform")) { - if (sourceSetIsPopulated("testSupport")) { - artifact testSupportJar - } - versionMapping { - usage('java-api') { fromResolutionOf('runtimeClasspath') } - usage('java-runtime') { fromResolutionResult() } - } - pom { - name = "Linea Besu - ${project.name}" - url = 'https://github.com/ConsenSys/linea-besu' - licenses { - license { - name = 'The Apache License, Version 2.0' - url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' - } + mavenJava(MavenPublication) { + groupId "io.consensys.linea-besu.internal" + version "${project.version}" + + if (sourceSetIsPopulated("main")) { + from components.java + artifact sourcesJar + artifact javadocJar + } + + if (sourceSetIsPopulated("testSupport")) { + artifact testSupportJar + } + + versionMapping { + usage('java-api') { fromResolutionOf('runtimeClasspath') } + usage('java-runtime') { fromResolutionResult() } } - scm { - connection = 'scm:git:git://github.com/ConsenSys/linea-besu.git' - developerConnection = 'scm:git:ssh://github.com/ConsenSys/linea-besu.git' + pom { + name = "Linea Besu - ${project.name}" url = 'https://github.com/ConsenSys/linea-besu' + licenses { + license { + name = 'The Apache License, Version 2.0' + url = 'http://www.apache.org/licenses/LICENSE-2.0.txt' + } + } + scm { + connection = 'scm:git:git://github.com/ConsenSys/linea-besu.git' + developerConnection = 'scm:git:ssh://github.com/ConsenSys/linea-besu.git' + url = 'https://github.com/ConsenSys/linea-besu' + } } } } @@ -565,6 +578,7 @@ subprojects { } } + tasks.withType(Test) { // If GRADLE_MAX_TEST_FORKS is not set, use half the available processors maxParallelForks = (System.getenv('GRADLE_MAX_TEST_FORKS') ?: (Runtime.runtime.availableProcessors().intdiv(2) ?: 1)).toInteger() diff --git a/platform/build.gradle b/platform/build.gradle index 489e1cd8ef4..d91497d7cd3 100644 --- a/platform/build.gradle +++ b/platform/build.gradle @@ -189,10 +189,9 @@ publishing { publications { mavenPlatform(MavenPublication) { from components.javaPlatform - groupId "io.consensys.linea-besu" + groupId 'io.consensys.linea-besu' artifactId 'bom' version calculateVersion() - pom { name = "Linea Besu BOM" url = 'https://github.com/ConsenSys/linea-besu'