Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is uploadArchives not listed at the tasks list?

Tags:

gradle

i thought uploadArchives is a task which is provided by the java plugin. In my build.gradle i use the java plugin:

apply plugin: 'java'

But if i invoke gradle tasks on command line, i can't see the uploadArchives task.

Even not with gradle gradle tasks --all

The uploadArchives task is listed in the gradle java plugin documentation see http://www.gradle.org/java_plugin (table 11).

I use gradle version 1.0-milestone-6.

I can invoke gradle uploadArchives without error, but the task is not listed.

like image 914
Cengiz Avatar asked Dec 12 '11 17:12

Cengiz


2 Answers

The uploadArchives task is added as a Rule to your build script and not explicitly by name. In the output of "gradle tasks" you should see this line:

Pattern: upload<ConfigurationName>: Assembles and uploads the artifacts belonging to a configuration.

This means, that for each configuration in your build file, an according uploadTask exist. The java plugin adds an configuration named archives to your build script. By adding the configuration "archives" to your build script explicitly by the java plugin, the uploadArchives task is added implicitly too.

There are scenarios, where gradle can't know what tasks need to be materialized by a rule.

E.g.

tasks.addRule("Pattern: ping<ID>") { String taskName ->
    if (taskName.startsWith("ping")) {
        task(taskName) << {
            println "Pinging: " + (taskName - 'ping')
        }
    }
}

There is no way to figure out which ping tasks should be shown as they are just materialized when triggered from commandline via 'gradle pingServer1 pingServer2 pingServer3'

regards, René

like image 164
Rene Groeschke Avatar answered Sep 19 '22 06:09

Rene Groeschke


The uploadArchives task is a part of the maven-plugin. You have to add:

apply plugin: 'maven'
like image 39
thoredge Avatar answered Sep 21 '22 06:09

thoredge