maven_push.gradle 1.28 KB
Newer Older
1 2
apply plugin: 'maven'

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

5 6
def getVersionName() {
    return hasProperty('VERSION_NAME') ? VERSION_NAME : rootProject.ext.ydlPublishVersion[project.getName()]
7
}
万齐军 committed
8 9 10 11 12 13 14
task sourceJar(type:Jar){
    classifier = 'source'
    from android.sourceSets.main.java.srcDirs
}
artifacts {
    archives sourceJar
}
15 16 17 18 19 20 21

afterEvaluate { project ->
    uploadArchives {
        repositories {
            mavenDeployer {
                pom.artifactId = project.getName().replace('_', "-")
                pom.groupId = "com.ydl"
22
                pom.version =  getVersionName()
万齐军 committed
23 24 25 26
                repository(url: mavenRepositoryUrl) {
                    authentication(userName: "admin", password: "fjoi#1+#@")
                }
//                repository(url:mavenLocal().url)
27 28 29 30 31 32 33 34
            }
        }
    }

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