Reputation: 692053
I'm a newbie in Gradle and Groovy in general, and I'm trying to understand the following example from the Gradle user guide, and especially how I could find, in the DSL documentation, where all these options can be found:
uploadArchives {
repositories.mavenDeployer {
name = 'sshDeployer' // optional
configuration = configurations.deployerJars
repository(url: "scp://repos.mycompany.com/releases") {
authentication(userName: "me", password: "myPassword")
}
}
}
What I understand:
uploadArchives
is a task of type Upload
, added to the project by the Java pluginrepositories
is a property of the Upload
task, of type RepositoryHandler
What I don't understand:
mavenDeployer
doesn't appear anywhere in the documentation of RepositoryHandler. Where does it come from? How are we supposed to know that such a method exists?mavenDeployer
is a method from MavenRepositoryHandlerConvention which is mixed in the RepositoryHandler associated with each task of type Upload. Too bad this isn't mentioned in RepositoryHandler
's documentation and Upload's documentation.Although it could be clearer, I understand that the closure must configure an object of type GroovyMavenDeployer
. But reading the javadoc, the repository
property for example is of type Object
. How can I know that I can configure it using the following?
repository(url: "scp://repos.mycompany.com/releases") {
authentication(userName: "me", password: "myPassword")
}
Upvotes: 16
Views: 17834
Reputation: 8476
Gradle DSL documentation is not especially comprehensive. It's not always clear where public api stops and private impl starts & often the source code is the only place to get a comprehensive view (so I find it is generally easiest to link the src code to my IDE).
In your specific case, the userguide + the source code is the best way to navigate.
EDIT: this answer refers to an old version of gradle so the userguide link above points to that old version, current day (v7.4.2 at the time of writing) gradle uses a different plugin which is described in https://docs.gradle.org/current/userguide/userguide_single.html#publishing_maven
Upvotes: 6