Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Gradle's mavenDeployer

Tags:

gradle

groovy

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 plugin
  • repositories 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?
  • Searching in the index, I find that 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")
    }
    
like image 228
JB Nizet Avatar asked Oct 06 '12 15:10

JB Nizet


People also ask

How does Gradle publish work?

Gradle automatically generates publishing tasks for all possible combinations of publication and repository, allowing you to publish any artifact to any repository.

How do I deploy a jar to local Maven repository Gradle?

By running task publishToMavenLocal, the plugin will install compiled jar into Maven local repository along with the pom file generated based on the project properties (group, version, etc).

Can we use Maven plugin in Gradle?

You can't use a Maven plugin as-is in Gradle; you'll have to port it to a Gradle plugin. How difficult this is depends on how many Maven APIs the plugin is using. Another strategy might be to call into Maven via Gradle's Exec task.


1 Answers

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.

like image 136
Matt Avatar answered Sep 23 '22 13:09

Matt