blob: 3678076faeb7fafe6cdf09c16765657362a90607 [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 Gruver76867f02019-04-04 11:15:17 -070034version = '2.2.7'
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'
Ben Gruver3a96d5d2012-10-29 21:42:29 -070060}
61
Ben Gruver5b411f32014-01-17 02:04:07 -080062// Note: please don't use this. This is strictly for the official releases
63// that are posted on, e.g. the bitbucket download page.
64task release() {
65}
66
Lanchon08bef5f2017-08-12 15:47:44 -030067task(install).doLast {
Ben Gruver6429b3d2016-02-14 18:45:17 -080068 println "Installing version: ${version}"
69}
70
Ben Gruver1d28b322014-01-18 11:33:39 -080071// The projects that get pushed to maven
72def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util']
73
Ben Gruver7d7ee582012-09-14 20:56:58 -070074subprojects {
75 apply plugin: 'java'
Ben Gruvercc5871f2012-09-16 00:18:03 -070076 apply plugin: 'idea'
Ben Gruver7d7ee582012-09-14 20:56:58 -070077
Ben Gruver0b42b4f2014-12-28 14:14:39 -080078 if (JavaVersion.current().isJava8Compatible()) {
79 allprojects {
80 tasks.withType(Javadoc) {
81 options.addStringOption('Xdoclint:none', '-quiet')
82 }
83 }
84 }
85
Ben Gruver3a96d5d2012-10-29 21:42:29 -070086 version = parent.version
Ben Gruver7d1263a2012-09-15 16:54:20 -070087
Ben Gruver46cefa32013-03-03 17:58:02 -080088 ext {
Ben Gruver29d714f2016-02-26 22:09:08 -080089 depends = [
90 guava: 'com.google.guava:guava:18.0',
91 findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
92 junit: 'junit:junit:4.6',
Ben Gruverdcaf46c2016-10-02 18:26:17 -070093 mockito: 'org.mockito:mockito-core:1.10.19',
Ben Gruver29d714f2016-02-26 22:09:08 -080094 antlr_runtime: 'org.antlr:antlr-runtime:3.5.2',
95 antlr: 'org.antlr:antlr:3.5.2',
96 stringtemplate: 'org.antlr:stringtemplate:3.2.1',
Ben Gruver07dc76c2016-07-09 13:42:15 -070097 jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0',
Ben Gruver29d714f2016-02-26 22:09:08 -080098 proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1',
99 dx: 'com.google.android.tools:dx:1.7',
Ben Gruver5a5eafb2016-04-10 22:08:11 -0700100 gson: 'com.google.code.gson:gson:2.3.1',
Ben Gruver75fdec62017-03-21 21:22:06 -0700101 jcommander: jcommanderVersion
102 ]
Ben Gruver46cefa32013-03-03 17:58:02 -0800103 }
104
Ben Gruver7d7ee582012-09-14 20:56:58 -0700105 repositories {
106 mavenCentral()
107 }
Ben Gruver7d1263a2012-09-15 16:54:20 -0700108
Ben Gruver1d28b322014-01-18 11:33:39 -0800109 if (project.name in maven_release_projects) {
110 apply plugin: 'maven'
111 apply plugin: 'signing'
Ben Gruver5b411f32014-01-17 02:04:07 -0800112
Ben Gruver1d28b322014-01-18 11:33:39 -0800113 group = 'org.smali'
Ben Gruver5b411f32014-01-17 02:04:07 -0800114
Ben Gruver1d28b322014-01-18 11:33:39 -0800115 task javadocJar(type: Jar, dependsOn: javadoc) {
116 classifier = 'javadoc'
117 from 'build/docs/javadoc'
118 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800119
Ben Gruver1d28b322014-01-18 11:33:39 -0800120 task sourcesJar(type: Jar) {
121 classifier = 'sources'
122 from sourceSets.main.allJava
123 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800124
Ben Gruver1d28b322014-01-18 11:33:39 -0800125 artifacts {
126 archives javadocJar
127 archives sourcesJar
128 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800129
Ben Gruver1d28b322014-01-18 11:33:39 -0800130 signing {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800131 required { gradle.taskGraph.hasTask('uploadArchives') }
Ben Gruver1d28b322014-01-18 11:33:39 -0800132 sign configurations.archives
133 }
134
135 uploadArchives {
136 repositories.mavenDeployer {
137 configuration = configurations.archives
138
139 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
140
141 if (rootProject.hasProperty('sonatypeUsername') && rootProject.hasProperty('sonatypePassword')) {
Ben Gruverf0c481a2015-03-01 22:00:30 -0800142 repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
Ben Gruver1d28b322014-01-18 11:33:39 -0800143 authentication(userName: sonatypeUsername, password: sonatypePassword)
Ben Gruver5b411f32014-01-17 02:04:07 -0800144 }
145 }
Ben Gruver1d28b322014-01-18 11:33:39 -0800146
147 pom.artifactId = project.name
148
149 pom.project {
150 name project.name
151 url 'http://smali.org'
152 packaging 'jar'
153 licenses {
154 license {
155 name 'The BSD 3-Clause License'
156 url 'http://opensource.org/licenses/BSD-3-Clause'
157 distribution 'repo'
158 }
159 }
160 scm {
161 connection 'scm:git:git://github.com/JesusFreke/smali.git'
162 developerConnection 'scm:git:git@github.com:JesusFreke/smali.git'
163 }
164 developers {
165 developer {
166 id 'jesusfreke'
167 name 'Ben Gruver'
168 email 'jesusfreke@jesusfreke.com'
169 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800170 }
171 }
172 }
173 }
Ben Gruver5b411f32014-01-17 02:04:07 -0800174
Ben Gruver1d28b322014-01-18 11:33:39 -0800175 tasks.getByPath(':release').dependsOn(uploadArchives)
176 }
Ben Gruver3a96d5d2012-10-29 21:42:29 -0700177}
Ben Gruver7d1263a2012-09-15 16:54:20 -0700178
179buildscript {
180 repositories {
181 mavenCentral()
182 }
183 dependencies {
184 classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
185 }
Ben Gruverdbce47d2013-10-10 20:29:34 -0700186}
187
188task wrapper(type: Wrapper) {
Ben Gruver97fd7962018-06-11 23:33:49 -0700189 gradleVersion = '4.6'
Frieder Bluemlee231d682016-07-19 19:03:22 +0800190 distributionType = Wrapper.DistributionType.ALL
Ben Gruver93a43732017-05-17 11:32:05 -0700191}