|
| 1 | +import com.android.builder.core.BuilderConstants |
| 2 | + |
| 3 | +apply plugin: 'com.android.library' |
| 4 | +apply plugin: 'com.github.kt3k.coveralls' |
| 5 | + |
| 6 | +group = 'com.parse' |
| 7 | +version = '0.0.1-SNAPSHOT' |
| 8 | + |
| 9 | +buildscript { |
| 10 | + repositories { |
| 11 | + mavenCentral() |
| 12 | + } |
| 13 | + |
| 14 | + dependencies { |
| 15 | + classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1x' |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +android { |
| 20 | + compileSdkVersion rootProject.ext.compileSdkVersion |
| 21 | + buildToolsVersion rootProject.ext.buildToolsVersion |
| 22 | + |
| 23 | + defaultConfig { |
| 24 | + minSdkVersion rootProject.ext.minSdkVersion |
| 25 | + targetSdkVersion rootProject.ext.targetSdkVersion |
| 26 | + versionCode 1 |
| 27 | + versionName project.version |
| 28 | + consumerProguardFiles 'release-proguard.pro' |
| 29 | + } |
| 30 | + |
| 31 | + lintOptions { |
| 32 | + abortOnError false |
| 33 | + } |
| 34 | + |
| 35 | + buildTypes { |
| 36 | + debug { |
| 37 | + testCoverageEnabled = true |
| 38 | + } |
| 39 | + } |
| 40 | +} |
| 41 | + |
| 42 | +dependencies { |
| 43 | + compile 'com.parse:parse-android:1.13.1' |
| 44 | + compile 'com.firebase:tubesock:0.0.12' |
| 45 | + compile 'com.parse.bolts:bolts-tasks:1.4.0' |
| 46 | + |
| 47 | + testCompile 'org.robolectric:robolectric:3.0' |
| 48 | + testCompile 'org.skyscreamer:jsonassert:1.2.3' |
| 49 | + testCompile 'org.mockito:mockito-core:1.10.19' |
| 50 | +} |
| 51 | + |
| 52 | +android.libraryVariants.all { variant -> |
| 53 | + def name = variant.buildType.name |
| 54 | + def jar = project.tasks.create(name: "jar${name.capitalize()}", type: Jar) { |
| 55 | + dependsOn variant.javaCompile |
| 56 | + from variant.javaCompile.destinationDir |
| 57 | + |
| 58 | + manifest { |
| 59 | + attributes( |
| 60 | + "Bundle-Name": 'parse-livequery-android', |
| 61 | + "Bundle-Version": project.version |
| 62 | + ) |
| 63 | + } |
| 64 | + |
| 65 | + exclude '**/R.class' |
| 66 | + exclude '**/R\$*.class' |
| 67 | + exclude '**/Manifest.class' |
| 68 | + exclude '**/Manifest\$*.class' |
| 69 | + exclude '**/BuildConfig.class' |
| 70 | + } |
| 71 | + |
| 72 | + def javadoc = task("javadoc${variant.name.capitalize()}", type: Javadoc) { |
| 73 | + description "Generates Javadoc for $variant.name." |
| 74 | + source = variant.javaCompile.source |
| 75 | + ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" |
| 76 | + classpath = files(variant.javaCompile.classpath.files) + files(ext.androidJar) |
| 77 | + |
| 78 | + options.docletpath = [rootProject.file("./gradle/ExcludeDoclet.jar")] |
| 79 | + options.doclet = "me.grantland.doclet.ExcludeDoclet" |
| 80 | + |
| 81 | + options.linksOffline("http://d.android.com/reference", "${android.sdkDirectory}/docs/reference") |
| 82 | + options.links("http://boltsframework.github.io/docs/android/") |
| 83 | + |
| 84 | + exclude '**/BuildConfig.java' |
| 85 | + exclude '**/R.java' |
| 86 | + exclude '**/internal/**' |
| 87 | + } |
| 88 | + |
| 89 | + def javadocJar = task("javadocJar${variant.name.capitalize()}", type: Jar, dependsOn: "javadoc${variant.name.capitalize()}") { |
| 90 | + classifier = 'javadoc' |
| 91 | + from javadoc.destinationDir |
| 92 | + } |
| 93 | + |
| 94 | + if (name.equals(BuilderConstants.RELEASE)) { |
| 95 | + artifacts.add('archives', jar); |
| 96 | + artifacts.add('archives', javadocJar); |
| 97 | + } |
| 98 | +} |
| 99 | + |
| 100 | +//region Maven |
| 101 | + |
| 102 | +apply plugin: 'maven' |
| 103 | +apply plugin: 'signing' |
| 104 | + |
| 105 | +def isSnapshot = version.endsWith('-SNAPSHOT') |
| 106 | +def ossrhUsername = hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : System.getenv('CI_NEXUS_USERNAME') |
| 107 | +def ossrhPassword = hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : System.getenv('CI_NEXUS_PASSWORD') |
| 108 | + |
| 109 | +uploadArchives { |
| 110 | + repositories.mavenDeployer { |
| 111 | + beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
| 112 | + |
| 113 | + repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") { |
| 114 | + authentication(userName: ossrhUsername, password: ossrhPassword) |
| 115 | + } |
| 116 | + |
| 117 | + snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { |
| 118 | + authentication(userName: ossrhUsername, password: ossrhPassword) |
| 119 | + } |
| 120 | + |
| 121 | + pom.project { |
| 122 | + name 'Parse-LiveQuery-Android' |
| 123 | + artifactId = 'parse-livequery-android' |
| 124 | + packaging 'jar' |
| 125 | + description 'A library that gives you access to the powerful Parse cloud platform from your Android app.' |
| 126 | + url 'https://github.com/ParsePlatform/ParseLiveQuery-Android' |
| 127 | + |
| 128 | + scm { |
| 129 | + connection 'scm:[email protected]:ParsePlatform/ParseLiveQuery-Android.git' |
| 130 | + developerConnection 'scm:[email protected]:ParsePlatform/ParseLiveQuery-Android.git' |
| 131 | + url 'https://github.com/ParsePlatform/ParseLiveQuery-Android' |
| 132 | + } |
| 133 | + |
| 134 | + licenses { |
| 135 | + license { |
| 136 | + name 'BSD License' |
| 137 | + url 'https://github.com/ParsePlatform/ParseLiveQuery-Android/blob/master/LICENSE' |
| 138 | + distribution 'repo' |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + developers { |
| 143 | + developer { |
| 144 | + id 'parse' |
| 145 | + name 'Parse' |
| 146 | + } |
| 147 | + } |
| 148 | + } |
| 149 | + } |
| 150 | +} |
| 151 | + |
| 152 | +signing { |
| 153 | + required { !isSnapshot && gradle.taskGraph.hasTask("uploadArchives") } |
| 154 | + sign configurations.archives |
| 155 | +} |
| 156 | + |
| 157 | +task androidSourcesJar(type: Jar) { |
| 158 | + classifier = 'sources' |
| 159 | + from android.sourceSets.main.java.sourceFiles |
| 160 | +} |
| 161 | + |
| 162 | +artifacts { |
| 163 | + archives androidSourcesJar |
| 164 | +} |
| 165 | + |
| 166 | +//endregion |
| 167 | + |
| 168 | +//region Code Coverage |
| 169 | + |
| 170 | +apply plugin: 'jacoco' |
| 171 | + |
| 172 | +jacoco { |
| 173 | + toolVersion "0.7.1.201405082137" |
| 174 | +} |
| 175 | + |
| 176 | +task jacocoTestReport(type:JacocoReport, dependsOn: "testDebugUnitTest") { |
| 177 | + group = "Reporting" |
| 178 | + description = "Generate Jacoco coverage reports" |
| 179 | + |
| 180 | + classDirectories = fileTree( |
| 181 | + dir: "${buildDir}/intermediates/classes/debug", |
| 182 | + excludes: ['**/R.class', |
| 183 | + '**/R$*.class', |
| 184 | + '**/*$ViewInjector*.*', |
| 185 | + '**/BuildConfig.*', |
| 186 | + '**/Manifest*.*'] |
| 187 | + ) |
| 188 | + |
| 189 | + sourceDirectories = files("${buildDir.parent}/src/main/java") |
| 190 | + additionalSourceDirs = files([ |
| 191 | + "${buildDir}/generated/source/buildConfig/debug", |
| 192 | + "${buildDir}/generated/source/r/debug" |
| 193 | + ]) |
| 194 | + executionData = files("${buildDir}/jacoco/testDebugUnitTest.exec") |
| 195 | + |
| 196 | + reports { |
| 197 | + xml.enabled = true |
| 198 | + html.enabled = true |
| 199 | + } |
| 200 | +} |
| 201 | + |
| 202 | +//endregion |
| 203 | + |
| 204 | +//region Coveralls |
| 205 | + |
| 206 | +coveralls.jacocoReportPath = "${buildDir}/reports/jacoco/jacocoTestReport/jacocoTestReport.xml" |
| 207 | + |
| 208 | +//endregion |
0 commit comments