[英]get classpath dependency in custom gradle plugin
I have to declare dependency for my custom plugin in buildscript
我必须在
buildscript
为我的自定义插件声明依赖buildscript
buildscript {
dependencies {
classpath files (["project/path/to/compiled/classes"])
classpath ("com.project.plugin:custom-plugin:${pluginVersion}")
}
}
Is it possible to get them somehow inside plugin class 是否可以在插件类中以某种方式获取它们
public class PluginClass implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getExtensions().create("pluginConfig", PluginExtension.class);
project.getTasks().create("plugin", PluginTask.class);
}
}
or pass them using extension? 还是通过扩展名通过? Something like:
就像是:
porject.getDependencies().create(classpath_dependency)
You can access both dependencies
and configurations
via project
instance: 您可以通过
project
实例访问dependencies
和configurations
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.google.guava:guava:18.0'
}
}
apply plugin: LolPlugin
class LolPlugin implements Plugin<Project> {
public void apply(Project p) {
p.buildscript.dependencies.each {
println it
}
p.buildscript.configurations.classpath.each {
println it
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.