From 6e609479c9dfce4a7ede1a1ea957a597af44c154 Mon Sep 17 00:00:00 2001 From: ansgarz Date: Tue, 13 Jun 2023 18:49:48 +0200 Subject: [PATCH] publish lib to meissa repo --- .gitlab-ci.yml | 2 +- build.gradle | 58 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f2ad9d6..91a8fff 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -111,7 +111,7 @@ publish-snapshot-lib: - if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ script: - ./gradlew -x assemble -x test jar - - ./gradlew -x assemble -x test publish + - ./gradlew -x assemble -x test publishLibraryPublicationToMeissaRepository artifacts: paths: - build/libs/*.jar diff --git a/build.gradle b/build.gradle index ead3f6a..db8ba2f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,23 +2,23 @@ buildscript { ext.kotlin_version = "1.7.0" ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID - repositories { mavenCentral() } - - dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + repositories { + mavenCentral() } } -apply plugin: "org.jetbrains.kotlin.jvm" -apply plugin: "java-library" -apply plugin: "java-test-fixtures" +plugins { + id "org.jetbrains.kotlin.jvm" version "$kotlin_version" + id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version" + id "java" + id "java-test-fixtures" +} + apply plugin: "maven-publish" -apply plugin: "kotlinx-serialization" group = "org.domaindrivenarchitecture.provs" -version = "0.22.3-SNAPSHOT" +version = "0.22.4-SNAPSHOT" repositories { mavenCentral() @@ -178,28 +178,40 @@ task sourceJar(type: Jar, dependsOn: classes) { } +// publish to repo.prod.meissa.de with task "publishLibraryPublicationToMeissaRepository" -- (using pattern "publishLibraryPublicationToRepository") publishing { publications { library(MavenPublication) { + groupId 'org.domaindrivenarchitecture' + artifactId 'provs' from components.java } } + repositories { - if (System.getenv("CI_JOB_TOKEN") != null) { - // see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html - maven { - url "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven" - name "GitLab" - credentials(HttpHeaderCredentials) { - name = "Job-Token" - value = System.getenv("CI_JOB_TOKEN") - } - authentication { - header(HttpHeaderAuthentication) + maven { + name = "meissa" + url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven") + + credentials(HttpHeaderCredentials) { + name = "Authorization" + if (System.getenv("CI_JOB_TOKEN") != null) { + value = "token " + System.getenv("meissa_repo_token") + } else { + // use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci + // you can create a token in gitea "Profile and Settings ... > Settings > Applications", Token Name, Select scopes (write:package) > "Generate Token" + if (!project.hasProperty("meissa_repo_token")) { + // if meissa_repo_token is missing, provide a dummy in order to avoid error "Could not get unknown property 'meissa_repo_token' for Credentials [header: Authorization]" for other gradle tasks + ext.meissa_repo_token = "meissa_repo_token not provided in file \".gradle/gradle.properties\"" + println "Error: meissa_repo_token not found" + } + value = "token $meissa_repo_token" } } - } else { - mavenLocal() + + authentication { + header(HttpHeaderAuthentication) + } } } }