blob: 0bcb69b7d57697e49f608d94370669b515472154 [file] [log] [blame]
Dominik Schürmann1bb476c2016-08-09 23:35:31 +02001apply plugin: 'com.android.application'
2apply plugin: 'checkstyle'
3
Hans-Christoph Steiner76c07a32016-08-09 15:21:01 +02004/* gets the version name from the latest Git tag, stripping the leading v off */
5def getVersionName = { ->
6 def stdout = new ByteArrayOutputStream()
7 exec {
8 commandLine 'git', 'describe', '--tags', '--always'
9 standardOutput = stdout
10 }
Hans-Christoph Steiner3a4804b2016-08-16 17:09:59 +020011 return stdout.toString().trim()
Hans-Christoph Steiner76c07a32016-08-09 15:21:01 +020012}
13
Hans-Christoph Steiner655374f2016-12-01 15:34:39 +010014gradle.allprojects {
15 ext.getVersionCode = { ->
16 def manifestFile = file("app/src/main/AndroidManifest.xml")
17 def pattern = Pattern.compile("versionCode=\"(\\d+)\"")
18 def manifestText = manifestFile.getText()
19 def matcher = pattern.matcher(manifestText)
20 matcher.find()
21 return Integer.parseInt(matcher.group(1))
22 }
23}
24
Dominik Schürmann99aa8522016-08-01 23:06:54 +020025repositories {
26 jcenter()
27}
28
Dominik Schürmann1bb476c2016-08-09 23:35:31 +020029dependencies {
30 testCompile 'junit:junit:4.12'
31
Hans-Christoph Steinerc9681a72017-03-14 21:25:19 +010032 androidTestCompile 'com.android.support:support-annotations:25.3.0'
Dominik Schürmann1bb476c2016-08-09 23:35:31 +020033 androidTestCompile 'com.android.support.test:runner:0.5'
34 androidTestCompile 'com.android.support.test:rules:0.5'
35}
Dominik Schürmann99aa8522016-08-01 23:06:54 +020036
37android {
Hans-Christoph Steiner1ae586a2017-03-14 21:24:32 +010038 compileSdkVersion 25
Hans-Christoph Steiner66d8f022017-03-14 21:23:53 +010039 buildToolsVersion '24.0.0'
Dominik Schürmann99aa8522016-08-01 23:06:54 +020040
41 defaultConfig {
Hans-Christoph Steiner863c5592018-03-21 17:42:44 +010042 archivesBaseName = "F-DroidPrivilegedExtension"
Hans-Christoph Steiner3a4804b2016-08-16 17:09:59 +020043 versionName getVersionName()
Hans-Christoph Steiner76c07a32016-08-09 15:21:01 +020044
Dominik Schürmann1bb476c2016-08-09 23:35:31 +020045 testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Dominik Schürmann99aa8522016-08-01 23:06:54 +020046 }
47
48 compileOptions {
49 compileOptions.encoding = "UTF-8"
50
51 // Use Java 1.7, requires minSdk 8
52 sourceCompatibility JavaVersion.VERSION_1_7
53 targetCompatibility JavaVersion.VERSION_1_7
54 }
55
Hans-Christoph Steiner2bc946f2017-07-18 16:25:03 +020056 aaptOptions {
57 cruncherEnabled = false
58 }
59
relan5c58c3e2016-08-11 22:04:26 +030060 buildTypes {
61 all {
62 // Keep IPackageInstallObserver and IPackageDeleteObserver
63 minifyEnabled false
64 useProguard false
65 shrinkResources false
66 }
67 }
68
Dominik Schürmann99aa8522016-08-01 23:06:54 +020069 lintOptions {
Hans-Christoph Steinere40a2502016-08-08 16:36:31 +020070 checkReleaseBuilds false
71 abortOnError true
72
73 htmlReport true
74 xmlReport false
75 textReport false
76
Dominik Schürmann1bb476c2016-08-09 23:35:31 +020077 // this is never going to be a real "app"
78 disable 'GoogleAppIndexingWarning'
Dominik Schürmann99aa8522016-08-01 23:06:54 +020079 }
80
Hans-Christoph Steiner9b578ed2016-08-11 15:03:34 +020081 File signFile = rootProject.file('signing.properties')
82 if (signFile.exists()) {
83 Properties properties = new Properties()
84 properties.load(new FileInputStream(signFile))
85 signingConfigs {
86 release {
87 storeFile rootProject.file(properties['key.store'])
88 storePassword properties['key.store.password']
89 keyAlias properties['key.alias']
90 keyPassword properties['key.alias.password']
91 }
92 }
93 buildTypes.release.signingConfig signingConfigs.release
94 }
Dominik Schürmann99aa8522016-08-01 23:06:54 +020095}
96
97checkstyle {
Hans-Christoph Steiner9db56cf2016-08-10 11:59:55 +020098 toolVersion = '7.1'
Dominik Schürmann99aa8522016-08-01 23:06:54 +020099}
100
101task checkstyle(type: Checkstyle) {
102 configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
103 source 'src/main/java'
104 include '**/*.java'
105
106 classpath = files()
107}