blob: d5c452726c7f1484fb35622105a542fb26e535c6 [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
Hans-Christoph Steiner86e83982019-01-09 12:58:03 +010077 lintConfig file("lint.xml")
Dominik Schürmann99aa8522016-08-01 23:06:54 +020078 }
79
Hans-Christoph Steiner9b578ed2016-08-11 15:03:34 +020080 File signFile = rootProject.file('signing.properties')
81 if (signFile.exists()) {
82 Properties properties = new Properties()
83 properties.load(new FileInputStream(signFile))
84 signingConfigs {
85 release {
86 storeFile rootProject.file(properties['key.store'])
87 storePassword properties['key.store.password']
88 keyAlias properties['key.alias']
89 keyPassword properties['key.alias.password']
90 }
91 }
92 buildTypes.release.signingConfig signingConfigs.release
93 }
Dominik Schürmann99aa8522016-08-01 23:06:54 +020094}
95
96checkstyle {
Hans-Christoph Steiner2fb71c82019-01-09 12:13:06 +010097 toolVersion = '7.2'
Dominik Schürmann99aa8522016-08-01 23:06:54 +020098}
99
100task checkstyle(type: Checkstyle) {
101 configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml")
102 source 'src/main/java'
103 include '**/*.java'
104
105 classpath = files()
106}