TestKit Doesn't Find Java Source in Subprojects

plugins
(Ryan O'Meara) #1

I am trying to write some plug-in tests using Gradle test kit on a multi-module project. Each of the sub-projects has the java plug-in applied, and a Java source file in the standard location for the “main” and “test” source sets (src/main/java and src/test/java, respectively). When I run a task involving compilation, the runner output shows “NO SOURCE” for the Java compile tasks in the sub-projects.

This situation persists whether the source is in a named package or the default package, and regardless of whether I apply the java plugin in a subprojects block or individually in each of the two sub-projects.

The runner setup in the test looks like this:

BuildResult result = GradleRunner.create()
                .withPluginClasspath()
                .withProjectDir(testProjectDirectory)
                .withArguments("clean", "build", "--rerun-tasks")
                .build();

I have also tried assemble or compileJava directly as the task to the same result.

This is with Gradle version 3.5 (I know it’s behind, this issue is actually coming up because I’m trying to increase my plug-in’s test suite before I attempt upgrading it to work with later versions)

Has anyone solved this issue before, or have any ideas about other things I can try or may be incorrectly configured? Thanks for any guidance/help!

0 Likes