diff --git a/build.gradle b/build.gradle index 53b5e1d..74ec4d8 100644 --- a/build.gradle +++ b/build.gradle @@ -37,9 +37,6 @@ repositories { url = 'https://maven.fabricmc.net/' } mavenCentral() - maven { - url = 'https://plugins.gradle.org/m2/' - } mavenLocal() } @@ -95,9 +92,6 @@ dependencies { // source code remapping implementation ('net.fabricmc:mercury:0.2.4') - // IDEA support - implementation ('gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext:1.1.1') - // Kapt integration compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0') diff --git a/src/main/java/net/fabricmc/loom/configuration/ide/idea/IdeaConfiguration.java b/src/main/java/net/fabricmc/loom/configuration/ide/idea/IdeaConfiguration.java index 17a646d..a8055d6 100644 --- a/src/main/java/net/fabricmc/loom/configuration/ide/idea/IdeaConfiguration.java +++ b/src/main/java/net/fabricmc/loom/configuration/ide/idea/IdeaConfiguration.java @@ -24,19 +24,11 @@ package net.fabricmc.loom.configuration.ide.idea; -import java.util.Objects; +import java.util.List; -import org.gradle.api.NamedDomainObjectContainer; import org.gradle.api.Project; -import org.gradle.api.plugins.ExtensionAware; import org.gradle.api.tasks.TaskProvider; -import org.gradle.plugins.ide.idea.model.IdeaModel; -import org.gradle.plugins.ide.idea.model.IdeaProject; -import org.jetbrains.gradle.ext.ActionDelegationConfig; -import org.jetbrains.gradle.ext.IdeaExtPlugin; -import org.jetbrains.gradle.ext.ProjectSettings; -import org.jetbrains.gradle.ext.RunConfiguration; -import org.jetbrains.gradle.ext.TaskTriggersConfig; +import org.gradle.execution.taskgraph.TaskExecutionGraphInternal; public class IdeaConfiguration { public static void setup(Project project) { @@ -48,36 +40,8 @@ public class IdeaConfiguration { return; } - project.getPlugins().apply(IdeaExtPlugin.class); - project.getPlugins().withType(IdeaExtPlugin.class, ideaExtPlugin -> { - if (project != project.getRootProject()) { - // Also ensure it's applied to the root project. - project.getRootProject().getPlugins().apply(IdeaExtPlugin.class); - } - - final IdeaModel ideaModel = project.getRootProject().getExtensions().findByType(IdeaModel.class); - - if (ideaModel == null) { - return; - } - - final IdeaProject ideaProject = ideaModel.getProject(); - - if (ideaProject == null) { - return; - } - - final ProjectSettings settings = getExtension(ideaProject, ProjectSettings.class); - final ActionDelegationConfig delegateActions = getExtension(settings, ActionDelegationConfig.class); - final TaskTriggersConfig taskTriggers = getExtension(settings, TaskTriggersConfig.class); - final NamedDomainObjectContainer runConfigurations = (NamedDomainObjectContainer) ((ExtensionAware) settings).getExtensions().getByName("runConfigurations"); - - // Run the sync task on import - taskTriggers.afterSync(ideaSyncTask); - }); - } - - private static T getExtension(Object extensionAware, Class type) { - return Objects.requireNonNull(((ExtensionAware) extensionAware).getExtensions().getByType(type)); + // Run the idea sync task, is this exposed via the api? + final TaskExecutionGraphInternal taskGraph = (TaskExecutionGraphInternal) project.getGradle().getTaskGraph(); + taskGraph.whenReady(taskExecutionGraph -> taskGraph.addEntryTasks(List.of(ideaSyncTask.get()))); } }