plugins - 未找到自定义 Gradle 插件 ID

我正在编写一个 Gradle 插件,但无法让 apply plugin: 命令在使用该插件的 Gradle 脚本中工作。我正在使用 Gradle 1.1。

我已经用 clean build 构建了插件,我现在正尝试通过一个平面 repo 将它添加到 Gradle 构建中。这似乎有效,但 Gradle 没有发现有一个 ID 为 test-plugin 的插件。插件的 settings.gradle 中的项目名称是 test-plugin 并且 META-INF/gradle-plugins 中的属性文件也是 test-plugin.properties。我不确定在哪里可以指定插件 ID。

项目中使用test-pluginbuild.gradle文件:

repositories {
  flatDir name: 'libs', dirs: "../build/libs"
}

dependencies {
  compile 'test:test-plugin:0.1'
}

apply plugin: 'test-plugin'

来自 Gradle 的错误:

What went wrong:
A problem occurred evaluating root project 'tmp'.
Plugin with id 'test-plugin' not found.

最佳答案

插件 Jar 必须添加为 构建脚本依赖项:

buildscript {
    repositories { flatDir name: 'libs', dirs: "../build/libs" }
    dependencies { classpath 'test:test-plugin:0.1' }
}

apply plugin: "test-plugin"

https://stackoverflow.com/questions/12569916/

相关文章:

xcode - 了解 Xcode 的 Copy Headers 阶段

build - Gradle 全局构建目录

gcc - g++ 输出 : file not recognized: File format no

gradle - 如何更改 gradle 插件存储库?

c# - NuGet 以代码 -1 退出 - 结果构建失败

java - 错误 :Could not initialize class com. android

ios - 如何在 Xcode 4 中自动增加捆绑版本?

c# - 如何获得本地 Visual Studio 构建完成的通知?

command-line - 如何从命令行构建 IntelliJ 项目?

tfs - Cruise Control .Net 与 Team Foundation 构建