Gradle配置Maven上传

来源:互联网 发布:淘宝如何参加9.9包邮 编辑:程序博客网 时间:2024/06/10 06:59

在module的build.gradle里加入maven相关的上传配置,由于本人测试,故很多代码先注释掉了。

/** *  Maven仓库构建 */apply plugin: 'maven'def NexusInfo = [        userName             : NEXUS_USERNAME,        password             : NEXUS_PASSWORD,        snapshotRepositoryUrl: SNAPSHOT_REPOSITORY_URL,        releaseRepositoryUrl : RELEASE_REPOSITORY_URL,        testRepositoryUrl    : TEST_REPOSITORY_URL,  // 测试上传地址        localRepositoryUrl   : LOCAL_REPOSITORY_PATH  // 本地maven上传测试]def localRepositoryFile = file(getProperty('LOCAL_REPOSITORY_PATH'))afterEvaluate { project ->    uploadArchives {        repositories {            mavenDeployer {                pom.project {                    groupId GROUP_ID                    artifactId ARTIFACT_ID                    version VERSION_NAME                    packaging PACKAGING                    description DESCRIPTION                }//                snapshotRepository(url: NexusInfo.snapshotRepositoryUrl) {//                    authentication(userName: NexusInfo.userName, password: NexusInfo.password)//                }//                repository(url: NexusInfo.releaseRepositoryUrl) {//                    authentication(userName: NexusInfo.userName, password: NexusInfo.password)//                }//                repository(url: NexusInfo.testRepositoryUrl) {//                    authentication(userName: NexusInfo.userName, password: NexusInfo.password)//                }                // 本地maven上传测试                repository(url: "file://${localRepositoryFile.absolutePath}")            }        }    }//    task androidJavadocs(type: Javadoc) {//        source = android.sourceSets.main.java.srcDirs//        classpath += project.files(android.getBootClasspath().join(File.pathSeparator))//    }//    task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {//        classifier = 'javadoc'//        from androidJavadocs.destinationDir//    }//    task androidSourcesJar(type: Jar) {//        classifier = 'sources'//        from android.sourceSets.main.java.sourceFiles//    }//    artifacts {//        archives androidSourcesJar//        archives androidJavadocsJar//    }}

在gradle.properties里定义上面所用到的常量,仓库地址都是我测试用的,可以改成自己要上传的地址

# maven项目打包属性GROUP_ID=com.xuhj.androidARTIFACT_ID=maven-testVERSION_NAME=1.0.0-SNAPSHOTSPACKAGING=arrDESCRIPTION=this is description# 账户信息NEXUS_USERNAME=xxxNEXUS_PASSWORD=xxx# maven仓库地址SNAPSHOT_REPOSITORY_URL=http://nexus/content/repositories/snapshots/RELEASE_REPOSITORY_URL=http://nexus/content/repositories/releases/TEST_REPOSITORY_URL=http://nexus/content/repositories/test/LOCAL_REPOSITORY_PATH=C:/XuHaojie/Android/maven/repository
0 0