Skip to content

Commit 1e5f1e1

Browse files
committed
[gradle-4.6] support publishing module metadata
1 parent be95f3b commit 1e5f1e1

File tree

3 files changed

+21
-6
lines changed

3 files changed

+21
-6
lines changed

gradle/Bintray.gradle

-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
* See the License for the specific language governing permissions and limitations under the License.
1212
*/
1313

14-
import org.gradle.api.artifacts.repositories.MavenArtifactRepository
15-
import org.gradle.api.internal.Actions
1614
import org.gradle.api.internal.ClosureBackedAction
1715

1816
class BintrayRepositoriesExtension {

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

src/main/groovy/com/jfrog/bintray/gradle/BintrayUploadTask.groovy

+20-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import org.gradle.api.file.CopySpec
1010
import org.gradle.api.publish.Publication
1111
import org.gradle.api.publish.PublishingExtension
1212
import org.gradle.api.publish.maven.MavenPublication
13+
import org.gradle.api.publish.maven.internal.publication.MavenPublicationInternal
1314
import org.gradle.api.tasks.Input
1415
import org.gradle.api.tasks.Optional
1516
import org.gradle.api.tasks.TaskAction
@@ -214,8 +215,8 @@ class BintrayUploadTask extends DefaultTask {
214215
} else {
215216
logger.error("{}: Could not find publication: {}.", path, it);
216217
}
217-
} else if (it instanceof MavenPublication) {
218-
return collectArtifacts((MavenPublication) it)
218+
} else if (it instanceof MavenPublicationInternal) {
219+
return collectArtifacts((MavenPublicationInternal) it)
219220
} else {
220221
logger.error("{}: Unsupported publication type: {}.", path, it.class)
221222
}
@@ -627,7 +628,7 @@ class BintrayUploadTask extends DefaultTask {
627628
}
628629

629630
Artifact[] collectArtifacts(Publication publication) {
630-
if (!publication instanceof MavenPublication) {
631+
if (!publication instanceof MavenPublicationInternal) {
631632
logger.info "{} can only use maven publications - skipping {}.", path, publication.name
632633
return []
633634
}
@@ -647,6 +648,22 @@ class BintrayUploadTask extends DefaultTask {
647648
)
648649
}
649650

651+
def mavenPublication = (MavenPublicationInternal)publication
652+
if (mavenPublication.canPublishModuleMetadata()) {
653+
def moduleFile = mavenPublication.publishableFiles.find{ it.name == 'module.json'}
654+
if (moduleFile != null) {
655+
artifacts << new Artifact(
656+
name: identity.artifactId,
657+
groupId: identity.groupId,
658+
version: identity.version,
659+
extension: 'module',
660+
type: 'module',
661+
file: moduleFile
662+
)
663+
}
664+
}
665+
666+
650667
// Add the pom file
651668
artifacts << new Artifact(
652669
name: identity.artifactId,

0 commit comments

Comments
 (0)