apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'signing'

sourceCompatibility = 1.6
group = 'org.quanqi'
version = "0.1.4"

repositories {
    mavenCentral()
}

dependencies {
    compile gradleApi()
    compile localGroovy()
    testCompile 'com.android.tools.build:gradle:0.11.0'
}


ext {
    sourceCompatibility = 1.6
    targetCompatibility = 1.6
    artifactId = 'android-signing'
}


task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from groovydoc
}

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

artifacts {
    archives jar
    archives javadocJar
    archives sourcesJar
}

if (project.hasProperty("signing.keyId")) {
    signing {
        sign configurations.archives
    }
}

uploadArchives {
    repositories {
        mavenDeployer {

            beforeDeployment { deployment -> signing.signPom(deployment) }

            if (project.hasProperty('NEXUS_USERNAME')) {
                snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
                    authentication(userName: project.getProperty('NEXUS_USERNAME'),
                            password: project.getProperty('NEXUS_PASSWORD'))
                }

                repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
                    authentication(userName: project.getProperty('NEXUS_USERNAME'),
                            password: project.getProperty('NEXUS_PASSWORD'))
                }
            }
            uniqueVersion = false

            pom.project {

                parent {
                    groupId 'org.sonatype.oss'
                    artifactId 'oss-parent'
                    version '7'
                }

                name 'Gradle android-signing plugin'
                packaging 'jar'
                description 'A plugin used for automatic keystore configration.'
                url 'https://github.com/dodocat/android-signing'

                scm {
                    url 'https://github.com/dodocat/android-signing'
                    connection 'scm:git:https://github.com/dodocat/android-signing.git'
                    developerConnection 'scm:git:https://github.com/dodocat/android-signing.git'
                }

                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                        distribution 'repo'
                    }
                }

                developers {
                    developer {
                        id 'dodocat'
                        name 'Cindy'
                    }
                }
            }
        }
    }
}
