• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
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
32apply plugin: 'idea'
33
34version = '2.2.0'
35def jcommanderVersion = ''
36
37if (!('release' in gradle.startParameter.taskNames)) {
38    // 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
42    def versionSuffix
43    try {
44        def git = org.eclipse.jgit.api.Git.open(file('.'))
45        def head = git.getRepository().getRef('HEAD')
46        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
57    version += "-${versionSuffix}"
58} else {
59    jcommanderVersion = 'com.beust:jcommander:1.64'
60
61    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    }
65}
66
67// 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
72task(install) << {
73    println "Installing version: ${version}"
74}
75
76// The projects that get pushed to maven
77def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util']
78
79subprojects {
80    apply plugin: 'java'
81    apply plugin: 'idea'
82
83    if (JavaVersion.current().isJava8Compatible()) {
84        allprojects {
85            tasks.withType(Javadoc) {
86                options.addStringOption('Xdoclint:none', '-quiet')
87            }
88        }
89    }
90
91    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
104    version = parent.version
105
106    ext {
107        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',
111                mockito: 'org.mockito:mockito-core:1.10.19',
112                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',
115                jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0',
116                proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1',
117                dx: 'com.google.android.tools:dx:1.7',
118                gson: 'com.google.code.gson:gson:2.3.1',
119                jcommander: jcommanderVersion
120        ]
121    }
122
123    repositories {
124        mavenCentral()
125    }
126
127    if (project.name in maven_release_projects) {
128        apply plugin: 'maven'
129        apply plugin: 'signing'
130
131        group = 'org.smali'
132
133        task javadocJar(type: Jar, dependsOn: javadoc) {
134            classifier = 'javadoc'
135            from 'build/docs/javadoc'
136        }
137
138        task sourcesJar(type: Jar) {
139            classifier = 'sources'
140            from sourceSets.main.allJava
141        }
142
143        artifacts {
144            archives javadocJar
145            archives sourcesJar
146        }
147
148        signing {
149            required { gradle.taskGraph.hasTask('uploadArchives') }
150            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')) {
160                    repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
161                        authentication(userName: sonatypeUsername, password: sonatypePassword)
162                    }
163                }
164
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                        }
188                    }
189                }
190            }
191        }
192
193        tasks.getByPath(':release').dependsOn(uploadArchives)
194    }
195}
196
197buildscript {
198    repositories {
199        mavenCentral()
200    }
201    dependencies {
202        classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
203    }
204}
205
206task wrapper(type: Wrapper) {
207    gradleVersion = '3.1'
208    distributionType = Wrapper.DistributionType.ALL
209}