Hi,
I was wondering if there are any tutorial/blogs/documentation sources how to publish gradle plugins to a gitlab package registry and version the related plugin artefacts with nebula.
All my attempts so far failed. The latest attempt failed because there seems to be no maven-metadata.xml present in the gitlab package registry:
* What went wrong:
Execution failed for task ':publishNebulaPublicationToMavenRepository'.
> Failed to publish publication 'nebula' to repository 'maven'
> Could not GET 'https://git.acme.net/api/v4/projects/1384/packages/maven/org/foobar/foobar-gradle-plugin/maven-metadata.xml'. Received status code 500 from server: Internal Server Error
My build.gradle in the plugin project looks like the following:
plugins {
id 'java-gradle-plugin'
id 'org.jetbrains.kotlin.jvm' version '1.7.10'
id 'nebula.release' version '17.0.1'
id 'maven-publish'
}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
}
gradlePlugin {
plugins {
project {
id = 'com.acme.project'
implementationClass = 'com.acme.ProjectPlugin'
}
}
}
test {
useJUnitPlatform()
}
task sourceJar(type: Jar) {
from sourceSets.main.allSource
classifier "sources"
}
publishing {
publications {
nebula(MavenPublication) {
groupId 'org.foobar'
}
}
repositories {
maven {
url "https://git.acme.net/api/v4/projects/1384/packages/maven"
credentials(HttpHeaderCredentials) {
name = "Private-Token"
value = "glpat-fewfewfewfewfewfew"
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
nebulaRelease {
addReleaseBranchPattern("develop")
}
and my .gitlab-ci.yml like this:
.gradle_job:
image: registry.acme.net/container/build/java:11.0.17
cache:
paths:
- .gradle/wrapper/
- .gradle/caches/
- build/jib-cache
key:
files:
- build.gradle
- gradle/wrapper/gradle-wrapper.properties
prefix: $CI_PROJECT_PATH_SLUG
tags:
- op-k-build
- medium
- amd64
before_script:
# set gradle user home into project dir for caching
- export GRADLE_USER_HOME=`pwd`/.gradle
build:
extends: .gradle_job
stage: build
coverage: '/Coverage: (\d+\.?\d+)%/'
script:
- ./gradlew clean check
except:
- tags
artifacts:
reports:
junit: build/test-results/test/TEST-*.xml
paths:
- build/
expire_in: 2 days
release.minor:
extends: .gradle_job
stage: deploy
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE !~ /.*\b(Major|Patch|Chore):.*/ims
script:
# new minor version on each develop commit - except chore, major, patch
- ./gradlew final -Prelease.scope=minor
release.major:
extends: .gradle_job
stage: deploy
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE =~ /.*\bMajor:.*/ims
script:
# new major version when commit message starts with "major: "
- ./gradlew final -Prelease.scope=major
release.patch:
extends: .gradle_job
stage: deploy
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE =~ /.*\bPatch:.*/ims
script:
# new patch version when commit message starts with "patch: "
- ./gradlew final -Prelease.scope=patch
release.candidate.minor:
extends: .gradle_job
stage: deploy
only:
- branches
when: manual
script:
# new minor version release candidate on demand
- ./gradlew final -Prelease.scope=minor publish
Would be really glad, if someone could point me to the right direction.