From 1cbb4d6dbe34998f4caa2cbe52c59abc8e0e4886 Mon Sep 17 00:00:00 2001 From: Justin Ryan Date: Tue, 23 Oct 2012 16:05:35 -0700 Subject: [PATCH] Fixing issue when publishing source/javadoc to maven central --- gradle/convention.gradle | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/gradle/convention.gradle b/gradle/convention.gradle index f16047e2..8e71812e 100644 --- a/gradle/convention.gradle +++ b/gradle/convention.gradle @@ -14,23 +14,40 @@ subprojects { project -> task sourcesJar(type: Jar, dependsOn:classes) { from sourceSets.main.allSource + classifier 'sources' + extension 'jar' } task javadocJar(type: Jar, dependsOn:javadoc) { from javadoc.destinationDir + classifier 'javadoc' + extension 'jar' } configurations.add('sources') configurations.add('javadoc') + configurations.archives { + extendsFrom configurations.sources + extendsFrom configurations.javadoc + } + + // When outputing to an Ivy repo, we want to use the proper type field + gradle.taskGraph.whenReady { + def isNotMaven = !it.hasTask(project.uploadMavenCentral) + if (isNotMaven) { + def artifacts = project.configurations.sources.artifacts + def sourceArtifact = artifacts.iterator().next() + sourceArtifact.type = 'sources' + } + } artifacts { sources(sourcesJar) { - type 'source' - classifier 'sources' + // Weird Gradle quirk where type will be used for the extension, but only for sources + type 'jar' } javadoc(javadocJar) { type 'javadoc' - classifier 'javadoc' } }