buildscript {
  repositories {
    jcenter()
    mavenCentral()
  }
  dependencies {
    classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
  }
}
plugins {
  id "com.jfrog.bintray" version "1.7"
}

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'

def libVersionCode = '2.0.3'
def siteUrl = 'https://github.com/dlazaro66/QRCodeReaderView/tree/master/QRCodeReaderView-lib'
def gitUrl = 'https://github.com/dlazaro66/QRCodeReaderView/tree/master/QRCodeReaderView-lib.git'

group = "com.dlazaro66.qrcodereaderview"
version = libVersionCode

android {

  lintOptions {
    abortOnError false
  }

  compileSdkVersion 26
  buildToolsVersion '26.0.2'

  defaultConfig {
    minSdkVersion 14
    targetSdkVersion 26
    versionCode 1
    versionName libVersionCode
  }

  buildTypes {
    release {
      minifyEnabled false
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
  }
}

dependencies {
  compile 'com.google.zxing:core:3.2.1'
  testCompile 'junit:junit:4.12'
  testCompile 'org.mockito:mockito-core:2.7.5'
  testCompile "org.robolectric:robolectric:3.2.2"
}

install {
  repositories.mavenInstaller {
    pom {
      project {
        packaging 'aar'
        name 'QRCodeReaderView'
        description =
            'Android view which show camera and notify when there\'s a QR code inside the preview.'
        url siteUrl
        licenses {
          license {
            name 'The Apache Software License, Version 2.0'
            url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
          }
        }
        developers {
          developer {
            id 'dlazaro66'
            name 'David Lázaro'
            email 'dlazaro66@gmail.com'
          }
        }
        scm {
          connection gitUrl
          developerConnection gitUrl
          url siteUrl
        }
      }
    }
  }
}


bintray {
  user = project.findProperty('bintrayUser')
  key = project.findProperty('bintrayApiKey')
  configurations = ['archives']
  publish = true
  pkg {
    version {
      name = libVersionCode
      desc = 'Android view which show camera and notify when there\'s a QR code inside the preview.'
      released = new Date()
      vcsTag = libVersionCode
      gpg {
        sign = true //Determines whether to GPG sign the files. The default is false
        passphrase = project.findProperty('gpgPassphrase') //Optional. The passphrase for GPG signing'
      }
    }
    repo = "maven"
    name = "QRCodeReaderView"
    websiteUrl = siteUrl
    vcsUrl = gitUrl
    licenses = ["Apache-2.0"]
  }
}

task wrapper(type: Wrapper) {
  gradleVersion = '2.4'
}

task sourcesJar(type: Jar) {
  from android.sourceSets.main.java.srcDirs
  classifier = 'sources'
}

task javadoc(type: Javadoc) {
  source = android.sourceSets.main.java.srcDirs
  classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}

task javadocJar(type: Jar, dependsOn: javadoc) {
  classifier = 'javadoc'
  from javadoc.destinationDir
}
artifacts {
  archives javadocJar
  archives sourcesJar
}

task findConventions << {
  println project.getConvention()
}


