apply plugin: 'maven'

def mavenRepositoryUrl = "http://nexus.yidianling.com/repository/AndroidReleases/"

def getVersionName() {
    return hasProperty('VERSION_NAME') ? VERSION_NAME : rootProject.ext.ydlPublishVersion[project.getName()]
}
task sourceJar(type:Jar){
    classifier = 'source'
    from android.sourceSets.main.java.srcDirs
}
artifacts {
    archives sourceJar
}

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                pom.artifactId = "m-" + project.name + "-api"
                pom.groupId = "com.ydl"
                pom.version =  project.version
                repository(url: mavenRepositoryUrl) {
                    authentication(userName: "admin", password: "fjoi#1+#@")
                }
//                repository(url:mavenLocal().url)
            }
        }
    }

    uploadArchives.doFirst {
        // log
        println String.format(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n>>>>> [%s] 正在将[%s]版本的[%s]包上传到Maven的[%s]仓库 >>>>>\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
                , project.getName()
                , project.version
                , "aar"
                , "release"
        )
    }
}