| apply plugin: 'com.android.application' |
| |
| android { |
| compileSdkVersion 23 |
| buildToolsVersion "23.0.2" |
| useLibrary 'org.apache.http.legacy' |
| namespace "google.simpleapplication" |
| |
| defaultConfig { |
| applicationId "google.simpleapplication" |
| minSdkVersion 21 |
| targetSdkVersion 23 |
| versionCode 1 |
| versionName "1.0" |
| } |
| buildTypes { |
| release { |
| minifyEnabled false |
| proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| } |
| } |
| lintOptions { |
| abortOnError false |
| } |
| |
| buildFeatures { |
| buildConfig true |
| } |
| } |
| |
| dependencies { |
| api fileTree(dir: 'libs', include: ['*.jar']) |
| api 'com.android.support:appcompat-v7:+' |
| api 'com.google.guava:guava:19.0' |
| api 'com.android.support.constraint:constraint-layout:1.0.2' |
| testImplementation 'junit:junit:4.12' |
| androidTestImplementation 'com.android.support.test:runner:+' |
| androidTestImplementation 'com.android.support.test.espresso:espresso-core:+' |
| } |
| |
| abstract class AssetGenerator extends DefaultTask { |
| @OutputDirectory |
| abstract DirectoryProperty getOutputDirectory(); |
| |
| @TaskAction |
| void run() { |
| def outputFile = new File(getOutputDirectory().get().getAsFile(), "generated.asset.txt") |
| new FileWriter(outputFile).with { |
| write("generated text") |
| flush() |
| } |
| } |
| } |
| |
| def writeAssetTask = tasks.register("createAssets", AssetGenerator.class) |
| androidComponents { |
| onVariants(selector().all(), { variant -> |
| variant.sources.assets.addGeneratedSourceDirectory(writeAssetTask, AssetGenerator::getOutputDirectory) |
| }) |
| } |