Advertisement
Guest User

Untitled

a guest
Jan 5th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 2.38 KB | None | 0 0
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'kotlin-kapt'
  3. apply plugin: 'kotlin-android'
  4. apply plugin: 'kotlin-android-extensions'
  5.  
  6. def protoPath = 'src/main/java/mopo/encryptedsms/data/network/proto'
  7. def wireGeneratedPath = 'build/generated/source/wire'
  8.  
  9. buildscript {
  10.     repositories {
  11.         // Used to fetch wire-compiler
  12.         mavenCentral()
  13.     }
  14.  
  15.     dependencies {
  16.         classpath 'com.squareup.wire:wire-compiler:2.2.0'
  17.     }
  18. }
  19.  
  20. android {
  21.     compileSdkVersion 26
  22.     defaultConfig {
  23.         applicationId "mopo.encryptedsms"
  24.         minSdkVersion 23
  25.         targetSdkVersion 26
  26.         versionCode 1
  27.         versionName "1.0"
  28.         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  29.     }
  30.     buildTypes {
  31.         release {
  32.             minifyEnabled false
  33.             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  34.         }
  35.     }
  36.     sourceSets {
  37.         main {
  38.             java {
  39.                 // Include the generated wire code so it is accessible/usable by our code
  40.                 srcDir wireGeneratedPath
  41.             }
  42.         }
  43.     }
  44. }
  45.  
  46. dependencies {
  47.     implementation fileTree(dir: 'libs', include: ['*.jar'])
  48.     implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  49.     testImplementation 'junit:junit:4.12'
  50.     androidTestImplementation 'com.android.support.test:runner:1.0.1'
  51.     androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
  52.  
  53.     implementation 'com.android.support:design:26.1.0'
  54.  
  55.     // "Wire": Protobuf encoding/decoding
  56.     implementation 'com.squareup.wire:wire-runtime:2.2.0'
  57. }
  58.  
  59. // This handles the Protobuf code generation with Wire
  60. task generateWireClasses {
  61.     println("Generating wire classes")
  62.     description = 'Generate Java classes from protocol buffer (.proto) schema files for use with squareup\'s wire library'
  63.     delete(wireGeneratedPath)
  64.     fileTree(dir: protoPath, include: '**/*.proto').each { File file ->
  65.         doLast {
  66.             javaexec {
  67.                 main = 'com.squareup.wire.WireCompiler'
  68.                 classpath = buildscript.configurations.classpath
  69.                 args = ["--proto_path=${protoPath}", "--java_out=${wireGeneratedPath}", "${file}"]
  70.             }
  71.         }
  72.     }
  73. }
  74.  
  75. // Do the Wire codegen before compiling anything
  76. preBuild.dependsOn generateWireClasses
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement