From 3114907ecc2646c28b9ad56ecd441933a839ed72 Mon Sep 17 00:00:00 2001 From: Lennon Scariano Date: Wed, 21 Jan 2026 17:17:25 -0500 Subject: [PATCH 1/3] cleanup check, add conditional for publishing to github --- common.gradle | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/common.gradle b/common.gradle index 43a41daae..d7bd672b5 100644 --- a/common.gradle +++ b/common.gradle @@ -294,20 +294,6 @@ subprojects { assemble.dependsOn osgi - tasks.register('prePublish') { - if (System.getenv("GITHUB_ACTOR") == null) { - throw new Exception("Environment variable GITHUB_ACTOR not set. Please set to your github username.") - } - - if (System.getenv("GITHUB_TOKEN") == null) { - throw new Exception("Environment variable GITHUB_TOKEN not set. Please generate and set to your personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") - } - } - - tasks.named('publish') { // This is a lifecycle task that runs all publish tasks - dependsOn 'prePublish' - } - // do stuff at the end in case subprojects add extra info afterEvaluate { project -> @@ -381,6 +367,30 @@ subprojects { } } } + + project.tasks.named("generateMetadataFileForMavenJavaPublication") { + if (System.getenv("GITHUB_ACTOR") == null) { + throw new Exception("Environment variable GITHUB_ACTOR not set. Please set to your github username.") + } + + if (System.getenv("GITHUB_TOKEN") == null) { + throw new Exception("Environment variable GITHUB_TOKEN not set. Please generate and set to your personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") + } + } + + p.tasks.named("publishMavenJavaPublicationToGitHubPackagesRepository") { + onlyIf { + // + MavenArtifactRepository repo = repository as MavenArtifactRepository; + MavenPublication pub = publication as MavenPublication; + + HttpURLConnection connection = new URL("$repo.url/${pub.groupId.replace('.', '/')}/$pub.artifactId/$pub.version/$pub.artifactId-${pub.version}.jar").openConnection(); + connection.setRequestMethod("GET"); + connection.setRequestProperty("Authorization", "Basic ${new String(Base64.getEncoder().encode("$repo.credentials.username:$repo.credentials.password".bytes))}"); + connection.connect(); + return connection.responseCode == 404; + } + } } // disable jar task if no source is included From 30c40098d4788b931c0b0b945d0229c8c251de66 Mon Sep 17 00:00:00 2001 From: Lennon Scariano Date: Wed, 21 Jan 2026 17:17:46 -0500 Subject: [PATCH 2/3] fix name --- common.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common.gradle b/common.gradle index d7bd672b5..c3d857d13 100644 --- a/common.gradle +++ b/common.gradle @@ -378,7 +378,7 @@ subprojects { } } - p.tasks.named("publishMavenJavaPublicationToGitHubPackagesRepository") { + project.tasks.named("publishMavenJavaPublicationToGitHubPackagesRepository") { onlyIf { // MavenArtifactRepository repo = repository as MavenArtifactRepository; From eed4ed79c6b386e1de8c67f969043737341491f6 Mon Sep 17 00:00:00 2001 From: Lennon Scariano Date: Wed, 21 Jan 2026 17:20:02 -0500 Subject: [PATCH 3/3] add back dofirst --- common.gradle | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/common.gradle b/common.gradle index c3d857d13..ac2f00342 100644 --- a/common.gradle +++ b/common.gradle @@ -369,12 +369,14 @@ subprojects { } project.tasks.named("generateMetadataFileForMavenJavaPublication") { - if (System.getenv("GITHUB_ACTOR") == null) { - throw new Exception("Environment variable GITHUB_ACTOR not set. Please set to your github username.") - } - - if (System.getenv("GITHUB_TOKEN") == null) { - throw new Exception("Environment variable GITHUB_TOKEN not set. Please generate and set to your personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") + doFirst { + if (System.getenv("GITHUB_ACTOR") == null) { + throw new Exception("Environment variable GITHUB_ACTOR not set. Please set to your github username.") + } + + if (System.getenv("GITHUB_TOKEN") == null) { + throw new Exception("Environment variable GITHUB_TOKEN not set. Please generate and set to your personal access token: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens") + } } }