Skip to content

Instantly share code, notes, and snippets.

@TurpIF
Created November 25, 2019 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TurpIF/5a529a668b28c88407b873b055cc4945 to your computer and use it in GitHub Desktop.
Save TurpIF/5a529a668b28c88407b873b055cc4945 to your computer and use it in GitHub Desktop.
Gradle Android project with tests in dedicated subproject
// Lib build file
android {
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
subprojects {
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.1'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
// Tests build file
android {
defaultConfig {
multiDexEnabled true
}
}
dependencies {
implementation project(path: ':lib')
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation group: 'org.mockito', name: 'mockito-android', version: '3.1.0'
androidTestImplementation group: 'org.assertj', name: 'assertj-core', version: '3.14.0'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment