|
| 1 | +apply plugin: "java-library" |
| 2 | +apply plugin: "maven" |
| 3 | +apply plugin: "maven-publish" |
| 4 | +apply plugin: "com.jfrog.bintray" |
| 5 | + |
| 6 | +sourceCompatibility = JavaVersion.VERSION_1_6 |
| 7 | +targetCompatibility = JavaVersion.VERSION_1_6 |
| 8 | + |
| 9 | +// ------------------------------------------------------------------------------------------------ |
| 10 | +// Dependency Definitions |
| 11 | +// ------------------------------------------------------------------------------------------------ |
| 12 | + |
| 13 | +dependencies { |
| 14 | + implementation files("libs/junit5-rt.jar") |
| 15 | +} |
| 16 | + |
| 17 | +// ------------------------------------------------------------------------------------------------ |
| 18 | +// Deployment Setup |
| 19 | +// |
| 20 | +// Releases are pushed to jcenter via Bintray, while snapshots are pushed to Sonatype OSS. |
| 21 | +// This section defines the necessary tasks to push new releases and snapshots using Gradle tasks. |
| 22 | +// ------------------------------------------------------------------------------------------------ |
| 23 | + |
| 24 | +// Include sources.jar archive in each release |
| 25 | +task sourcesJar(type: Jar, dependsOn: classes) { |
| 26 | + classifier = "sources" |
| 27 | + from sourceSets.main.allSource |
| 28 | +} |
| 29 | + |
| 30 | +// Include javadoc.jar archive in each release |
| 31 | +task javadocJar(type: Jar, dependsOn: javadoc) { |
| 32 | + classifier = "javadoc" |
| 33 | + from javadoc.destinationDir |
| 34 | +} |
| 35 | + |
| 36 | +artifacts { |
| 37 | + archives sourcesJar |
| 38 | + archives javadocJar |
| 39 | +} |
| 40 | + |
| 41 | +project.ext.artifactId = "android-junit5-embedded-runtime" |
| 42 | +version = VERSION_NAME |
| 43 | + |
| 44 | +publishing { |
| 45 | + publications { |
| 46 | + library(MavenPublication) { |
| 47 | + from components.java |
| 48 | + artifact sourcesJar |
| 49 | + artifact javadocJar |
| 50 | + groupId GROUP_ID |
| 51 | + artifactId project.ext.artifactId |
| 52 | + version VERSION_NAME |
| 53 | + pom.withXml { |
| 54 | + def root = asNode() |
| 55 | + root.appendNode("description", DESCRIPTION) |
| 56 | + root.appendNode("name", project.ext.artifactId) |
| 57 | + root.appendNode("url", VCS_URL) |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +// Copy POM to location expected by Bintray |
| 64 | +task copyPom(type: Copy) { |
| 65 | + from "build/publications/library" |
| 66 | + into "build/poms" |
| 67 | + include "pom-default.xml" |
| 68 | +} |
| 69 | + |
| 70 | +publish.dependsOn copyPom |
| 71 | + |
| 72 | +project.configure(project) { |
| 73 | + if (project.version.endsWith("-SNAPSHOT")) { |
| 74 | + // Configure deployment of snapshot versions to Sonatype OSS |
| 75 | + project.publishing { |
| 76 | + repositories { |
| 77 | + maven { |
| 78 | + name "snapshot" |
| 79 | + credentials { |
| 80 | + username project.ext.sonatypeUser |
| 81 | + password project.ext.sonatypePass |
| 82 | + } |
| 83 | + url "https://oss.sonatype.org/content/repositories/snapshots" |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + |
| 88 | + } else { |
| 89 | + // Configure deployment of release versions to Bintray |
| 90 | + project.bintray { |
| 91 | + user = project.ext.bintrayUser |
| 92 | + key = project.ext.bintrayKey |
| 93 | + configurations = ["archives"] |
| 94 | + dryRun = false |
| 95 | + pkg { |
| 96 | + repo = "maven" |
| 97 | + name = project.ext.artifactId |
| 98 | + userOrg = project.ext.bintrayUser |
| 99 | + licenses = [LICENCE_NAME] |
| 100 | + publish = true |
| 101 | + publicDownloadNumbers = true |
| 102 | + vcsUrl = VCS_URL |
| 103 | + version { |
| 104 | + name = VERSION_NAME |
| 105 | + desc = DESCRIPTION |
| 106 | + } |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +} |
0 commit comments