How to add a second jar/upload task to a Java build

Wanted to add a second set of tasks to a Java build file that would create and upload a separate jar file. Got it working quickly enough, except that all my uploads now overwrote the same Jar file on upload. I was puzzled because two jar files with different names were properly created in build/libs. Finally figured it out and thought I would share. Working code looks like this:

task woozleJar(type: Jar) {

baseName = “woozle” // THIS IS THE KEY COMPONENT TO DISTINGUISH THIS JAR FROM DEFAULT JAVA JAR

from sourceSets.woozle.classes }

configurations { woozle }

artifacts { woozle woozleJar }

uploadWoozle {

configurations = configurations. woozle

repositories {

add project.repositories.uploads

} }

// Standard Java plugin code here uploadArchives { … }