blob: 8a705f59f165e2547d4bfd577469a20a552d4d19 [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 Gruver17f2abc2016-10-02 16:43:59 -070034version = '2.2b1'
Ben Gruver3a96d5d2012-10-29 21:42:29 -070035
Ben Gruver3a96d5d2012-10-29 21:42:29 -070036if (!('release' in gradle.startParameter.taskNames)) {
37 def versionSuffix
38 try {
39 def git = org.eclipse.jgit.api.Git.open(file('.'))
Ben Gruverf0c481a2015-03-01 22:00:30 -080040 def head = git.getRepository().getRef('HEAD')
Ben Gruver3a96d5d2012-10-29 21:42:29 -070041 versionSuffix = head.getObjectId().abbreviate(8).name()
42
43 if (!git.status().call().clean) {
44 versionSuffix += '-dirty'
45 }
46 } catch (Exception) {
47 // In case we can't get the commit for some reason,
48 // just use -dev
49 versionSuffix = 'dev'
50 }
51
Ben Gruver6429b3d2016-02-14 18:45:17 -080052 version += "-${versionSuffix}"
Ben Gruver583079c2015-04-30 23:26:23 -070053} else {
54 if (System.env.JDK6_HOME == null && !JavaVersion.current().isJava6()) {
55 throw new InvalidUserDataException("bzzzzzzzt. Release builds must be performed with java 6. " +
56 "Either run gradle with java 6, or define the JDK6_HOME environment variable.")
57 }
Ben Gruver3a96d5d2012-10-29 21:42:29 -070058}
59
Ben Gruver5b411f32014-01-17 02:04:07 -080060// Note: please don't use this. This is strictly for the official releases
61// that are posted on, e.g. the bitbucket download page.
62task release() {
63}
64
Ben Gruver6429b3d2016-02-14 18:45:17 -080065task(install) << {
66 println "Installing version: ${version}"
67}
68
Ben Gruver1d28b322014-01-18 11:33:39 -080069// The projects that get pushed to maven
70def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util']
71
Ben Gruver7d7ee582012-09-14 20:56:58 -070072subprojects {
73 apply plugin: 'java'
Ben Gruvercc5871f2012-09-16 00:18:03 -070074 apply plugin: 'idea'
Ben Gruver7d7ee582012-09-14 20:56:58 -070075
Ben Gruver0b42b4f2014-12-28 14:14:39 -080076 if (JavaVersion.current().isJava8Compatible()) {
77 allprojects {
78 tasks.withType(Javadoc) {
79 options.addStringOption('Xdoclint:none', '-quiet')
80 }
81 }
82 }
83
Ben Gruver583079c2015-04-30 23:26:23 -070084 if (System.env.JDK6_HOME != null) {
85 sourceCompatibility = 1.6
86 targetCompatibility = 1.6
87
88 tasks.withType(JavaCompile) {
89 doFirst {
90 options.fork = true
91 options.bootClasspath = "$System.env.JDK6_HOME/jre/lib/rt.jar"
92 options.bootClasspath += "$File.pathSeparator$System.env.JDK6_HOME/jre/lib/jsse.jar"
93 }
94 }
95 }
96
Ben Gruver3a96d5d2012-10-29 21:42:29 -070097 version = parent.version
Ben Gruver7d1263a2012-09-15 16:54:20 -070098
Ben Gruver46cefa32013-03-03 17:58:02 -080099 ext {
Ben Gruver29d714f2016-02-26 22:09:08 -0800100 depends = [
101 guava: 'com.google.guava:guava:18.0',
102 findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
103 junit: 'junit:junit:4.6',
Ben Gruver3587c6f2016-08-30 21:15:03 -0700104 mockito: 'org.mockito:mockito-core:1.+',
Ben Gruver29d714f2016-02-26 22:09:08 -0800105 antlr_runtime: 'org.antlr:antlr-runtime:3.5.2',
106 antlr: 'org.antlr:antlr:3.5.2',
107 stringtemplate: 'org.antlr:stringtemplate:3.2.1',
Ben Gruver07dc76c2016-07-09 13:42:15 -0700108 jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0',
Ben Gruver29d714f2016-02-26 22:09:08 -0800109 proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1',
110 dx: 'com.google.android.tools:dx:1.7',
Ben Gruver5a5eafb2016-04-10 22:08:11 -0700111 gson: 'com.google.code.gson:gson:2.3.1',
112 jcommander: 'com.beust:jcommander:1.48'
Ben Gruver46cefa32013-03-03 17:58:02 -0800113 ]
114 }
115
Ben Gruver7d7ee582012-09-14 20:56:58 -0700116 repositories {
117 mavenCentral()
118 }
Ben Gruver7d1263a2012-09-15 16:54:20 -0700119
Ben Gruver1d28b322014-01-18 11:33:39 -0800120 if (project.name in maven_release_projects) {
121 apply plugin: 'maven'
122 apply plugin: 'signing'
Ben Gruver5b411f32014-01-17 02:04:07 -0800123
Ben Gruver1d28b322014-01-18 11:33:39 -0800124 group = 'org.smali'
Ben Gruver5b411f32014-01-17 02:04:07 -0800125
Ben Gruver1d28b322014-01-18 11:33:39 -0800126 task javadocJar(type: Jar, dependsOn: javadoc) {
127 classifier = 'javadoc'
128 from 'build/docs/javadoc'
129 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800130
Ben Gruver1d28b322014-01-18 11:33:39 -0800131 task sourcesJar(type: Jar) {
132 classifier = 'sources'
133 from sourceSets.main.allJava
134 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800135
Ben Gruver1d28b322014-01-18 11:33:39 -0800136 artifacts {
137 archives javadocJar
138 archives sourcesJar
139 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800140
Ben Gruver1d28b322014-01-18 11:33:39 -0800141 signing {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800142 required { gradle.taskGraph.hasTask('uploadArchives') }
Ben Gruver1d28b322014-01-18 11:33:39 -0800143 sign configurations.archives
144 }
145
146 uploadArchives {
147 repositories.mavenDeployer {
148 configuration = configurations.archives
149
150 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
151
152 if (rootProject.hasProperty('sonatypeUsername') && rootProject.hasProperty('sonatypePassword')) {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800153 repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
Ben Gruver1d28b322014-01-18 11:33:39 -0800154 authentication(userName: sonatypeUsername, password: sonatypePassword)
Ben Gruver5b411f32014-01-17 02:04:07 -0800155 }
156 }
Ben Gruver1d28b322014-01-18 11:33:39 -0800157
158 pom.artifactId = project.name
159
160 pom.project {
161 name project.name
162 url 'http://smali.org'
163 packaging 'jar'
164 licenses {
165 license {
166 name 'The BSD 3-Clause License'
167 url 'http://opensource.org/licenses/BSD-3-Clause'
168 distribution 'repo'
169 }
170 }
171 scm {
172 connection 'scm:git:git://github.com/JesusFreke/smali.git'
173 developerConnection 'scm:git:git@github.com:JesusFreke/smali.git'
174 }
175 developers {
176 developer {
177 id 'jesusfreke'
178 name 'Ben Gruver'
179 email 'jesusfreke@jesusfreke.com'
180 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800181 }
182 }
183 }
184 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800185
Ben Gruver1d28b322014-01-18 11:33:39 -0800186 tasks.getByPath(':release').dependsOn(uploadArchives)
187 }
Ben Gruver3a96d5d2012-10-29 21:42:29 -0700188}
Ben Gruver7d1263a2012-09-15 16:54:20 -0700189
190buildscript {
191 repositories {
192 mavenCentral()
193 }
194 dependencies {
195 classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
196 }
Ben Gruverdbce47d2013-10-10 20:29:34 -0700197}
198
199task wrapper(type: Wrapper) {
Frieder Bluemlee231d682016-07-19 19:03:22 +0800200 gradleVersion = '3.1'
201 distributionType = Wrapper.DistributionType.ALL
Ben Gruver7d7ee582012-09-14 20:56:58 -0700202}