1- apply plugin : ' groovy'
2- apply plugin : ' idea'
3- apply plugin : ' maven'
4- apply plugin : ' maven-publish'
5- apply plugin : ' com.jfrog.bintray'
1+ apply plugin : " groovy"
2+ apply plugin : " idea"
3+ apply plugin : " maven"
4+ apply plugin : " maven-publish"
5+ apply plugin : " com.jfrog.bintray"
6+ apply plugin : " com.jfrog.artifactory"
67
78sourceCompatibility = JavaVersion . VERSION_1_6
89targetCompatibility = JavaVersion . VERSION_1_6
910
11+ // ------------------------------------------------------------------------------------------------
12+ // Test Setup
13+ //
14+ // We run our unit tests against multiple versions of the Android Gradle Plugin,
15+ // in order to support logical & structural intricacies of both the 2.x & 3.x line of plugins.
16+ // To achieve this, several new source sets & configurations for each branch are created here,
17+ // which are derived from the common "test" scope.
18+ // ------------------------------------------------------------------------------------------------
19+
1020configurations {
1121 testAgp2xCompile {
1222 extendsFrom configurations. testCompile
@@ -40,6 +50,28 @@ idea {
4050 }
4151}
4252
53+ // Run Unit Tests against Android Gradle Plugin version 2.x
54+ task testAgp2x (type : Test ) {
55+ testClassesDirs = sourceSets. testAgp2x. output. classesDirs
56+ classpath = sourceSets. main. runtimeClasspath + sourceSets. testAgp2x. runtimeClasspath
57+ }
58+
59+ // Run Unit Tests against Android Gradle Plugin version 3.x
60+ task testAgp3x (type : Test ) {
61+ testClassesDirs = sourceSets. testAgp3x. output. classesDirs
62+ classpath = sourceSets. main. runtimeClasspath + sourceSets. testAgp3x. runtimeClasspath
63+ }
64+
65+ // Combine all tests when executing the main JUnit task
66+ tasks. getByName(" test" ). dependsOn(
67+ testAgp2x,
68+ testAgp3x
69+ )
70+
71+ // ------------------------------------------------------------------------------------------------
72+ // Dependency Definitions
73+ // ------------------------------------------------------------------------------------------------
74+
4375dependencies {
4476 compile gradleApi()
4577 compile localGroovy()
@@ -55,46 +87,32 @@ dependencies {
5587 testAgp3xCompile " com.android.tools.build:gradle:$ANDROID_PLUGIN_VERSION_3X "
5688}
5789
58- // Run Unit Tests against Android Gradle Plugin version 2.x
59- task testAgp2x (type : Test ) {
60- testClassesDirs = sourceSets. testAgp2x. output. classesDirs
61- classpath = sourceSets. main. runtimeClasspath + sourceSets. testAgp2x. runtimeClasspath
90+ // ------------------------------------------------------------------------------------------------
91+ // Deployment Setup
92+ //
93+ // Releases are pushed to jcenter via Bintray, and snapshots are pushed to OJO Artifactory.
94+ // This section defines the necessary tasks to push new releases and snapshots using Gradle tasks.
95+ // ------------------------------------------------------------------------------------------------
96+
97+ // Include sources.jar archive in each release
98+ task sourcesJar (type : Jar , dependsOn : classes) {
99+ classifier = " sources"
100+ from sourceSets. main. allSource
62101}
63102
64- // Run Unit Tests against Android Gradle Plugin version 3.x
65- task testAgp3x (type : Test ) {
66- testClassesDirs = sourceSets . testAgp3x . output . classesDirs
67- classpath = sourceSets . main . runtimeClasspath + sourceSets . testAgp3x . runtimeClasspath
103+ // Include javadoc.jar archive in each release
104+ task javadocJar (type : Jar , dependsOn : javadoc ) {
105+ classifier = " javadoc "
106+ from javadoc . destinationDir
68107}
69108
70- // Combine all tests when executing the main JUnit task
71- tasks. getByName(" test" ). dependsOn(
72- testAgp2x,
73- testAgp3x
74- )
109+ artifacts {
110+ archives sourcesJar
111+ archives javadocJar
112+ }
75113
76114version = VERSION_NAME
77115
78- bintray {
79- user = project. ext. bintrayUser
80- key = project. ext. bintrayApiKey
81- configurations = [' archives' ]
82- dryRun = false
83- pkg {
84- repo = ' maven'
85- name = ARTIFACT_ID
86- userOrg = properties. get(" BINTRAY_USER" )
87- licenses = [" EPL-1.0" ]
88- publish = true
89- publicDownloadNumbers = true
90- vcsUrl = VCS_URL
91- version {
92- name = VERSION_NAME
93- desc = DESCRIPTION
94- }
95- }
96- }
97-
98116publishing {
99117 publications {
100118 library(MavenPublication ) {
@@ -114,25 +132,49 @@ publishing {
114132 }
115133}
116134
135+ // Copy POM to location expected by Bintray
117136task copyPom (type : Copy ) {
118- from ' build/publications/library'
119- into ' build/poms'
120- include ' pom-default.xml'
137+ from " build/publications/library"
138+ into " build/poms"
139+ include " pom-default.xml"
121140}
122141
123142publish. dependsOn copyPom
124143
125- task sourcesJar (type : Jar , dependsOn : classes) {
126- classifier = ' sources'
127- from sourceSets. main. allSource
128- }
129-
130- task javadocJar (type : Jar , dependsOn : javadoc) {
131- classifier = ' javadoc'
132- from javadoc. destinationDir
144+ // Configure deployment of release versions to Bintray
145+ bintray {
146+ user = project. ext. bintrayUser
147+ key = project. ext. bintrayKey
148+ configurations = [" archives" ]
149+ dryRun = false
150+ pkg {
151+ repo = " maven"
152+ name = ARTIFACT_ID
153+ userOrg = project. ext. bintrayUser
154+ licenses = [" EPL-1.0" ]
155+ publish = true
156+ publicDownloadNumbers = true
157+ vcsUrl = VCS_URL
158+ version {
159+ name = VERSION_NAME
160+ desc = DESCRIPTION
161+ }
162+ }
133163}
134164
135- artifacts {
136- archives sourcesJar
137- archives javadocJar
165+ // Configure deployment of snapshots to Artifactory
166+ artifactory {
167+ contextUrl = " https://oss.jfrog.org/artifactory"
168+ publish {
169+ repository {
170+ repoKey = VERSION_NAME . endsWith(" SNAPSHOT" ) ? " oss-snapshot-local" : " oss-release-local"
171+ username = project. ext. bintrayUser
172+ password = project. ext. bintrayKey
173+ maven = true
174+ }
175+ defaults {
176+ publishArtifacts = true
177+ publications(" library" )
178+ }
179+ }
138180}
0 commit comments