apply plugin: 'com.android.application' apply plugin: 'checkstyle' apply plugin: 'pmd' /* gets the version name from the latest Git tag, stripping the leading v off */ def getVersionName = { -> def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'describe', '--tags', '--always' standardOutput = stdout } return stdout.toString().trim() } dependencies { implementation 'com.android.support:support-v4:27.1.1' implementation 'com.android.support:appcompat-v7:27.1.1' implementation 'com.android.support:gridlayout-v7:27.1.1' implementation 'com.android.support:support-annotations:27.1.1' implementation 'com.android.support:recyclerview-v7:27.1.1' implementation 'com.android.support:cardview-v7:27.1.1' implementation 'com.android.support:design:27.1.1' implementation 'com.android.support:support-vector-drawable:27.1.1' implementation 'com.android.support.constraint:constraint-layout:1.1.0' implementation 'com.android.support:palette-v7:27.1.1' implementation 'com.android.support:preference-v14:27.1.1' implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' implementation 'com.google.zxing:core:3.3.2' implementation 'eu.chainfire:libsuperuser:1.0.0.201602271131' implementation 'cc.mvdan.accesspoint:library:0.2.0' implementation 'info.guardianproject.netcipher:netcipher:2.0.0-alpha1' implementation 'info.guardianproject.panic:panic:0.5' implementation 'commons-io:commons-io:2.5' implementation 'commons-net:commons-net:3.5' implementation 'org.jmdns:jmdns:3.5.3' implementation 'org.nanohttpd:nanohttpd:2.3.1' implementation 'ch.acra:acra:4.9.1' implementation 'io.reactivex:rxjava:1.1.0' implementation 'io.reactivex:rxandroid:0.23.0' implementation 'com.hannesdorfmann:adapterdelegates3:3.0.1' implementation 'com.ashokvarma.android:bottom-navigation-bar:2.0.4' implementation 'com.fasterxml.jackson.core:jackson-core:2.8.7' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.7' implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.7' implementation 'org.bouncycastle:bcpkix-jdk15on:1.59' implementation 'org.bouncycastle:bcprov-jdk15on:1.59' testImplementation 'org.robolectric:robolectric:3.8' testImplementation 'junit:junit:4.12' testImplementation 'org.mockito:mockito-core:2.7.22' androidTestImplementation 'com.android.support:support-annotations:25.3.1' androidTestImplementation 'com.android.support.test:runner:0.5' androidTestImplementation 'com.android.support.test:rules:0.5' } def isCi = "true".equals(System.getenv("CI")) def preDexEnabled = "true".equals(System.getProperty("pre-dex", "true")) android { compileSdkVersion 27 buildToolsVersion '27.0.3' buildTypes { // use proguard on debug too since we have unknowingly broken // release builds before. all { minifyEnabled true useProguard true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'src/androidTest/proguard-rules.pro' } } compileOptions { compileOptions.encoding = "UTF-8" } aaptOptions { cruncherEnabled = false } dexOptions { // Improve build server performance by allowing disabling of pre-dexing // see http://tools.android.com/tech-docs/new-build-system/tips#TOC-Improving-Build-Server-performance // Skip pre-dexing when running on CI or when disabled via -Dpre-dex=false. preDexLibraries = preDexEnabled && !isCi } defaultConfig { versionCode 1003000 versionName getVersionName() applicationId 'org.fdroid.fdroid' resValue "string", "applicationId", applicationId testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { debug { applicationIdSuffix ".debug" resValue "string", "applicationId", defaultConfig.applicationId + applicationIdSuffix versionNameSuffix "-debug" } } /* set the debug versionCode based on DB verson and how many commits in the repo */ applicationVariants.all { variant -> if (variant.buildType.isDebuggable()) { // default to a timestamp, in case anything fails later variant.mergedFlavor.versionCode = new Date().getTime() / 1000 try { def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD' standardOutput = stdout } def commitCount = Integer.parseInt(stdout.toString().trim()) stdout = new ByteArrayOutputStream() exec { commandLine 'sed', '-n', 's,.*DB_VERSION *= *\\([0-9][0-9]*\\).*,\\1,p', 'src/main/java/org/fdroid/fdroid/data/DBHelper.java' standardOutput = stdout } def dbVersion = Integer.parseInt(stdout.toString().trim()) println 'Setting debug versionCode: ' + sprintf("%d%05d", [dbVersion, commitCount]) variant.mergedFlavor.versionCode = Integer.parseInt(sprintf("%d%05d", [dbVersion, commitCount])) } catch (ignored) { } } } testOptions { unitTests { includeAndroidResources = true // prevent tests from dying on android.util.Log calls returnDefaultValues = true all { // All the usual Gradle options. testLogging { events "skipped", "failed", "standardOut", "standardError" showStandardStreams = true } } } } sourceSets { test { java.srcDirs += "$projectDir/src/testShared/java" } androidTest { java.srcDirs += "$projectDir/src/testShared/java" } } lintOptions { checkReleaseBuilds false abortOnError true htmlReport true xmlReport false textReport false lintConfig file("lint.xml") } packagingOptions { exclude 'META-INF/LICENSE' exclude 'META-INF/LICENSE.txt' exclude 'META-INF/NOTICE' exclude 'META-INF/NOTICE.txt' exclude 'META-INF/INDEX.LIST' exclude '.readme' } } checkstyle { toolVersion = '7.2' } task checkstyle(type: Checkstyle) { configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") source 'src/main/java', 'src/test/java', 'src/androidTest/java' include '**/*.java' classpath = files() } pmd { toolVersion = '5.5.1' consoleOutput = true } task pmdMain(type: Pmd) { dependsOn 'assembleDebug' ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-main.xml") ruleSets = [] // otherwise defaults clash with the list in rules.xml source 'src/main/java' include '**/*.java' exclude '**/kellinwood/**/*.java' } task pmdTest(type: Pmd) { dependsOn 'assembleDebug' ruleSetFiles = files("${project.rootDir}/config/pmd/rules.xml", "${project.rootDir}/config/pmd/rules-test.xml") ruleSets = [] // otherwise defaults clash with the list in rules.xml source 'src/test/java', 'src/androidTest/java' include '**/*.java' } task pmd(dependsOn: [pmdMain, pmdTest]) {}