CAPAUT-471 Maven publish include for build process
This commit is contained in:
53
gradle/build-mavenpublish.gradle
Normal file
53
gradle/build-mavenpublish.gradle
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* Enables maven publish handling on build process
|
||||||
|
*
|
||||||
|
* Project: gradle
|
||||||
|
* Author: Marc Böhm <marc.boehm@captica.de>
|
||||||
|
* 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user