Java 使用测试套件测试自定义Gradle插件
我正在尝试使用测试一个定制的Gradle插件 执行测试时,Gradle无法找到正在测试的插件Java 使用测试套件测试自定义Gradle插件,java,gradle,Java,Gradle,我正在尝试使用测试一个定制的Gradle插件 执行测试时,Gradle无法找到正在测试的插件 group 'com.example' gradlePlugin { plugins { simplePlugin { id = 'example' implementationClass = 'com.example.ExamplePlugin' } } } 我用Gradle 6.5编制了一份回购协议。测
group 'com.example'
gradlePlugin {
plugins {
simplePlugin {
id = 'example'
implementationClass = 'com.example.ExamplePlugin'
}
}
}
我用Gradle 6.5编制了一份回购协议。测试工具包文档告诉我,“Java Gradle插件开发插件”将提供与测试工具包的直接集成,但我得到的错误是,正在测试的插件在类路径上不可用
我试图找到另一个正在使用测试套件测试的、有效的示例插件,但没有任何东西向我跳出来。结果是我的代码中有几个问题
GradleRunner
plugins{id'example}
@Test
public void test() throws IOException {
writeFile(settingsFile, "rootProject.name = 'hello-world'");
writeFile(buildFile, "plugins { id 'com.example.example' }");
BuildResult result = GradleRunner.create()
.withProjectDir(testProjectDir.getRoot())
.withArguments("exampleTask")
.build();
assertThat(result.getOutput()).contains("Hello World!");
assertThat(result.task(":exampleTask"))
.isNotNull()
.hasFieldOrPropertyWithValue("outcome", TaskOutcome.SUCCESS);
}
* What went wrong:
Plugin [id: 'com.example.example'] was not found in any of the following sources: