apply plugin: 'com.android.library'

android {
  compileSdkVersion Integer.parseInt(project.COMPILE_SDK_VERSION)
  buildToolsVersion BUILD_TOOLS_VERSION

  defaultConfig {
    minSdkVersion project.MINIMUM_SDK_VERSION
  }

  lintOptions {
    abortOnError false
  }

  buildTypes {
    debug {
      minifyEnabled false
    }
    release {
      minifyEnabled false
      shrinkResources false
    }
  }

  testOptions {
    unitTests.all {
      testLogging {
        events "passed", "skipped", "failed", "standardOut", "standardError"
        outputs.upToDateWhen { false }
        showStandardStreams = true
      }
    }
  }

  flavorDimensions "mode"
  productFlavors {
    internal {
      dimension "mode"
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SCHEME",
          "\"" + project.APTOIDE_WEB_SERVICES_SCHEME_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_HOST_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_V7_HOST_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_V7_CACHE_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_V7_CACHE_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_APTWORDS_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_APTWORDS_HOST_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_WRITE_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_WRITE_V7_HOST_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_NOTIFICATION_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_NOTIFICATION_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_READ_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_READ_V7_HOST_DEVELOPMENT + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SEARCH_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_SEARCH_NO_SSL_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SEARCH_SSL_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_SEARCH_SSL_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_AB_TESTING_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_AB_TESTING_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_AB_TEST_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_AB_TEST_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_REACTIONS_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_REACTIONS_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_RAKAM_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_RAKAM_HOST + "\""
      matchingFallbacks = ['internal', 'prod']
    }
    prod {
      dimension "mode"
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SCHEME",
          "\"" + project.APTOIDE_WEB_SERVICES_SCHEME_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_V7_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_V7_CACHE_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_V7_CACHE_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_APTWORDS_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_APTWORDS_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_WRITE_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_WRITE_V7_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_NOTIFICATION_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_NOTIFICATION_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_READ_V7_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_READ_V7_HOST_PRODUCTION + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SEARCH_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_SEARCH_NO_SSL_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_SEARCH_SSL_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_SEARCH_SSL_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_AB_TESTING_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_AB_TESTING_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_AB_TEST_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_AB_TEST_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_REACTIONS_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_REACTIONS_HOST + "\""
      buildConfigField "String", "APTOIDE_WEB_SERVICES_RAKAM_HOST",
          "\"" + project.APTOIDE_WEB_SERVICES_RAKAM_HOST + "\""
      matchingFallbacks = ['prod', 'internal']
    }
  }

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/MANIFEST.MF'
    exclude 'META-INF/LGPL2.1'
  }
}

dependencies {
  implementation fileTree(include: ['*.jar'], dir: 'libs')
  implementation project(path: ':aptoidepreferences')
  implementation project(path: ':crashreports')
  implementation project(path: ':appcoins')
  compileOnly project(path: ':utils')

  testImplementation "com.squareup.okhttp3:mockwebserver:${MOCK_WEB_SERVER_VERSION}"
  testImplementation "junit:junit:${JUNIT_VERSION}"
  testImplementation "org.mockito:mockito-core:${MOCKITO_CORE_VERSION}"

  //noinspection GradleDependency
  implementation "androidx.appcompat:appcompat:${APPCOMPAT_VERSION}"
  //noinspection GradleDependency
  implementation "com.google.android.gms:play-services-base:${PLAY_SERVICES_BASEMENT_VERSION}"

  implementation "io.reactivex:rxjava:${RXJAVA_VERSION}"
  implementation "io.reactivex:rxandroid:${RXANDROID_VERSION}"
  implementation "nl.littlerobots.rxlint:rxlint:${Rx_lint_version}"
  // And ProGuard rules for RxJava!
  implementation "com.artemzin.rxjava:proguard-rules:${RXJAVA_PROGUARD_RULES_VERSION}"
  implementation "com.squareup.retrofit2:retrofit:${RETROFIT_VERSION}"
  implementation "com.squareup.retrofit2:adapter-rxjava:${RETROFIT_VERSION}"
  implementation "com.squareup.retrofit2:converter-jackson:${RETROFIT_VERSION}"
  implementation "com.fasterxml.jackson.core:jackson-databind:${JACKSON_VERSION}"

  // Rxjava Interop
  implementation "com.github.akarnokd:rxjava2-interop:${RXJAVA2_INTEROP}"

  implementation("com.squareup.okhttp3:logging-interceptor:${OKHTTP_VERSION}") {
    force = true
  }

  // Parceler - https://github.com/johncarl81/parceler
  compileOnly "org.parceler:parceler-api:${PARCELER_VERSION}"
  annotationProcessor "org.parceler:parceler:${PARCELER_VERSION}"
}
