build.gradle revision 5b411f3447b1ad81152d477102303a6346e1c6ed
1a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch/*
25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * Copyright 2012, Google Inc.
35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * All rights reserved.
45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
5a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch * Redistribution and use in source and binary forms, with or without
6a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch * modification, are permitted provided that the following conditions are
75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * met:
85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     * Redistributions of source code must retain the above copyright
10a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch * notice, this list of conditions and the following disclaimer.
11a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch *     * Redistributions in binary form must reproduce the above
125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * in the documentation and/or other materials provided with the
145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * distribution.
155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
165821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * contributors may be used to endorse or promote products derived from
175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * this software without specific prior written permission.
185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) *
195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) */
315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)apply plugin: 'idea'
335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)version = '2.0.2'
355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)def jarVersion = version
375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)if (!('release' in gradle.startParameter.taskNames)) {
395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    def versionSuffix
405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    try {
415821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        def git = org.eclipse.jgit.api.Git.open(file('.'))
425821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        def head = git.getRepository().getRef("HEAD")
435821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        versionSuffix = head.getObjectId().abbreviate(8).name()
445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        if (!git.status().call().clean) {
465821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)            versionSuffix += '-dirty'
475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        }
485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    } catch (Exception) {
495821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        // In case we can't get the commit for some reason,
505821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        // just use -dev
515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)        versionSuffix = 'dev'
525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    }
535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    def baseVersion = version
555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    version = baseVersion + '-' + versionSuffix
565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // use something like module-1.2.3-dev.jar for the jar name, rather than the full
585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    // module-1.2.3-001afe02-dirty.jar
595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    jarVersion = baseVersion + '-dev'
605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Note: please don't use this. This is strictly for the official releases
635821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// that are posted on, e.g. the bitbucket download page.
645821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)task release() {
655821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}
665821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)
675821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)subprojects {
685821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    apply plugin: 'java'
695821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    apply plugin: 'idea'
705821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)    apply plugin: 'maven'
71a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    apply plugin: 'signing'
72
73    group = 'org.smali'
74    version = parent.version
75
76    ext {
77        depends = [guava: 'com.google.guava:guava:14.0',
78                   findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
79                   junit: 'junit:junit:4.6',
80                   antlr_runtime: 'org.antlr:antlr-runtime:3.5',
81                   antlr: 'org.antlr:antlr:3.5',
82                   commons_cli: 'commons-cli:commons-cli:1.2',
83                   jflex: 'de.jflex:jflex:1.4.3',
84                   proguard: 'net.sf.proguard:proguard-base:4.8'
85         ]
86    }
87
88    jar {
89        version = jarVersion
90    }
91
92    repositories {
93        mavenCentral()
94    }
95
96    signing {
97        required { gradle.taskGraph.hasTask("uploadArchives") }
98        sign configurations.archives
99    }
100
101    uploadArchives {
102        repositories.mavenDeployer {
103            configuration = configurations.archives
104
105            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
106
107            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
108                authentication(userName: sonatypeUsername, password: sonatypePassword)
109            }
110
111            pom.artifactId = project.name
112
113            pom.project {
114                name project.name
115                url 'http://smali.org'
116                packaging 'jar'
117                licenses {
118                    license {
119                        name 'The BSD 3-Clause License'
120                        url 'http://opensource.org/licenses/BSD-3-Clause'
121                        distribution 'repo'
122                    }
123                }
124                scm {
125                    connection 'scm:git:git://github.com/JesusFreke/smali.git'
126                    developerConnection 'scm:git:git@github.com:JesusFreke/smali.git'
127                }
128                developers {
129                    developer {
130                        id 'jesusfreke'
131                        name 'Ben Gruver'
132                        email 'jesusfreke@jesusfreke.com'
133                    }
134                }
135            }
136        }
137    }
138
139    tasks.getByPath(':release').dependsOn(uploadArchives)
140}
141
142buildscript {
143    repositories {
144        mavenCentral()
145    }
146    dependencies {
147        classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
148    }
149}
150
151task wrapper(type: Wrapper) {
152    gradleVersion = '1.8'
153}