publish lib to meissa repo

This commit is contained in:
ansgarz 2023-06-13 18:49:48 +02:00
parent bf28d6306e
commit 6e609479c9
2 changed files with 36 additions and 24 deletions

View file

@ -111,7 +111,7 @@ publish-snapshot-lib:
- if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/ - if: $CI_COMMIT_TAG !~ /^release-[0-9]+[.][0-9]+([.][0-9]+)?$/
script: script:
- ./gradlew -x assemble -x test jar - ./gradlew -x assemble -x test jar
- ./gradlew -x assemble -x test publish - ./gradlew -x assemble -x test publishLibraryPublicationToMeissaRepository
artifacts: artifacts:
paths: paths:
- build/libs/*.jar - build/libs/*.jar

View file

@ -2,23 +2,23 @@ buildscript {
ext.kotlin_version = "1.7.0" ext.kotlin_version = "1.7.0"
ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID ext.CI_PROJECT_ID = System.env.CI_PROJECT_ID
repositories { mavenCentral() } repositories {
mavenCentral()
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
} }
} }
apply plugin: "org.jetbrains.kotlin.jvm" plugins {
apply plugin: "java-library" id "org.jetbrains.kotlin.jvm" version "$kotlin_version"
apply plugin: "java-test-fixtures" id 'org.jetbrains.kotlin.plugin.serialization' version "$kotlin_version"
id "java"
id "java-test-fixtures"
}
apply plugin: "maven-publish" apply plugin: "maven-publish"
apply plugin: "kotlinx-serialization"
group = "org.domaindrivenarchitecture.provs" group = "org.domaindrivenarchitecture.provs"
version = "0.22.3-SNAPSHOT" version = "0.22.4-SNAPSHOT"
repositories { repositories {
mavenCentral() mavenCentral()
@ -178,28 +178,40 @@ task sourceJar(type: Jar, dependsOn: classes) {
} }
// publish to repo.prod.meissa.de with task "publishLibraryPublicationToMeissaRepository" -- (using pattern "publishLibraryPublicationTo<MAVEN REPOSITORY NAME>Repository")
publishing { publishing {
publications { publications {
library(MavenPublication) { library(MavenPublication) {
groupId 'org.domaindrivenarchitecture'
artifactId 'provs'
from components.java from components.java
} }
} }
repositories { repositories {
if (System.getenv("CI_JOB_TOKEN") != null) { maven {
// see https://docs.gitlab.com/ee/user/packages/maven_repository/index.html name = "meissa"
maven { url = uri("https://repo.prod.meissa.de/api/packages/meissa/maven")
url "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/maven"
name "GitLab" credentials(HttpHeaderCredentials) {
credentials(HttpHeaderCredentials) { name = "Authorization"
name = "Job-Token" if (System.getenv("CI_JOB_TOKEN") != null) {
value = System.getenv("CI_JOB_TOKEN") value = "token " + System.getenv("meissa_repo_token")
} } else {
authentication { // use project-property (define e.g. in "~/.gradle/gradle.properties") when not running in ci
header(HttpHeaderAuthentication) // 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)
}
} }
} }
} }