CAPAUT-471 Refactor error handling to avoid broken builds

This commit is contained in:
2024-10-25 14:38:22 +02:00
parent 75e93be1fe
commit 4c6c7835e2

View File

@@ -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}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
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)
credentials(HttpHeaderCredentials) {
name = "Authorization"
value = "token ${mavenAccessToken}"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
}