Skip to content

Commit

Permalink
Update logic for collecting artifacts from a publication
Browse files Browse the repository at this point in the history
This enables the upload of Gradle Module Metadata when generated.
The APIs used require Gradle 4.8 at the minimum.

Fixes bintray#229
  • Loading branch information
ljacomet committed Dec 23, 2019
1 parent c58ab1b commit 9a66735
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.gradle.api.file.CopySpec
import org.gradle.api.publish.Publication
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Optional
import org.gradle.api.tasks.TaskAction
Expand Down Expand Up @@ -539,34 +540,21 @@ class BintrayUploadTask extends DefaultTask {
}

Artifact[] collectArtifacts(Publication publication) {
if (!publication instanceof MavenPublication) {
if (!publication instanceof MavenPublicationInternal) {
logger.info "{} can only use maven publications - skipping {}.", path, publication.name
return []
}
def artifacts = publication.artifacts.findResults {
boolean signedArtifact = (it instanceof org.gradle.plugins.signing.Signature)
def signedExtension = signedArtifact ? it.toSignArtifact.getExtension() : null
def artifacts = publication.asNormalisedPublication().allArtifacts.findResults {
new Artifact(
name: publication.artifactId,
groupId: publication.groupId,
version: publication.version,
extension: it.extension,
type: it.extension,
classifier: it.classifier,
file: it.file,
signedExtension: signedExtension
file: it.file
)
}

// Add the pom file
artifacts << new Artifact(
name: publication.artifactId,
groupId: publication.groupId,
version: publication.version,
extension: 'pom',
type: 'pom',
file: publication.asNormalisedPublication().pomFile
)
artifacts
}

Expand Down

0 comments on commit 9a66735

Please sign in to comment.