赞
踩
创建Module项目后,选择Android Library。
apply plugin: 'groovy' dependencies { implementation gradleApi() implementation localGroovy() } sourceSets { main { groovy { srcDir 'src/main/groovy' } resources { srcDir 'src/main/resources' } } }
package com.testmodule
import org.gradle.api.Plugin
import org.gradle.api.Project
class Test implements Plugin<Project>{
@Override
void apply(Project target) {
target.task('testPrint') {
println "this is gradle plugin"
}
}
}
apply plugin: 'maven'
repositories {
mavenCentral()
}
uploadArchives {
repositories.mavenDeployer {
repository(url: uri('../release'))
pom.groupId = 'com.test.plugin'
pom.version = '1.0.0'
pom.artifactId = 'gradle-plugin-test'
}
}
目录结构(src/main/resources/META-INF)如下
peoperties中的内容为
implementation-class=com.testmodule.Test
dependencies {
classpath 'com.test.plugin:gradle-plugin-test:1.0.0'
}
allprojects {
repositories {
maven {
url uri('./release')
}
}
}
apply plugin: 'gradle-plugin-test'
./gradlew testPrint
输出内容
this is gradle plugin
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。