我创建了一个gradle插件(简称testinfra),它具有编译时间和运行时对其他两个jars的依赖。这是我的插件的build.gradle:
/**
* Define the dependencies for compiling the plugin code
*/
dependencies {
compile gradleApi()
compile localGroovy()
compile group:'com.mycompany.tools', name: 'lrgmanager', version: '1.0+'
compile group: 'com.mycompany.tools', name: 'LrgParser', version: '1.0+'
}
/**
* This task is responsible for publishing the plugin jar in the artifactory
*/
group = 'com.mycompany.tools'
version = '1.0'
publishing {
publications {
publishPlugin(MavenPublication) {
artifact jar
}
}
}我可以把我的插件罐到工匠。但是当我想要使用这个插件时,我必须指定插件的GAV及其依赖项。见下文:
/**
* define classpath for buildscript{}, to download the regression plugin and its dependencies
*/
buildscript {
dependencies {
classpath group: 'com.mycompany.tools', name: 'testinfra', version: '1.0+'
classpath group:'com.mycompany.tools', name: 'lrgmanager', version: '1.0+'
classpath group: 'com.mycompany.tools', name: 'LrgParser', version: '1.0+'
}
}
apply plugin: 'testinfra'我的要求是避免指定依赖的jar的GAV和testinfra插件GAV。是否有一种方法可以在发布期间配置我的pom.xml (发布任务),这样当我指定插件的GAV时,gradle就可以识别依赖项并下载它们吗?
为此,我试图参考gradle用户指南,但没有看到任何明确的示例。
发布于 2014-07-15 07:48:55
不要使用artifact jar,而是使用from components.java。然后,依赖项应该出现在POM中,而Gradle将自动将它们拉进来。
https://stackoverflow.com/questions/24751996
复制相似问题