配置

需要发布构件的模块 build.gradle 加入如下配置

apply plugin: 'maven-publish'

publishing {
publications {
mavenJava(MavenPublication) {
groupId 'io.github.shaobin0604'
artifactId 'gradle-plugin-replace'
version '1.0.0-SNAPSHOT' from components.java
// more goes in here
}
} repositories {
mavenLocal()
}
}

发布

$ ./gradlew <Module Name>:publishToMavenLocal

如何使用

添加本地仓库 mavenLocal()

buildscript {
repositories {
mavenLocal() // 添加本地仓库
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3' classpath 'io.github.shaobin0604:gradle-plugin-replace:1.0.0-SNAPSHOT' // 刚才发布的插件
}
} allprojects {
repositories {
mavenLocal() // 添加本地仓库
jcenter()
}
}

参考

05-28 00:56