0
我想定義一個插件,它在gradle項目中設置repositories{...}
節以使用我們批准的代理和回購,並且不需要在每個項目中定義它們。我怎麼做?如何在Gradle插件中預置存儲庫部分?
我想定義一個插件,它在gradle項目中設置repositories{...}
節以使用我們批准的代理和回購,並且不需要在每個項目中定義它們。我怎麼做?如何在Gradle插件中預置存儲庫部分?
你可以做到這一點,例如通過以下方式:
apply plugin: 'java'
apply plugin: Lol
dependencies {
compile 'com.google.guava:guava:18.0'
}
task cl(type: Copy) {
from configurations.compile
into 'libs'
}
class Lol implements Plugin<Project> {
void apply(Project p) {
def repositoriesConf = {
mavenCentral()
jcenter()
}
p.repositories(repositoriesConf)
}
}
實現此任務的方法有很多種。請注意這個事實,也將需要java
插件,也許你需要實現的插件應該也應用java
插件。
@ChristianGoetze,我的答案是否解決了這個問題?如果是,請接受它。 – Opal