在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.android
ARTIFACT_ID=maven-test
VERSION_NAME=1.0.0-SNAPSHOTS
PACKAGING=arr
DESCRIPTION=this is description
# 账户信息
NEXUS_USERNAME=xxx
NEXUS_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
最后
以上就是飘逸煎蛋最近收集整理的关于Gradle配置Maven上传的全部内容,更多相关Gradle配置Maven上传内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复