Remove idea-ext plugin, replace with 1 internal gradle api. Vastly improves import performance.
This commit is contained in:
parent
ab21e0e550
commit
e4244dc895
2 changed files with 5 additions and 47 deletions
|
@ -37,9 +37,6 @@ repositories {
|
||||||
url = 'https://maven.fabricmc.net/'
|
url = 'https://maven.fabricmc.net/'
|
||||||
}
|
}
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven {
|
|
||||||
url = 'https://plugins.gradle.org/m2/'
|
|
||||||
}
|
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +92,6 @@ dependencies {
|
||||||
// source code remapping
|
// source code remapping
|
||||||
implementation ('net.fabricmc:mercury:0.2.4')
|
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
|
// Kapt integration
|
||||||
compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0')
|
compileOnly('org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0')
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,11 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.configuration.ide.idea;
|
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.Project;
|
||||||
import org.gradle.api.plugins.ExtensionAware;
|
|
||||||
import org.gradle.api.tasks.TaskProvider;
|
import org.gradle.api.tasks.TaskProvider;
|
||||||
import org.gradle.plugins.ide.idea.model.IdeaModel;
|
import org.gradle.execution.taskgraph.TaskExecutionGraphInternal;
|
||||||
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;
|
|
||||||
|
|
||||||
public class IdeaConfiguration {
|
public class IdeaConfiguration {
|
||||||
public static void setup(Project project) {
|
public static void setup(Project project) {
|
||||||
|
@ -48,36 +40,8 @@ public class IdeaConfiguration {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
project.getPlugins().apply(IdeaExtPlugin.class);
|
// Run the idea sync task, is this exposed via the api?
|
||||||
project.getPlugins().withType(IdeaExtPlugin.class, ideaExtPlugin -> {
|
final TaskExecutionGraphInternal taskGraph = (TaskExecutionGraphInternal) project.getGradle().getTaskGraph();
|
||||||
if (project != project.getRootProject()) {
|
taskGraph.whenReady(taskExecutionGraph -> taskGraph.addEntryTasks(List.of(ideaSyncTask.get())));
|
||||||
// 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<RunConfiguration> runConfigurations = (NamedDomainObjectContainer<RunConfiguration>) ((ExtensionAware) settings).getExtensions().getByName("runConfigurations");
|
|
||||||
|
|
||||||
// Run the sync task on import
|
|
||||||
taskTriggers.afterSync(ideaSyncTask);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <T> T getExtension(Object extensionAware, Class<T> type) {
|
|
||||||
return Objects.requireNonNull(((ExtensionAware) extensionAware).getExtensions().getByType(type));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue