Plugins 是否可以扩展二进制插件中配置的gradle构建脚本?
我在下面创建了一个Gradle插件:Plugins 是否可以扩展二进制插件中配置的gradle构建脚本?,plugins,build,gradle,build-script,Plugins,Build,Gradle,Build Script,我在下面创建了一个Gradle插件: class CommandServiceProjectPlugin implements Plugin<Project> { public void apply(Project project) { project.buildscript{ repositories { maven: { url: 'http://localhost:8081/artifactory/
class CommandServiceProjectPlugin implements Plugin<Project> {
public void apply(Project project) {
project.buildscript{
repositories {
maven: {
url: 'http://localhost:8081/artifactory/zailab-virtual-repo'
credentials: {
username = "admin"
password = "password"
}
}
}
/*Spring Boot Gradle plugin */
dependencies {
classpath: 'org.springframework.boot:spring-boot-gradle-plugin:1.1.6.RELEASE'
}
}
project.apply plugin: 'spring-boot'
project.apply plugin: 'java'
project.apply plugin: 'eclipse'
project.repositories {
maven: {
url: 'http://localhost:8081/artifactory/zailab-virtual-repo'
}
}
project.dependencies {
/*Spring Boot dependencies */
compile: 'org.springframework.boot:spring-boot-starter-test'
compile: 'org.springframework.boot:spring-boot-starter-aop'
compile: 'org.springframework.boot:spring-boot-starter-data-mongodb'
compile: 'org.springframework.boot:spring-boot-starter-integration'
compile: 'org.springframework.boot:spring-boot-starter-amqp'
/*Axon dependencies */
compile: 'org.axonframework:axon-core:2.3.1'
compile: 'org.axonframework:axon-mongo:2.3.1'
}
}
}
谢谢,
Roscoe据我所知,不可能从插件以编程方式添加构建脚本依赖项。 原因是构建脚本的生命周期——插件的apply方法调用发生在项目的类路径配置已经解决之后
您应该在项目的构建脚本中配置构建脚本,或者使用插件打包类路径依赖项 或者在插件模块的POM/Ivy描述符中列出依赖项。有人能给出一个选项(或两者)的示例吗。谢谢
buildscript {
repositories {
maven {
url 'http://localhost:8081/artifactory/zailab-virtual-repo'
credentials {
username = "admin"
password = "password"
}
}
}
dependencies {
classpath(group: 'com.zailab', name: 'zailab-command-service-build', version: '1.0.0- SNAPSHOT')
}
}
apply plugin: 'com.zailab.command.service.project'