/*
 * Copyright 2019 Kirill Rozov
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

tasks.register("sourceJar", Jar) {
    from android.sourceSets.main.java.srcDirs
    archiveClassifier.set('sources')
}

afterEvaluate {
    publishing {
        publications {
            releaseAar(MavenPublication) {
                from components.release
                groupId 'com.kirich1409.svgplugin'
                artifactId 'svg-glide4-plugin'
                version rootProject.ext.versionName

                pom {
                    name = 'SvgGlide4Plugin'
                    url = 'https://github.com/kirich1409/SvgGlidePlugins'
                    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 = "kirich1409"
                            name = "Kirill Rozov"
                            email = "krl.rozov@gmail.com"
                        }
                    }
                    scm {
                        url = "https://github.com/kirich1409/SvgGlidePlugins.git"
                    }
                }

                artifact sourceJar
            }
        }

        repositories {
            maven {
                name = "buildDir"
                // change to point to your repo, e.g. http://my.org/repo
                url = "$buildDir/repo"
            }
        }
    }
}

bintray {
    user = rootProject.hasProperty('user') ? rootProject.property('user') : System.getenv('BINTRAY_USER')
    key = rootProject.hasProperty('apiKey') ? rootProject.property('apiKey') : System.getenv('BINTRAY_API_KEY')

    publications = ["releaseAar"]

    pkg {
        repo = 'maven'
        name = 'svg-glide-plugin'
        desc = "Glide 4 Module which adds possibility to load SVG"
        userOrg = System.env.BINTRAY_USER_ORGANIZATION ?: ""
        licenses = ['Apache-2.0']
        vcsUrl = 'https://github.com/kirich1409/SvgGlidePlugins.git'
        websiteUrl = 'https://github.com/kirich1409/SvgGlidePlugins'
        issueTrackerUrl = 'https://github.com/kirich1409/SvgGlidePlugins/issues'
        labels = ['glide', 'svg']

        githubRepo = 'kirich1409/SvgGlidePlugins' //Optional Github repository
        githubReleaseNotesFile = 'README.md' //Optional Github readme file

        version {
            name = rootProject.ext.versionName
            vcsTag = rootProject.ext.versionName
        }
    }
}
