Dominik Schürmann | 1bb476c | 2016-08-09 23:35:31 +0200 | [diff] [blame] | 1 | apply plugin: 'com.android.application' |
| 2 | apply plugin: 'checkstyle' |
| 3 | |
Hans-Christoph Steiner | 76c07a3 | 2016-08-09 15:21:01 +0200 | [diff] [blame] | 4 | /* gets the version name from the latest Git tag, stripping the leading v off */ |
| 5 | def getVersionName = { -> |
| 6 | def stdout = new ByteArrayOutputStream() |
| 7 | exec { |
| 8 | commandLine 'git', 'describe', '--tags', '--always' |
| 9 | standardOutput = stdout |
| 10 | } |
Hans-Christoph Steiner | 3a4804b | 2016-08-16 17:09:59 +0200 | [diff] [blame] | 11 | return stdout.toString().trim() |
Hans-Christoph Steiner | 76c07a3 | 2016-08-09 15:21:01 +0200 | [diff] [blame] | 12 | } |
| 13 | |
Hans-Christoph Steiner | 655374f | 2016-12-01 15:34:39 +0100 | [diff] [blame] | 14 | gradle.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ürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 25 | repositories { |
| 26 | jcenter() |
| 27 | } |
| 28 | |
Dominik Schürmann | 1bb476c | 2016-08-09 23:35:31 +0200 | [diff] [blame] | 29 | dependencies { |
| 30 | testCompile 'junit:junit:4.12' |
| 31 | |
Hans-Christoph Steiner | c9681a7 | 2017-03-14 21:25:19 +0100 | [diff] [blame] | 32 | androidTestCompile 'com.android.support:support-annotations:25.3.0' |
Dominik Schürmann | 1bb476c | 2016-08-09 23:35:31 +0200 | [diff] [blame] | 33 | androidTestCompile 'com.android.support.test:runner:0.5' |
| 34 | androidTestCompile 'com.android.support.test:rules:0.5' |
| 35 | } |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 36 | |
| 37 | android { |
Hans-Christoph Steiner | 1ae586a | 2017-03-14 21:24:32 +0100 | [diff] [blame] | 38 | compileSdkVersion 25 |
Hans-Christoph Steiner | 66d8f02 | 2017-03-14 21:23:53 +0100 | [diff] [blame] | 39 | buildToolsVersion '24.0.0' |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 40 | |
| 41 | defaultConfig { |
Hans-Christoph Steiner | 863c559 | 2018-03-21 17:42:44 +0100 | [diff] [blame] | 42 | archivesBaseName = "F-DroidPrivilegedExtension" |
Hans-Christoph Steiner | 3a4804b | 2016-08-16 17:09:59 +0200 | [diff] [blame] | 43 | versionName getVersionName() |
Hans-Christoph Steiner | 76c07a3 | 2016-08-09 15:21:01 +0200 | [diff] [blame] | 44 | |
Dominik Schürmann | 1bb476c | 2016-08-09 23:35:31 +0200 | [diff] [blame] | 45 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 46 | } |
| 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 Steiner | 2bc946f | 2017-07-18 16:25:03 +0200 | [diff] [blame] | 56 | aaptOptions { |
| 57 | cruncherEnabled = false |
| 58 | } |
| 59 | |
relan | 5c58c3e | 2016-08-11 22:04:26 +0300 | [diff] [blame] | 60 | buildTypes { |
| 61 | all { |
| 62 | // Keep IPackageInstallObserver and IPackageDeleteObserver |
| 63 | minifyEnabled false |
| 64 | useProguard false |
| 65 | shrinkResources false |
| 66 | } |
| 67 | } |
| 68 | |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 69 | lintOptions { |
Hans-Christoph Steiner | e40a250 | 2016-08-08 16:36:31 +0200 | [diff] [blame] | 70 | checkReleaseBuilds false |
| 71 | abortOnError true |
| 72 | |
| 73 | htmlReport true |
| 74 | xmlReport false |
| 75 | textReport false |
| 76 | |
Hans-Christoph Steiner | 86e8398 | 2019-01-09 12:58:03 +0100 | [diff] [blame] | 77 | lintConfig file("lint.xml") |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 78 | } |
| 79 | |
Hans-Christoph Steiner | 9b578ed | 2016-08-11 15:03:34 +0200 | [diff] [blame] | 80 | 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ürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 94 | } |
| 95 | |
| 96 | checkstyle { |
Hans-Christoph Steiner | 2fb71c8 | 2019-01-09 12:13:06 +0100 | [diff] [blame] | 97 | toolVersion = '7.2' |
Dominik Schürmann | 99aa852 | 2016-08-01 23:06:54 +0200 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | task 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 | } |