From 90b9933d8759a450a053271531f4d5fa0ef29b70 Mon Sep 17 00:00:00 2001 From: Marc Boehm Date: Fri, 25 Oct 2024 14:22:35 +0200 Subject: [PATCH] CAPAUT-471 Maven publish include for build process --- gradle/build-mavenpublish.gradle | 53 ++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 gradle/build-mavenpublish.gradle diff --git a/gradle/build-mavenpublish.gradle b/gradle/build-mavenpublish.gradle new file mode 100644 index 0000000..678fb0e --- /dev/null +++ b/gradle/build-mavenpublish.gradle @@ -0,0 +1,53 @@ +/* + * Enables maven publish handling on build process + * + * Project: gradle + * Author: Marc Böhm + * License: MIT License (see LICENSE.md) + * + * Copyright (c) captica GmbH est. 2021 + */ + +// Load external plugins +buildscript { + repositories { + gradlePluginPortal() + mavenCentral() + } +} + +project.ext { + mavenAccessToken = ( project.hasProperty('MAVEN_PUBLISH_ACCESS_TOKEN') ? MAVEN_ACCESS_TOKEN : null ) + 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") +} + +// Apply plugins +apply plugin: 'maven-publish' + +// Configure maven publish +publishing { + publications { + bootJava(MavenPublication) { + artifact tasks.named("bootJar") + } + } + repositories { + maven { + url uri(mavenRepositoryUrl) + + credentials(HttpHeaderCredentials) { + name = "Authorization" + value = "token ${mavenAccessToken}" + } + + authentication { + header(HttpHeaderAuthentication) + } + } + } +} \ No newline at end of file