aboutsummaryrefslogtreecommitdiff
path: root/third_party/sl4a/build.gradle
blob: d5d4518708633f1543b2917174ac0a6ec5337c27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
    }
}

plugins {
    id 'com.github.sherter.google-java-format' version '0.8'
    id 'com.github.dcendents.android-maven' version '2.0'
}


apply plugin: 'com.android.library'
apply plugin: 'com.jfrog.bintray'


android {
    compileSdkVersion 26

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 22
        // testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        versionCode VERSION_CODE.toInteger()
        versionName VERSION_NAME

        // Need to set up some project properties to publish to bintray.
        project.group = GROUP_ID
        project.archivesBaseName = ARTIFACT_ID
        project.version = VERSION_NAME
    }

    splits {
        abi {
          enable true
          reset()
          // Specifies a list of ABIs that Gradle should create APKs for.
          include "arm64-v8a", "armeabi-v7a", "armeabi"
          universalApk true
        }
    }

    lintOptions {
        abortOnError false
        checkAllWarnings true
        warningsAsErrors true
        disable 'HardwareIds','MissingApplicationIcon','GoogleAppIndexingWarning','InvalidPackage','OldTargetApi'
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {
    // implementation fileTree(include: ['*.jar'], dir: 'libs')
    // implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'junit:junit:4.12'
    implementation 'com.android.support.test:runner:1.0.2'
}

googleJavaFormat {
    options style: 'AOSP'
}

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    source = android.sourceSets.main.java.srcDirs
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

// bintray packaging information
install {
    repositories.mavenInstaller {
        pom.project {
            name ARTIFACT_ID
            description
                'Android library for triggering device-side code from ' +
                'host-side Mobly tests.'
            url 'https://github.com/google/mobly-snippet-lib'

            packaging 'aar'
            groupId GROUP_ID
            artifactId ARTIFACT_ID
            version VERSION_NAME
            name ARTIFACT_ID

            licenses {
                license {
                    name 'The Apache Software License, Version 2.0'
                    url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    distribution 'repo'
                }
            }
            scm {
                connection 'https://github.com/google/mobly-snippet-lib.git'
                url 'https://github.com/google/mobly-snippet-lib'
            }
        }
    }
}

// Try loading bintray.properties. It's okay if this fails; we might not be
// uploading.
def bintrayPropFile = project.rootProject.file('bintray.properties')
if (bintrayPropFile.exists()) {
    Properties prop = new Properties()
    prop.load(new FileInputStream(bintrayPropFile))
    project.ext.bintrayUser = prop.user
    project.ext.bintrayKey = prop.key
} else {
    project.ext.bintrayUser = null
    project.ext.bintrayKey = null
}

gradle.taskGraph.whenReady { graph ->
    if (graph.hasTask(bintrayUpload)) {
        if (project.bintrayUser == null || project.bintrayKey == null) {
            if (bintrayPropFile.exists()) {
                throw new IllegalArgumentException(
                    bintrayPropFile.toString()
                    + ' does not contain "user" or "key" props')
            } else {
                throw new FileNotFoundException(
                    'bintray.properties not found at path: ' + bintrayPropFile)
            }
        }
    }
}

bintray {
    user = project.bintrayUser
    key = project.bintrayKey
    configurations = ['archives']
    pkg {
        repo = 'mobly'
        name = ARTIFACT_ID
        userOrg = 'google'
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/google/mobly-snippet-lib.git'
        version {
            name = VERSION_NAME
            desc = 'Mobly Snippet Lib ' + VERSION_NAME
            released  = new Date()
            vcsTag = VERSION_NAME
        }
    }
}

// Open lint's HTML report in your default browser or viewer.
task openLintReport(type: Exec) {
    def lint_report = "build/reports/lint-results.html"
    def cmd = "cat"
    def platform = System.getProperty('os.name').toLowerCase(Locale.ROOT)
    if (platform.contains("linux")) {
        cmd = "xdg-open"
    } else if (platform.contains("mac os x")) {
        cmd = "open"
    } else if (platform.contains("windows")) {
        cmd = "launch"
    }
    commandLine cmd, lint_report
}

task presubmit {
    dependsOn { ['googleJavaFormat', 'lint', 'openLintReport'] }
    doLast {
        println "Fix any lint issues you see. When it looks good, submit the pull request."
    }
}