From 4c6c7835e2a3ad8e4d5ce783f4afd4e1dbdc7d62 Mon Sep 17 00:00:00 2001 From: Marc Boehm Date: Fri, 25 Oct 2024 14:38:22 +0200 Subject: [PATCH] CAPAUT-471 Refactor error handling to avoid broken builds --- gradle/build-mavenpublish.gradle | 48 ++++++++++++++++---------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/gradle/build-mavenpublish.gradle b/gradle/build-mavenpublish.gradle index e43a0ff..ab598aa 100644 --- a/gradle/build-mavenpublish.gradle +++ b/gradle/build-mavenpublish.gradle @@ -21,34 +21,34 @@ project.ext { mavenRepositoryUrl = ( project.hasProperty('MAVEN_PUBLISH_REPOSITORY_URL') ? MAVEN_PUBLISH_REPOSITORY_URL : null ) } -// Fail fast -if ( mavenAccessToken == null || mavenRepositoryUrl == null ) { - throw new GradleScriptException("Missing required properties: MAVEN_PUBLISH_ACCESS_TOKEN and MAVEN_PUBLISH_REPOSITORY_URL", null) -} - // Apply plugins apply plugin: 'maven-publish' -// Configure maven publish -publishing { - publications { - bootJava(MavenPublication) { - artifact tasks.named("bootJar") - } - } - repositories { - maven { - name = "git.captica.de" - url uri(mavenRepositoryUrl) - - credentials(HttpHeaderCredentials) { - name = "Authorization" - value = "token ${mavenAccessToken}" +if ( ext.mavenAccessToken == null || ext.mavenRepositoryUrl == null ) { + logger.error("ERROR: Maven publish not possible! Missing required properties: MAVEN_PUBLISH_ACCESS_TOKEN and MAVEN_PUBLISH_REPOSITORY_URL") +} +else { + // Configure maven publish + publishing { + publications { + bootJava(MavenPublication) { + artifact tasks.named("bootJar") } + } + repositories { + maven { + name = "git.captica.de" + url uri(mavenRepositoryUrl) - authentication { - header(HttpHeaderAuthentication) + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "token ${mavenAccessToken}" + } + + authentication { + header(HttpHeaderAuthentication) + } } - } - } + } + } } \ No newline at end of file