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.1.3' 35 36if (!('release' in gradle.startParameter.taskNames)) { 37 def versionSuffix 38 try { 39 def git = org.eclipse.jgit.api.Git.open(file('.')) 40 def head = git.getRepository().getRef('HEAD') 41 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 52 version += "-${versionSuffix}" 53} 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 } 58} 59 60// 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 65task(install) << { 66 println "Installing version: ${version}" 67} 68 69// The projects that get pushed to maven 70def maven_release_projects = ['smali', 'baksmali', 'dexlib2', 'util'] 71 72subprojects { 73 apply plugin: 'java' 74 apply plugin: 'idea' 75 76 if (JavaVersion.current().isJava8Compatible()) { 77 allprojects { 78 tasks.withType(Javadoc) { 79 options.addStringOption('Xdoclint:none', '-quiet') 80 } 81 } 82 } 83 84 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 97 version = parent.version 98 99 ext { 100 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', 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 commons_cli: 'commons-cli:commons-cli:1.2', 108 jflex_plugin: 'org.xbib.gradle.plugin:gradle-plugin-jflex:1.1.0', 109 proguard_gradle: 'net.sf.proguard:proguard-gradle:5.2.1', 110 dx: 'com.google.android.tools:dx:1.7', 111 gson: 'com.google.code.gson:gson:2.3.1' 112 ] 113 } 114 115 repositories { 116 mavenCentral() 117 } 118 119 if (project.name in maven_release_projects) { 120 apply plugin: 'maven' 121 apply plugin: 'signing' 122 123 group = 'org.smali' 124 125 task javadocJar(type: Jar, dependsOn: javadoc) { 126 classifier = 'javadoc' 127 from 'build/docs/javadoc' 128 } 129 130 task sourcesJar(type: Jar) { 131 classifier = 'sources' 132 from sourceSets.main.allJava 133 } 134 135 artifacts { 136 archives javadocJar 137 archives sourcesJar 138 } 139 140 signing { 141 required { gradle.taskGraph.hasTask('uploadArchives') } 142 sign configurations.archives 143 } 144 145 uploadArchives { 146 repositories.mavenDeployer { 147 configuration = configurations.archives 148 149 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } 150 151 if (rootProject.hasProperty('sonatypeUsername') && rootProject.hasProperty('sonatypePassword')) { 152 repository(url: 'https://oss.sonatype.org/service/local/staging/deploy/maven2/') { 153 authentication(userName: sonatypeUsername, password: sonatypePassword) 154 } 155 } 156 157 pom.artifactId = project.name 158 159 pom.project { 160 name project.name 161 url 'http://smali.org' 162 packaging 'jar' 163 licenses { 164 license { 165 name 'The BSD 3-Clause License' 166 url 'http://opensource.org/licenses/BSD-3-Clause' 167 distribution 'repo' 168 } 169 } 170 scm { 171 connection 'scm:git:git://github.com/JesusFreke/smali.git' 172 developerConnection 'scm:git:git@github.com:JesusFreke/smali.git' 173 } 174 developers { 175 developer { 176 id 'jesusfreke' 177 name 'Ben Gruver' 178 email 'jesusfreke@jesusfreke.com' 179 } 180 } 181 } 182 } 183 } 184 185 tasks.getByPath(':release').dependsOn(uploadArchives) 186 } 187} 188 189buildscript { 190 repositories { 191 mavenCentral() 192 } 193 dependencies { 194 classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r' 195 } 196} 197 198task wrapper(type: Wrapper) { 199 gradleVersion = '2.14' 200}