Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
);
}
}