diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java index e4373a2..a12a4fb 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/VanillaGradle.java @@ -125,6 +125,7 @@ private void applyToProject(final Project project) { this.configureIDEIntegrations( project, + minecraft.needsPrepareWorkspace(), p.getTasks().named(Constants.Tasks.PREPARE_WORKSPACE) ); }); @@ -158,6 +159,7 @@ private void createDisplayMinecraftVersions(final Provider shouldRunPrepare, final TaskProvider prepareWorkspaceTask ) { project.getPlugins().apply(IdeaExtPlugin.class); @@ -171,12 +173,16 @@ public void idea(final Project project, final IdeaModel idea, final ProjectSetti final TaskTriggersConfig taskTriggers = ((ExtensionAware) ideaExtension).getExtensions().getByType(TaskTriggersConfig.class); // Automatically prepare a workspace after importing - taskTriggers.afterSync(prepareWorkspaceTask); + if (shouldRunPrepare.get()) { + taskTriggers.afterSync(prepareWorkspaceTask); + } } @Override public void eclipse(final Project project, final EclipseModel eclipse) { - eclipse.synchronizationTasks(prepareWorkspaceTask); + if (shouldRunPrepare.get()) { + eclipse.synchronizationTasks(prepareWorkspaceTask); + } } }); } diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/MinecraftExtensionImpl.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/MinecraftExtensionImpl.java index 9525133..ea553fe 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/MinecraftExtensionImpl.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/MinecraftExtensionImpl.java @@ -35,6 +35,7 @@ import org.gradle.api.model.ObjectFactory; import org.gradle.api.provider.Property; import org.gradle.api.provider.Provider; +import org.gradle.api.provider.ProviderFactory; import org.gradle.util.ConfigureUtil; import org.spongepowered.gradle.vanilla.MinecraftExtension; import org.spongepowered.gradle.vanilla.internal.model.VersionClassifier; @@ -44,6 +45,7 @@ import org.spongepowered.gradle.vanilla.internal.repository.modifier.AccessWidenerModifier; import org.spongepowered.gradle.vanilla.internal.repository.modifier.ArtifactModifier; import org.spongepowered.gradle.vanilla.repository.MinecraftPlatform; +import org.spongepowered.gradle.vanilla.repository.MinecraftSide; import org.spongepowered.gradle.vanilla.runs.RunConfiguration; import org.spongepowered.gradle.vanilla.runs.RunConfigurationContainer; @@ -79,8 +81,10 @@ public class MinecraftExtensionImpl implements MinecraftExtension { private final RunConfigurationContainer runConfigurations; private volatile Set lazyModifiers; + private final Provider needsPrepareWorkspace; + @Inject - public MinecraftExtensionImpl(final Gradle gradle, final ObjectFactory factory, final Project project, final Provider providerService) { + public MinecraftExtensionImpl(final Gradle gradle, final ObjectFactory factory, final ProviderFactory providers, final Project project, final Provider providerService) { this.project = project; this.providerService = providerService; this.version = factory.property(String.class); @@ -129,6 +133,7 @@ public MinecraftExtensionImpl(final Gradle gradle, final ObjectFactory factory, this.targetVersion.finalizeValueOnRead(); this.runConfigurations = factory.newInstance(RunConfigurationContainer.class, factory.domainObjectContainer(RunConfiguration.class), this); + this.needsPrepareWorkspace = providers.provider(() -> !this.runConfigurations.isEmpty() && this.platform.get().includes(MinecraftSide.CLIENT)); } @Override @@ -270,4 +275,8 @@ public Provider targetVersion() { return this.targetVersion; } + public Provider needsPrepareWorkspace() { + return this.needsPrepareWorkspace; + } + } diff --git a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/ProvideMinecraftPlugin.java b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/ProvideMinecraftPlugin.java index b98678e..94f2c9e 100644 --- a/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/ProvideMinecraftPlugin.java +++ b/subprojects/gradle-plugin/src/main/java/org/spongepowered/gradle/vanilla/internal/ProvideMinecraftPlugin.java @@ -151,7 +151,7 @@ public void apply(final Project target) { this.configureRepositories(minecraft, p.getRepositories()); prepareWorkspace.configure(task -> { - if (minecraft.platform().get().includes(MinecraftSide.CLIENT)) { + if (minecraft.needsPrepareWorkspace().get()) { task.dependsOn(assets); } });