Skip to content

Commit

Permalink
Fixing issue when publishing source/javadoc to maven central
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin Ryan committed Oct 23, 2012
1 parent 05c4d06 commit 1cbb4d6
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions gradle/convention.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
}

Expand Down

0 comments on commit 1cbb4d6

Please sign in to comment.