【发布时间】:2014-07-15 07:09:48
【问题描述】:
我创建了一个 gradle 插件(简称为 testinfra),它的编译时间和运行时依赖于其他 2 个 jar。这是我的插件的 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
}
}
}
我可以将我的插件 jar 推送到 artifactory。但是当我想使用插件时,我必须指定插件的 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 用户指南,但我没有看到任何明确的示例。
【问题讨论】:
-
我想您应该使用
maven插件并适当地配置uploadArchives任务。你在用吗?见这里:gradle.org/docs/current/userguide/maven_plugin.html -
我正在使用“maven-publish”插件