1181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver/*
2181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * Copyright 2012, Google Inc.
3181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * All rights reserved.
4181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *
5181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * Redistribution and use in source and binary forms, with or without
6181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * modification, are permitted provided that the following conditions are
7181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * met:
8181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *
9181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *     * Redistributions of source code must retain the above copyright
10181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * notice, this list of conditions and the following disclaimer.
11181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *     * Redistributions in binary form must reproduce the above
12181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * copyright notice, this list of conditions and the following disclaimer
13181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * in the documentation and/or other materials provided with the
14181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * distribution.
15181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *     * Neither the name of Google Inc. nor the names of its
16181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * contributors may be used to endorse or promote products derived from
17181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * this software without specific prior written permission.
18181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver *
19181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver */
31181c04c839c38d6f2b9ef6214c2ec858307a70eeBen Gruver
32cc5871feefe53677894415df69e294e92ccb0521Ben Gruverapply plugin: 'idea'
33cc5871feefe53677894415df69e294e92ccb0521Ben Gruver
347cf2b33cbdd81c1661e8b59356999cf98116595fBen Gruverversion = '2.0.3'
357d7ee58ad94dc2ea4cd35e3b8e14577648e3bdddBen Gruver
363a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruverdef jarVersion = version
377d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
383a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruverif (!('release' in gradle.startParameter.taskNames)) {
393a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    def versionSuffix
403a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    try {
413a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        def git = org.eclipse.jgit.api.Git.open(file('.'))
423a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        def head = git.getRepository().getRef("HEAD")
433a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        versionSuffix = head.getObjectId().abbreviate(8).name()
447d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
453a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        if (!git.status().call().clean) {
463a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver            versionSuffix += '-dirty'
473a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        }
483a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    } catch (Exception) {
493a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        // In case we can't get the commit for some reason,
503a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        // just use -dev
513a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        versionSuffix = 'dev'
523a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    }
537d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
543a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    def baseVersion = version
553a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    version = baseVersion + '-' + versionSuffix
565cf9fe7c0af588670265a5804dfae9ab8bb5c391Ben Gruver
573a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    // use something like module-1.2.3-dev.jar for the jar name, rather than the full
583a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    // module-1.2.3-001afe02-dirty.jar
593a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    jarVersion = baseVersion + '-dev'
603a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver}
615cf9fe7c0af588670265a5804dfae9ab8bb5c391Ben Gruver
625b411f3447b1ad81152d477102303a6346e1c6edBen Gruver// Note: please don't use this. This is strictly for the official releases
635b411f3447b1ad81152d477102303a6346e1c6edBen Gruver// that are posted on, e.g. the bitbucket download page.
645b411f3447b1ad81152d477102303a6346e1c6edBen Gruvertask release() {
655b411f3447b1ad81152d477102303a6346e1c6edBen Gruver}
665b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
673a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruversubprojects {
683a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    apply plugin: 'java'
693a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    apply plugin: 'idea'
705b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    apply plugin: 'maven'
715b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    apply plugin: 'signing'
723a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver
735b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    group = 'org.smali'
743a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    version = parent.version
753a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver
7646cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver    ext {
7746cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver        depends = [guava: 'com.google.guava:guava:14.0',
7846cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver                   findbugs: 'com.google.code.findbugs:jsr305:1.3.9',
7946cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver                   junit: 'junit:junit:4.6',
800dceb148f3c09311513e07665c65e581edc46a0dBen Gruver                   antlr_runtime: 'org.antlr:antlr-runtime:3.5',
810dceb148f3c09311513e07665c65e581edc46a0dBen Gruver                   antlr: 'org.antlr:antlr:3.5',
8246cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver                   commons_cli: 'commons-cli:commons-cli:1.2',
8346cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver                   jflex: 'de.jflex:jflex:1.4.3',
8446cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver                   proguard: 'net.sf.proguard:proguard-base:4.8'
8546cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver         ]
8646cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver    }
8746cefa3d5be5a99484075cf60d1c55ca36ccffd3Ben Gruver
883a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver    jar {
893a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver        version = jarVersion
907d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver    }
917d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
927d7ee58ad94dc2ea4cd35e3b8e14577648e3bdddBen Gruver    repositories {
937d7ee58ad94dc2ea4cd35e3b8e14577648e3bdddBen Gruver        mavenCentral()
947d7ee58ad94dc2ea4cd35e3b8e14577648e3bdddBen Gruver    }
957d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
965b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    signing {
975b411f3447b1ad81152d477102303a6346e1c6edBen Gruver        required { gradle.taskGraph.hasTask("uploadArchives") }
985b411f3447b1ad81152d477102303a6346e1c6edBen Gruver        sign configurations.archives
995b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    }
1005b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1015b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    uploadArchives {
1025b411f3447b1ad81152d477102303a6346e1c6edBen Gruver        repositories.mavenDeployer {
1035b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            configuration = configurations.archives
1045b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1055b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
1065b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1075b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
1085b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                authentication(userName: sonatypeUsername, password: sonatypePassword)
1095b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            }
1105b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1115b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            pom.artifactId = project.name
1125b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1135b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            pom.project {
1145b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                name project.name
1155b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                url 'http://smali.org'
1165b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                packaging 'jar'
1175b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                licenses {
1185b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    license {
1195b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        name 'The BSD 3-Clause License'
1205b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        url 'http://opensource.org/licenses/BSD-3-Clause'
1215b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        distribution 'repo'
1225b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    }
1235b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                }
1245b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                scm {
1255b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    connection 'scm:git:git://github.com/JesusFreke/smali.git'
1265b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    developerConnection 'scm:git:git@github.com:JesusFreke/smali.git'
1275b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                }
1285b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                developers {
1295b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    developer {
1305b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        id 'jesusfreke'
1315b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        name 'Ben Gruver'
1325b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                        email 'jesusfreke@jesusfreke.com'
1335b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                    }
1345b411f3447b1ad81152d477102303a6346e1c6edBen Gruver                }
1355b411f3447b1ad81152d477102303a6346e1c6edBen Gruver            }
1365b411f3447b1ad81152d477102303a6346e1c6edBen Gruver        }
1375b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    }
1385b411f3447b1ad81152d477102303a6346e1c6edBen Gruver
1395b411f3447b1ad81152d477102303a6346e1c6edBen Gruver    tasks.getByPath(':release').dependsOn(uploadArchives)
1403a96d5d432ed10f94ddf2a9a9d5af9c5593e9b0dBen Gruver}
1417d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver
1427d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruverbuildscript {
1437d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver    repositories {
1447d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver        mavenCentral()
1457d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver    }
1467d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver    dependencies {
1477d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver        classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
1487d1263a4ff78ce92b2008e4664fb855f7d03da87Ben Gruver    }
149dbce47d36172093de6e1425e8847efa679718435Ben Gruver}
150dbce47d36172093de6e1425e8847efa679718435Ben Gruver
151dbce47d36172093de6e1425e8847efa679718435Ben Gruvertask wrapper(type: Wrapper) {
152dbce47d36172093de6e1425e8847efa679718435Ben Gruver    gradleVersion = '1.8'
1537d7ee58ad94dc2ea4cd35e3b8e14577648e3bdddBen Gruver}