Skip to content

Commit

Permalink
[gradle-4.6] support publishing module metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
vvlevchenko committed Apr 27, 2018
1 parent be95f3b commit 1e5f1e1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
2 changes: 0 additions & 2 deletions gradle/Bintray.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
* See the License for the specific language governing permissions and limitations under the License.
*/

import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.internal.Actions
import org.gradle.api.internal.ClosureBackedAction

class BintrayRepositoriesExtension {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
23 changes: 20 additions & 3 deletions src/main/groovy/com/jfrog/bintray/gradle/BintrayUploadTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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 @@ -214,8 +215,8 @@ class BintrayUploadTask extends DefaultTask {
} else {
logger.error("{}: Could not find publication: {}.", path, it);
}
} else if (it instanceof MavenPublication) {
return collectArtifacts((MavenPublication) it)
} else if (it instanceof MavenPublicationInternal) {
return collectArtifacts((MavenPublicationInternal) it)
} else {
logger.error("{}: Unsupported publication type: {}.", path, it.class)
}
Expand Down Expand Up @@ -627,7 +628,7 @@ 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 []
}
Expand All @@ -647,6 +648,22 @@ class BintrayUploadTask extends DefaultTask {
)
}

def mavenPublication = (MavenPublicationInternal)publication
if (mavenPublication.canPublishModuleMetadata()) {
def moduleFile = mavenPublication.publishableFiles.find{ it.name == 'module.json'}
if (moduleFile != null) {
artifacts << new Artifact(
name: identity.artifactId,
groupId: identity.groupId,
version: identity.version,
extension: 'module',
type: 'module',
file: moduleFile
)
}
}


// Add the pom file
artifacts << new Artifact(
name: identity.artifactId,
Expand Down

0 comments on commit 1e5f1e1

Please sign in to comment.