• 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.7'
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
62// 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
67task(install).doLast {
68    println "Installing version: ${version}"
69}
70
71// The projects that get pushed to maven
72def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util']
73
74subprojects {
75    apply plugin: 'java'
76    apply plugin: 'idea'
77
78    if (JavaVersion.current().isJava8Compatible()) {
79        allprojects {
80            tasks.withType(Javadoc) {
81                options.addStringOption('Xdoclint:none', '-quiet')
82            }
83        }
84    }
85
86    version = parent.version
87
88    ext {
89        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',
93                mockito: 'org.mockito:mockito-core:1.10.19',
94                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',
97                jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0',
98                proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1',
99                dx: 'com.google.android.tools:dx:1.7',
100                gson: 'com.google.code.gson:gson:2.3.1',
101                jcommander: jcommanderVersion
102        ]
103    }
104
105    repositories {
106        mavenCentral()
107    }
108
109    if (project.name in maven_release_projects) {
110        apply plugin: 'maven'
111        apply plugin: 'signing'
112
113        group = 'org.smali'
114
115        task javadocJar(type: Jar, dependsOn: javadoc) {
116            classifier = 'javadoc'
117            from 'build/docs/javadoc'
118        }
119
120        task sourcesJar(type: Jar) {
121            classifier = 'sources'
122            from sourceSets.main.allJava
123        }
124
125        artifacts {
126            archives javadocJar
127            archives sourcesJar
128        }
129
130        signing {
131            required { gradle.taskGraph.hasTask('uploadArchives') }
132            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')) {
142                    repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') {
143                        authentication(userName: sonatypeUsername, password: sonatypePassword)
144                    }
145                }
146
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                        }
170                    }
171                }
172            }
173        }
174
175        tasks.getByPath(':release').dependsOn(uploadArchives)
176    }
177}
178
179buildscript {
180    repositories {
181        mavenCentral()
182    }
183    dependencies {
184        classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
185    }
186}
187
188task wrapper(type: Wrapper) {
189    gradleVersion = '4.6'
190    distributionType = Wrapper.DistributionType.ALL
191}
192