G'day
In order to publish to a maven repository, you now need to explicitly add a
MavenPublication. The rationale for this change is described at
https://github.com/gradle/gradle/blob/master/design-docs/publication-model.md#publish-web-application-to-maven-repository
The DSL for doing so looks like:
publishing.publications {
myPublicationName(MavenPublication) {
from components.java // Publish the java-library component
}
}
publishing.publications {
myPublicationName {
// More config for the existing publication
}
}
So the method name gives the publication name, and the type is determined
by the class argument. This is different from RepositoryHandler, for
example, which uses the method name to define the type, and has a separate
way of setting the 'name'. Using the name for type does lead to a bit of
ambiguity in the DSL, because when creating you use repository.type and
when accessing repository.name.
repositories {
flatDir {
name "myFlatDir"
}
}
repositories {
myFlatDir {
// some extra config
}
}
I'm not sure the new syntax is better or worse, but it is a different
paradigm. One thing to note is that the name of a publication is not
particularly important: there will often be a single publication of a type,
and the name is only used for referencing elsewhere in the build.
So one option is to go with:
publishing.publications {
maven { // Creates a new MavenPublication
name "myMavenPublication"
from components.java
}
}
publishing.publications {
myMavenPublication {
// More config for the existing publication
}
}
This would be more consistent with other parts of the DSL, but probably
internally consistent. What happens if you give your publication the name
"maven"?
Thoughts?
Daz