diff --git a/src/main/java/org/gradle/playframework/plugins/PlayApplicationPlugin.java b/src/main/java/org/gradle/playframework/plugins/PlayApplicationPlugin.java index 67728223..1749610f 100644 --- a/src/main/java/org/gradle/playframework/plugins/PlayApplicationPlugin.java +++ b/src/main/java/org/gradle/playframework/plugins/PlayApplicationPlugin.java @@ -110,6 +110,10 @@ private void configureJavaAndScalaSourceSet(Project project) { mainScalaSourceDirectorySet.srcDir(getTwirlCompileTask(project).flatMap(task -> task.getOutputDirectory())); mainScalaSourceDirectorySet.srcDir(getRoutesCompileTask(project).flatMap(task -> task.getOutputDirectory())); + SourceSet testSourceSet = PlayPluginHelper.getTestJavaSourceSet(project); + SourceDirectorySet testResourcesDirectorySet = testSourceSet.getResources(); + testResourcesDirectorySet.setSrcDirs(Arrays.asList("test/resources")); + SourceDirectorySet testScalaSourceDirectorySet = PlayPluginHelper.getTestScalaSourceDirectorySet(project); testScalaSourceDirectorySet.setSrcDirs(Arrays.asList("test")); testScalaSourceDirectorySet.include("**/*.scala", "**/*.java"); diff --git a/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java b/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java new file mode 100644 index 00000000..4b40ac65 --- /dev/null +++ b/src/test/java/org/gradle/playframework/plugins/PluginResourceDirectoryTests.java @@ -0,0 +1,55 @@ +package org.gradle.playframework.plugins; + +import org.gradle.api.Project; +import org.gradle.api.file.SourceDirectorySet; +import org.gradle.api.tasks.SourceSet; +import org.gradle.playframework.plugins.internal.PlayPluginHelper; +import org.gradle.testfixtures.ProjectBuilder; +import org.junit.Test; + +import java.io.File; +import java.util.Collections; + +import static org.junit.Assert.assertEquals; + +public class PluginResourceDirectoryTests { + @Test + public void testResourcesDirectories() { + // given + Project project = ProjectBuilder + .builder() + .build(); + + // when + project.getPluginManager().apply(PlayPlugin.class); + + SourceSet mainSourceSet = PlayPluginHelper.getMainJavaSourceSet(project); + SourceDirectorySet mainResourcesDirectorySet = mainSourceSet.getResources(); + + // then + assertEquals( + Collections.singleton(new File(project.getProjectDir(), "conf")), + mainResourcesDirectorySet.getSrcDirs() + ); + } + + @Test + public void testTestResourcesDirectories() { + // given + Project project = ProjectBuilder + .builder() + .build(); + + // when + project.getPluginManager().apply(PlayPlugin.class); + + SourceSet testSourceSet = PlayPluginHelper.getTestJavaSourceSet(project); + SourceDirectorySet testResourcesDirectorySet = testSourceSet.getResources(); + + // then + assertEquals( + Collections.singleton(new File(project.getProjectDir(), "test/resources")), + testResourcesDirectorySet.getSrcDirs() + ); + } +}