I’m trying to override the artifact id used by the...
# gradle
j
I’m trying to override the artifact id used by the maven plugin when publishing a library :
Copy code
publications {
        create<MavenPublication>("maven") {
            groupId = "org.my.company"
            artifactId = "our-project"
            version = "0.1"
        }
    }
    repositories {
        maven {
            url = uri("<https://org.my.company/api/v4/projects/1/packages/maven>")
            name = "GitLab"
            credentials(HttpHeaderCredentials::class) {
                name = extra["gitlab.name"].toString()
                value = extra["gitlab.token"].toString()
            }
            authentication {
                register("header", HttpHeaderAuthentication::class.java)
            }
        }
    }
But that’s what being uploaded
<https://org.my.company/api/v4/projects/1/packages/maven/org/mycompany/OurProject-jvm/0.1/OurProject-jvm-0.1.jar>
, where
OurProject
comes from
settings.gradle.kts
rootProject.name = "TeliaTrackingMixpanel"
How can I force it to be
org.my.company:our-project:01
?
m
Why do you need a different name? group and version is read from the properties.
for example you could define in
settings.gradle,kts
Copy code
rootProject.name = "our-project"
gradle.allprojects {
  group = "<http://org.company.my|org.company.my>"
  version = "0.1"
}
j
it’s a multi-platform project and ios devs wants to keep the root name as “OurProject” to generate a proper name for the podspec file, while android dev would like to rename it to get a proper library dependency string. Since it seems possible to configure the maven properties I’m wondering if I can fix our issue like that
I do have
Copy code
group = "<http://org.company.my|org.company.my>"
  version = "0.1
In the build.gradle.kts but it does not seem to change anything
m
I made the experience that defining group and version in settings will reduce issues. Because settings is loaded before the build — so group and version is defined before the plugins are loaded
you can also set group & version inside the gradle.properties file inside the project. Which is loaded before settings.
Inside the publication you need to set:
from("java")
Maybe this will fix your issue
j
well the group id is correct in my case anyway, my issue is with the artifact id that uses the project root name instead of what is in my build.gradle.kts.
I did add
from(component["kotlin"])
but it did not change anything
m
Your issue is the
-jvm
?
If this is the case, I think -
jvm
is defined inside
classifier
. Maybe you can set
classifier = ""
?
🤔 or the change happens
afterEvaluation
… maybe you can try
afterEvaluate
which is not really a good workaround but helps you for now
j
My issue is with
TeliaTrackingMixpanel
from
rootProject.name = "TeliaTrackingMixpanel"
. It is not overwritten by
artifactId = "our-project"