diff --git a/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java b/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java index 798e7c3b..34c85a5c 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/ModDevPlugin.java @@ -3,9 +3,9 @@ import net.neoforged.elc.configs.JavaApplicationLaunchConfig; import net.neoforged.moddevgradle.dsl.InternalModelHelper; import net.neoforged.moddevgradle.dsl.NeoForgeExtension; -import net.neoforged.moddevgradle.dsl.Parchment; import net.neoforged.moddevgradle.dsl.RunModel; import net.neoforged.moddevgradle.internal.utils.ExtensionUtils; +import net.neoforged.moddevgradle.internal.utils.IdeDetection; import net.neoforged.moddevgradle.tasks.JarJar; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -456,8 +456,9 @@ private void configureArtifactManifestTask(CreateArtifactManifestTask task, NeoF } private static boolean shouldUseCombinedSourcesAndClassesArtifact() { - return true; - // return Boolean.getBoolean("idea.active"); + // Only IntelliJ needs the combined artifact + // For Eclipse, we can attach the sources via the Eclipse project model. + return IdeDetection.isIntelliJ(); } private void addTemporaryRepositories(RepositoryHandler repositories) { @@ -692,7 +693,7 @@ private static void configureIntelliJModel(Project project, TaskProvider i // IDEA Sync has no real notion of tasks or providers or similar project.afterEvaluate(ignored -> { var settings = getIntelliJProjectSettings(rootProject); - if (settings != null && Boolean.getBoolean("idea.sync.active")) { + if (settings != null && IdeDetection.isIntelliJSync()) { // Also run the sync task directly as part of the sync. (Thanks Loom). var startParameter = project.getGradle().getStartParameter(); var taskRequests = new ArrayList<>(startParameter.getTaskRequests()); @@ -803,7 +804,6 @@ private static void configureEclipseModel(Project project, var sourcesPath = createArtifacts.get().getSourcesArtifact().get().getAsFile(); for (var entry : classpath.getEntries()) { - System.out.println(entry); if (entry instanceof Library library && classesPath.equals(new File(library.getPath()))) { library.setSourcePath(classpath.fileReference(sourcesPath)); } @@ -813,8 +813,7 @@ private static void configureEclipseModel(Project project, // Set up runs if running under buildship // TODO: This should be moved into its own task being triggered via eclipseModel.synchronizationTask - System.out.println(System.getProperties()); - if (System.getProperty("eclipse.application") != null) { + if (IdeDetection.isEclipse()) { project.afterEvaluate(ignored -> { for (var run : extension.getRuns()) { var prepareTask = prepareRunTasks.get(run).get(); @@ -851,7 +850,6 @@ private static void addEclipseLaunchConfiguration(Project project, var filename = run.getIdeName().get(); var file = project.file(".eclipse/configurations/" + filename + ".launch"); - System.out.println("Writing eclipse run " + file); file.getParentFile().mkdirs(); try (var writer = new FileWriter(file, false)) { diff --git a/src/main/java/net/neoforged/moddevgradle/internal/NeoFormRuntimeTask.java b/src/main/java/net/neoforged/moddevgradle/internal/NeoFormRuntimeTask.java index b3af587f..d123ccfd 100644 --- a/src/main/java/net/neoforged/moddevgradle/internal/NeoFormRuntimeTask.java +++ b/src/main/java/net/neoforged/moddevgradle/internal/NeoFormRuntimeTask.java @@ -1,5 +1,6 @@ package net.neoforged.moddevgradle.internal; +import net.neoforged.moddevgradle.internal.utils.IdeDetection; import net.neoforged.moddevgradle.internal.utils.NetworkSettingPassthrough; import org.gradle.api.DefaultTask; import org.gradle.api.file.ConfigurableFileCollection; @@ -81,6 +82,12 @@ protected final void run(List args) { // See https://github.com/gradle/gradle/issues/28959 execSpec.jvmArgs("-Dstdout.encoding=UTF-8", "-Dstderr.encoding=UTF-8"); + + // When running through IJ or Eclipse, always enable emojis + if (IdeDetection.isIntelliJ() || IdeDetection.isEclipse()) { + execSpec.args("--emojis"); + } + execSpec.executable(getNeoFormRuntimeLauncher().get().getExecutablePath().getAsFile()); execSpec.classpath(getNeoFormRuntime()); execSpec.args(realArgs); diff --git a/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java b/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java new file mode 100644 index 00000000..ca3857c4 --- /dev/null +++ b/src/main/java/net/neoforged/moddevgradle/internal/utils/IdeDetection.java @@ -0,0 +1,30 @@ +package net.neoforged.moddevgradle.internal.utils; + +/** + * Utilities for trying to detect in which IDE Gradle is running. + */ +public final class IdeDetection { + private IdeDetection() { + } + + /** + * @return true if IntelliJ is running Gradle. This is true both during sync and execution of other Gradle tasks. + */ + public static boolean isIntelliJ() { + return Boolean.getBoolean("idea.active"); + } + + /** + * @return true if IntelliJ is syncing its project model with Gradle. + */ + public static boolean isIntelliJSync() { + return Boolean.getBoolean("idea.sync.active"); + } + + /** + * @return true if running under Eclipse (either Task execution or otherwise) + */ + public static boolean isEclipse() { + return System.getProperty("eclipse.application") != null; + } +} diff --git a/testproject/build.gradle b/testproject/build.gradle index a581cc86..c3ea0695 100644 --- a/testproject/build.gradle +++ b/testproject/build.gradle @@ -47,7 +47,7 @@ neoForge { neoFormRuntime { useEclipseCompiler = true // enableCache = false - verbose = true + // verbose = true } parchment {