blob: 360e3db04ac65ea7d29b25bf2e909c6638461299 [file] [log] [blame]
Ben Gruver181c04c2012-09-16 00:03:44 -07001/*
2 * Copyright 2012, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
Ben Gruvercc5871f2012-09-16 00:18:03 -070032apply plugin: 'idea'
33
Ben Gruver948c0202017-10-30 15:34:58 -070034version = '2.2.2'
Ben Gruver75fdec62017-03-21 21:22:06 -070035def jcommanderVersion = ''
Ben Gruver3a96d5d2012-10-29 21:42:29 -070036
Ben Gruver3a96d5d2012-10-29 21:42:29 -070037if (!('release' in gradle.startParameter.taskNames)) {
Ben Gruver75fdec62017-03-21 21:22:06 -070038 // we compile against 1.48 normally, to match what's in AOSP, but switch to a newer version
39 // for release, because it has some fixes required when running on Android
40 jcommanderVersion = 'com.beust:jcommander:1.48'
41
Ben Gruver3a96d5d2012-10-29 21:42:29 -070042 def versionSuffix
43 try {
44 def git = org.eclipse.jgit.api.Git.open(file('.'))
Ben Gruverf0c481a2015-03-01 22:00:30 -080045 def head = git.getRepository().getRef('HEAD')
Ben Gruver3a96d5d2012-10-29 21:42:29 -070046 versionSuffix = head.getObjectId().abbreviate(8).name()
47
48 if (!git.status().call().clean) {
49 versionSuffix += '-dirty'
50 }
51 } catch (Exception) {
52 // In case we can't get the commit for some reason,
53 // just use -dev
54 versionSuffix = 'dev'
55 }
56
Ben Gruver6429b3d2016-02-14 18:45:17 -080057 version += "-${versionSuffix}"
Ben Gruver583079c2015-04-30 23:26:23 -070058} else {
Ben Gruver75fdec62017-03-21 21:22:06 -070059 jcommanderVersion = 'com.beust:jcommander:1.64'
60
Ben Gruver583079c2015-04-30 23:26:23 -070061 if (System.env.JDK6_HOME == null && !JavaVersion.current().isJava6()) {
62 throw new InvalidUserDataException("bzzzzzzzt. Release builds must be performed with java 6. " +
63 "Either run gradle with java 6, or define the JDK6_HOME environment variable.")
64 }
Ben Gruver3a96d5d2012-10-29 21:42:29 -070065}
66
Ben Gruver5b411f32014-01-17 02:04:07 -080067// Note: please don't use this. This is strictly for the official releases
68// that are posted on, e.g. the bitbucket download page.
69task release() {
70}
71
Ben Gruver6429b3d2016-02-14 18:45:17 -080072task(install) << {
73 println "Installing version: ${version}"
74}
75
Ben Gruver1d28b322014-01-18 11:33:39 -080076// The projects that get pushed to maven
77def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util']
78
Ben Gruver7d7ee582012-09-14 20:56:58 -070079subprojects {
80 apply plugin: 'java'
Ben Gruvercc5871f2012-09-16 00:18:03 -070081 apply plugin: 'idea'
Ben Gruver7d7ee582012-09-14 20:56:58 -070082
Ben Gruver0b42b4f2014-12-28 14:14:39 -080083 if (JavaVersion.current().isJava8Compatible()) {
84 allprojects {
85 tasks.withType(Javadoc) {
86 options.addStringOption('Xdoclint:none', '-quiet')
87 }
88 }
89 }
90
Ben Gruver583079c2015-04-30 23:26:23 -070091 if (System.env.JDK6_HOME != null) {
92 sourceCompatibility = 1.6
93 targetCompatibility = 1.6
94
95 tasks.withType(JavaCompile) {
96 doFirst {
97 options.fork = true
98 options.bootClasspath = "$System.env.JDK6_HOME/jre/lib/rt.jar"
99 options.bootClasspath += "$File.pathSeparator$System.env.JDK6_HOME/jre/lib/jsse.jar"
100 }
101 }
102 }
103
Ben Gruver3a96d5d2012-10-29 21:42:29 -0700104 version = parent.version
Ben Gruver7d1263a2012-09-15 16:54:20 -0700105
Ben Gruver46cefa32013-03-03 17:58:02 -0800106 ext {
Ben Gruver29d714f2016-02-26 22:09:08 -0800107 depends = [
108 guava: 'com.google.guava:guava:18.0',
109 findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
110 junit: 'junit:junit:4.6',
Ben Gruverdcaf46c2016-10-02 18:26:17 -0700111 mockito: 'org.mockito:mockito-core:1.10.19',
Ben Gruver29d714f2016-02-26 22:09:08 -0800112 antlr_runtime: 'org.antlr:antlr-runtime:3.5.2',
113 antlr: 'org.antlr:antlr:3.5.2',
114 stringtemplate: 'org.antlr:stringtemplate:3.2.1',
Ben Gruver07dc76c2016-07-09 13:42:15 -0700115 jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0',
Ben Gruver29d714f2016-02-26 22:09:08 -0800116 proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1',
117 dx: 'com.google.android.tools:dx:1.7',
Ben Gruver5a5eafb2016-04-10 22:08:11 -0700118 gson: 'com.google.code.gson:gson:2.3.1',
Ben Gruver75fdec62017-03-21 21:22:06 -0700119 jcommander: jcommanderVersion
120 ]
Ben Gruver46cefa32013-03-03 17:58:02 -0800121 }
122
Ben Gruver7d7ee582012-09-14 20:56:58 -0700123 repositories {
124 mavenCentral()
125 }
Ben Gruver7d1263a2012-09-15 16:54:20 -0700126
Ben Gruver1d28b322014-01-18 11:33:39 -0800127 if (project.name in maven_release_projects) {
128 apply plugin: 'maven'
129 apply plugin: 'signing'
Ben Gruver5b411f32014-01-17 02:04:07 -0800130
Ben Gruver1d28b322014-01-18 11:33:39 -0800131 group = 'org.smali'
Ben Gruver5b411f32014-01-17 02:04:07 -0800132
Ben Gruver1d28b322014-01-18 11:33:39 -0800133 task javadocJar(type: Jar, dependsOn: javadoc) {
134 classifier = 'javadoc'
135 from 'build/docs/javadoc'
136 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800137
Ben Gruver1d28b322014-01-18 11:33:39 -0800138 task sourcesJar(type: Jar) {
139 classifier = 'sources'
140 from sourceSets.main.allJava
141 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800142
Ben Gruver1d28b322014-01-18 11:33:39 -0800143 artifacts {
144 archives javadocJar
145 archives sourcesJar
146 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800147
Ben Gruver1d28b322014-01-18 11:33:39 -0800148 signing {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800149 required { gradle.taskGraph.hasTask('uploadArchives') }
Ben Gruver1d28b322014-01-18 11:33:39 -0800150 sign configurations.archives
151 }
152
153 uploadArchives {
154 repositories.mavenDeployer {
155 configuration = configurations.archives
156
157 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
158
159 if (rootProject.hasProperty('sonatypeUsername') && rootProject.hasProperty('sonatypePassword')) {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800160 repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
Ben Gruver1d28b322014-01-18 11:33:39 -0800161 authentication(userName: sonatypeUsername, password: sonatypePassword)
Ben Gruver5b411f32014-01-17 02:04:07 -0800162 }
163 }
Ben Gruver1d28b322014-01-18 11:33:39 -0800164
165 pom.artifactId = project.name
166
167 pom.project {
168 name project.name
169 url 'http://smali.org'
170 packaging 'jar'
171 licenses {
172 license {
173 name 'The BSD 3-Clause License'
174 url 'http://opensource.org/licenses/BSD-3-Clause'
175 distribution 'repo'
176 }
177 }
178 scm {
179 connection 'scm:git:git://github.com/JesusFreke/smali.git'
180 developerConnection 'scm:git:git@github.com:JesusFreke/smali.git'
181 }
182 developers {
183 developer {
184 id 'jesusfreke'
185 name 'Ben Gruver'
186 email 'jesusfreke@jesusfreke.com'
187 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800188 }
189 }
190 }
191 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800192
Ben Gruver1d28b322014-01-18 11:33:39 -0800193 tasks.getByPath(':release').dependsOn(uploadArchives)
194 }
Ben Gruver3a96d5d2012-10-29 21:42:29 -0700195}
Ben Gruver7d1263a2012-09-15 16:54:20 -0700196
197buildscript {
198 repositories {
199 mavenCentral()
200 }
201 dependencies {
202 classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
203 }
Ben Gruverdbce47d2013-10-10 20:29:34 -0700204}
205
206task wrapper(type: Wrapper) {
Frieder Bluemle58a48092017-05-03 00:04:06 +0800207 gradleVersion = '3.5'
Frieder Bluemlee231d682016-07-19 19:03:22 +0800208 distributionType = Wrapper.DistributionType.ALL
Ben Gruver93a43732017-05-17 11:32:05 -0700209}