1/* 2 * Copyright 2012, Google LLC 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions are 6 * met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * * Redistributions in binary form must reproduce the above 11 * copyright notice, this list of conditions and the following disclaimer 12 * in the documentation and/or other materials provided with the 13 * distribution. 14 * * Neither the name of Google LLC nor the names of its 15 * contributors may be used to endorse or promote products derived from 16 * this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31apply plugin: 'idea' 32 33version = '3.0.7' 34def jcommanderVersion = '' 35 36if (!('release' in gradle.startParameter.taskNames)) { 37 // we compile against 1.48 normally, to match what's in AOSP, but switch to a newer version 38 // for release, because it has some fixes required when running on Android 39 jcommanderVersion = 'com.beust:jcommander:1.48' 40 41 def versionSuffix 42 try { 43 def git = org.eclipse.jgit.api.Git.open(file('.')) 44 def head = git.getRepository().getRef('HEAD') 45 versionSuffix = head.getObjectId().abbreviate(8).name() 46 47 if (!git.status().call().clean) { 48 versionSuffix += '-dirty' 49 } 50 } catch (Exception) { 51 // In case we can't get the commit for some reason, 52 // just use -dev 53 versionSuffix = 'dev' 54 } 55 56 version += "-${versionSuffix}" 57} else { 58 jcommanderVersion = 'com.beust:jcommander:1.64' 59} 60 61// Note: please don't use this. This is strictly for the official releases 62// that are posted on, e.g. the bitbucket download page. 63task release() { 64} 65 66task(install).doLast { 67 println "Installing version: ${version}" 68} 69 70// The projects that get pushed to maven 71def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util'] 72 73subprojects { 74 apply plugin: 'java-library' 75 apply plugin: 'idea' 76 77 if (JavaVersion.current().isJava8Compatible()) { 78 allprojects { 79 tasks.withType(Javadoc) { 80 options.addStringOption('Xdoclint:none', '-quiet') 81 } 82 } 83 } 84 85 version = parent.version 86 87 java { 88 sourceCompatibility JavaVersion.VERSION_1_8 89 targetCompatibility JavaVersion.VERSION_1_8 90 } 91 92 jar { 93 from(project.rootDir) { 94 include 'LICENSE' 95 } 96 } 97 98 ext { 99 depends = [ 100 guava: 'com.google.guava:guava:31.1-android', 101 findbugs: 'com.google.code.findbugs:jsr305:1.3.9', 102 junit: 'junit:junit:4.12', 103 mockito: 'org.mockito:mockito-core:1.10.19', 104 antlr_runtime: 'org.antlr:antlr-runtime:3.5.2', 105 antlr: 'org.antlr:antlr:3.5.2', 106 stringtemplate: 'org.antlr:stringtemplate:3.2.1', 107 jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0', 108 proguard_gradle: 'com.guardsquare:proguard-gradle:7.1.0', 109 dx: 'com.google.android.tools:dx:1.7', 110 gson: 'com.google.code.gson:gson:2.3.1', 111 jcommander: jcommanderVersion 112 ] 113 } 114 115 repositories { 116 mavenCentral() 117 } 118 119 if (project.name in maven_release_projects) { 120 apply plugin: 'maven-publish' 121 apply plugin: 'signing' 122 123 group = 'com.android.tools.smali' 124 def artifact = project.name 125 if (artifact != 'smali') { 126 artifact = 'smali-' + artifact 127 } 128 129 publishing { 130 publications { 131 mavenJava(MavenPublication) { 132 artifactId = artifact 133 from components.java 134 versionMapping { 135 usage('java-api') { 136 fromResolutionOf('runtimeClasspath') 137 } 138 usage('java-runtime') { 139 fromResolutionResult() 140 } 141 } 142 143 pom { 144 name = project.name 145 url = 'https://github.com/google/smali' 146 147 licenses { 148 license { 149 name = 'The BSD 3-Clause License' 150 url = 'http://opensource.org/licenses/BSD-3-Clause' 151 distribution = 'repo' 152 } 153 } 154 scm { 155 connection = 'scm:git:git://github.com/google/smali.git' 156 developerConnection = 'scm:git:[email protected]:google/smali.git' 157 } 158 developers { 159 developer { 160 id = 'jesusfreke' 161 name = 'Ben Gruver' 162 email = '[email protected]' 163 } 164 developer { 165 name = 'The Android Open Source Project' 166 } 167 } 168 } 169 } 170 } 171 if (rootProject.hasProperty('sonatypeUsername') && rootProject.hasProperty('sonatypePassword')) { 172 repositories { 173 maven { 174 url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' 175 credentials { 176 username sonatypeUsername 177 password sonatypePassword 178 } 179 } 180 } 181 } 182 } 183 184 signing { 185 required { gradle.taskGraph.hasTask('publish') } 186 sign(publishing.publications["mavenJava"]) 187 } 188 189 java { 190 withJavadocJar() 191 withSourcesJar() 192 } 193 194 tasks.getByPath(':release').dependsOn(publish) 195 } 196} 197 198buildscript { 199 repositories { 200 mavenCentral() 201 } 202 dependencies { 203 classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r' 204 } 205} 206 207wrapper { 208 gradleVersion = '8.5' 209 distributionType = Wrapper.DistributionType.ALL 210} 211