Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include the test module in the tested mod when running tests through IntelliJ #25

Merged
merged 2 commits into from
Jun 15, 2024
Merged
Changes from 1 commit
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
12 changes: 10 additions & 2 deletions src/main/java/net/neoforged/moddevgradle/internal/RunUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -199,8 +200,15 @@ public static ModFoldersProvider getIdeaModFoldersProvider(Project project, @Nul
.collect(Collectors.toMap(ModModel::getName, mod -> {
var modFolder = project.getObjects().newInstance(ModFolder.class);
modFolder.getFolders().from(InternalModelHelper.getModConfiguration(mod));
for (var sourceSet : mod.getModSourceSets().get()) {
// TODO: this is probably broken in multiproject builds
var sourceSets = new ArrayList<>(mod.getModSourceSets().get());
// Brings IJ in line with how we do it in Gradle
if (includeUnitTests) {
var testSourceSet = ExtensionUtils.getSourceSets(project).findByName("test");
if (testSourceSet != null && !sourceSets.contains(testSourceSet)) {
sourceSets.add(testSourceSet);
shartte marked this conversation as resolved.
Show resolved Hide resolved
}
}
for (var sourceSet : sourceSets) {
var sourceSetDir = outputDirectory.toPath().resolve(getIdeaOutName(sourceSet));
modFolder.getFolders().from(sourceSetDir.resolve("classes"));
modFolder.getFolders().from(sourceSetDir.resolve("resources"));
Expand Down
Loading