Created
July 19, 2018 05:15
-
-
Save gybin02/401241032a0383f44165dbc1f03aac9f to your computer and use it in GitHub Desktop.
gradle 打包到Maven
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven' | |
//apply plugin: 'com.github.dcendents.android-maven' | |
repositories { | |
mavenCentral() | |
} | |
//for project dependency | |
project.group = GROUP_ID | |
project.version = COMPONENT_VERSION | |
task deploy { | |
} | |
deploy.dependsOn uploadArchives | |
uploadArchives { | |
def typePattern = ~"[0-9]\\.[0-9]\\.[0-9]\$" | |
def depolyTypeUrl | |
if(typePattern.matcher(COMPONENT_VERSION)){ | |
println "warn ! find release version! will deploy release aar! version is $COMPONENT_VERSION " | |
depolyTypeUrl= deployUrl.replace("snapshots","releases") | |
}else { | |
depolyTypeUrl = deployUrl | |
} | |
// depolyTypeUrl= deployUrl.replace("snapshots","releases") | |
//println "depolyTypeUrl " + depolyTypeUrl | |
repositories.mavenDeployer { | |
repository(url: depolyTypeUrl) { | |
authentication(userName: deployUserName, password: deployPassword) | |
} | |
pom.project { | |
groupId GROUP_ID | |
artifactId POM_ARTIFACT_ID | |
packaging PACKAGE_FORMAT | |
version COMPONENT_VERSION | |
} | |
} | |
} | |
//上传源代码 | |
//task androidSourcesJar(type: Jar) { | |
// classifier = 'sources' | |
// from android.sourceSets.main.java.sourceFiles | |
//} | |
//artifacts { | |
// archives androidSourcesJar | |
//} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
1. mvn.gradle 文件放在Project同级目录
2. 修改库工程的Grade.properties文件,如果所示。新增 POM_ARTIFACT_ID 、GROUP_ID、COMPONENT_VERSION配置
3. 修改 同目录下build.gradle,在文件最末尾加上
4. 在Gradle视图中可以 就可以看到 uploadArchives 任务,双击运行。在Log那边可以看到 任务执行情况。