Publishing to Maven Repository through gradle

I am struggling to publish artifacts to Maven repository (Packages) through gradle.
Note: Publishing using pom worked as expected.

Here’s what i tried so far. (Note: it’s kotlin DSL syntax)

publishing {
publications {
create(“mavenJava”) {
from(components[“java”])
}
}
repositories {
maven {
name = “gitlab-maven”
url = uri(“https://gitlab.com/api/v4/projects/Package-ID/packages/maven”)
credentials(HttpHeaderCredentials::class) {
name = “Private-Token”
value = “TOKEN”
}
authentication {
create(“header”)
}
}
}
}

When i try to publish everything go through fine without any error BUT i can’t see anything gets uploaded to packages.

NOTE: Publishing to Local works just fine.

I would appreciate any pointers where exactly i am making any mistake.

Thanks.
Zeeshan.

2 Likes

Do we have similar documentation for Gradle?

https://docs.gitlab.com/ee/user/packages/maven_repository/

It would be nice if someone can answer this. Is there any other speedy way to get to other end for answer ?

2 Likes

I have a similar problem. CI pipeline successfully completed for different version of artifacts with 1.0 and 1.0-SNAPSHOT, but gitlab packages list shows only the first package with 1.0 version and without 1.0-SNAPSHOT. Packages API returns the same result - 1.0 version exists and 1.0-SNAPSHOT does not exist. What is the problem? Can not find any docs which provide this stuff (gradle+maven publish plugin+gitlab maven repo).

1 Like

Did you ever find a solution to this?

@divan It is a bug, see on this flow https://gitlab.com/gitlab-org/gitlab/-/issues/215015

2 Likes