Is there a way to change the artifact name for a m...
# gradle
n
Is there a way to change the artifact name for a module in a Gradle multi module project via Kotlin DSL?
g
Same as via Groovy
In general I don’t know any Gradle API or plugins API that cannot be confugured from Kotlin DSL, sometimes it’s not easy because of dynamic APIs or you should know what to configure: extension, convention or task
n
So something similar to this: https://stackoverflow.com/a/24827804
g
Yes, just configure this extension. You can try, if you still have some problems share your example
n
Been looking through the maven-publish plugin documentation (https://docs.gradle.org/current/userguide/publishing_maven.html), and found a possible way to set the artifactId (via name property in the pom block). Unfortunately with the Kotlin DSL the name property is read only, where as with the Groovy DSL the property is writable 🙁 .
g
probably you need something like
setName
check sources
Oh, it’s more tricky
Copy code
publishing {
    (publications) {
        "mavenJava"(MavenPublication::class) {
            pom {
                withGroovyBuilder {
                    "name"("something")
                }
            }
        }
    }
}
something like this
part about pom is very dynamic and based on groovy dynamic properties
n
Have something a bit different from what was posted:
Copy code
publishing {
    publications {
        create("sources", MavenPublication::class.java) {
            from(components["java"])
            artifact(createSourceJar)
            pom {
                // Do things with pom here...
            }
        }
    }
    // ...
}
g
It’s actually the same
create("sources", MavenPublication::class.java)
is just desugared version of
sources"(MavenPublication::class)
again, I’m not sure how to set name, maybe publication name will be used, I just showed how to add field to POM, that’s why it can be available on groovy, but not on kotlin