Fix crash with Gradle 7.4+ during idea sync.
This commit is contained in:
parent
4fe19028cf
commit
287e6cefb9
3 changed files with 40 additions and 5 deletions
|
@ -24,11 +24,14 @@
|
||||||
|
|
||||||
package net.fabricmc.loom.configuration.ide.idea;
|
package net.fabricmc.loom.configuration.ide.idea;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gradle.StartParameter;
|
||||||
|
import org.gradle.TaskExecutionRequest;
|
||||||
import org.gradle.api.Project;
|
import org.gradle.api.Project;
|
||||||
import org.gradle.api.tasks.TaskProvider;
|
import org.gradle.api.tasks.TaskProvider;
|
||||||
import org.gradle.execution.taskgraph.TaskExecutionGraphInternal;
|
import org.gradle.internal.DefaultTaskExecutionRequest;
|
||||||
|
|
||||||
import net.fabricmc.loom.task.LoomTasks;
|
import net.fabricmc.loom.task.LoomTasks;
|
||||||
|
|
||||||
|
@ -42,8 +45,10 @@ public class IdeaConfiguration {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run the idea sync task, is this exposed via the api?
|
final StartParameter startParameter = project.getGradle().getStartParameter();
|
||||||
final TaskExecutionGraphInternal taskGraph = (TaskExecutionGraphInternal) project.getGradle().getTaskGraph();
|
final List<TaskExecutionRequest> taskRequests = new ArrayList<>(startParameter.getTaskRequests());
|
||||||
taskGraph.whenReady(taskExecutionGraph -> taskGraph.addEntryTasks(List.of(ideaSyncTask.get())));
|
|
||||||
|
taskRequests.add(new DefaultTaskExecutionRequest(List.of("ideaSyncTask")));
|
||||||
|
startParameter.setTaskRequests(taskRequests);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import org.gradle.util.GradleVersion
|
||||||
|
|
||||||
class LoomTestConstants {
|
class LoomTestConstants {
|
||||||
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
|
public final static String DEFAULT_GRADLE = GradleVersion.current().getVersion()
|
||||||
public final static String PRE_RELEASE_GRADLE = "7.5-20220124231322+0000"
|
public final static String PRE_RELEASE_GRADLE = "7.5-20220129032445+0000"
|
||||||
|
|
||||||
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
|
public final static String[] STANDARD_TEST_VERSIONS = [DEFAULT_GRADLE, PRE_RELEASE_GRADLE]
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,9 @@ package net.fabricmc.loom.test.integration
|
||||||
import net.fabricmc.loom.test.util.GradleProjectTestTrait
|
import net.fabricmc.loom.test.util.GradleProjectTestTrait
|
||||||
import spock.lang.Specification
|
import spock.lang.Specification
|
||||||
import spock.lang.Unroll
|
import spock.lang.Unroll
|
||||||
|
import spock.util.environment.RestoreSystemProperties
|
||||||
|
|
||||||
|
import static net.fabricmc.loom.test.LoomTestConstants.STANDARD_TEST_VERSIONS
|
||||||
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS
|
||||||
|
|
||||||
// This test runs a mod that exits on mod init
|
// This test runs a mod that exits on mod init
|
||||||
|
@ -52,4 +54,32 @@ class RunConfigTest extends Specification implements GradleProjectTestTrait {
|
||||||
'runTestmodServer' | _
|
'runTestmodServer' | _
|
||||||
'runAutoTestServer' | _
|
'runAutoTestServer' | _
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RestoreSystemProperties
|
||||||
|
@Unroll
|
||||||
|
def "idea auto configuration (gradle #version)"() {
|
||||||
|
setup:
|
||||||
|
System.setProperty("idea.sync.active", "true")
|
||||||
|
def gradle = gradleProject(project: "minimalBase", version: version)
|
||||||
|
|
||||||
|
new File(gradle.projectDir, ".idea").mkdirs()
|
||||||
|
|
||||||
|
gradle.buildGradle << '''
|
||||||
|
dependencies {
|
||||||
|
minecraft "com.mojang:minecraft:1.18.1"
|
||||||
|
mappings "net.fabricmc:yarn:1.18.1+build.18:v2"
|
||||||
|
modImplementation "net.fabricmc:fabric-loader:0.12.12"
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
|
when:
|
||||||
|
// Dont run with any tasks, the idea sync task should be invoked automatically due to the system prop
|
||||||
|
def result = gradle.run(tasks: [])
|
||||||
|
|
||||||
|
then:
|
||||||
|
result.task(":ideaSyncTask").outcome == SUCCESS
|
||||||
|
|
||||||
|
where:
|
||||||
|
version << STANDARD_TEST_VERSIONS
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue