我必须在buildscript
buildscript {
dependencies {
classpath files (["project/path/to/compiled/classes"])
classpath ("com.project.plugin:custom-plugin:${pluginVersion}")
}
}
是否有可能以某种方式在插件类
中获取它们public class PluginClass implements Plugin<Project> {
@Override
public void apply(Project project) {
project.getExtensions().create("pluginConfig", PluginExtension.class);
project.getTasks().create("plugin", PluginTask.class);
}
}
或使用扩展程序传递它们?类似的东西:
porject.getDependencies().create(classpath_dependency)
答案 0 :(得分:5)
您可以通过dependencies
实例同时访问configurations
和project
:
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
}
}
}