Bagira
Bagira

Reputation: 2243

uploadArchives does not upload artifacts generated from other gradle files

In my build.gradle, I have war task which generates a war file and couple tasks which generate jar file. Jar generating tasks are defined in other gradle files and are imported in main build.gralde using apply from clause.

Problem is uploadArchives only uploads war file and does not upload jar files which are generated from other files.

What could be the potential cause of problem here?

My build.gradle looks like as follows

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'

war {
   .... // generates war file
}

apply from: 'Createjar1.gradle'  // creates jar1
apply from: 'Createjar2.gradle'  // creates jar2
apply from: 'Createjar3.gradle'  // creates jar3

uploadArchives {
repositories {
    mavenDeployer {
        repository(url:"${nexusURL}") {
            authentication(userName: 'username', password: 'password')
        }
        snapshotRepository(url: "${nexusURL}") {
            authentication(userName: 'username', password: 'password')
        }
    }
 }
}

Upvotes: 2

Views: 2363

Answers (1)

Mark Vieira
Mark Vieira

Reputation: 13466

By default the 'maven' plugin will upload any artifacts contained in the 'archives' configuration. Your WAR is automatically added to that configuration but additional artifacts have to be explicitly defined.

artifacts {
    archives jar1Task
    archives jar2Task
    archives jar3Task
}

Upvotes: 2

Related Questions