-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrunmanager.gradle
70 lines (64 loc) · 2.76 KB
/
runmanager.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
buildscript {
repositories {
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url "https://${mirror_maven_url}" }
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:${forge_gradle_version}"
}
}
// Make sure don't let FG use the -Xmx3G parameter to cause 32-bit Java errors.
// https://github.com/MinecraftForge/ForgeGradle/blob/FG_2.3/src/main/java/net/minecraftforge/gradle/tasks/fernflower/ApplyFernFlowerTask.java#L92
if (System.getProperty("os.arch") == "x86") {
project.setProperty "forkDecompile", "true"
}
sourceSets {
main {
output.resourcesDir = file('build/combined')
java.outputDir = file('build/combined')
}
}
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
tasks.genIntellijRuns.doFirst {
def workspaceFile = file(".idea/workspace.xml")
workspaceFile.parentFile.mkdirs()
if (!workspaceFile.exists()) {
workspaceFile.write("""\
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RunManager">
</component>
</project>
""".stripIndent())
} else {
def workspace = new XmlParser().parse(workspaceFile)
def runManager = workspace.component.findAll({ it.@name == "RunManager" })
if (runManager.size() == 0) {
// When IDEA first imported the project, the RunManager node didn't exist.
workspace.appendNode("component", ["name": "RunManager"])
} else {
// The genIntellijRuns task doesn't delete old run configurations, this is bad.
runManager.each {
it.configuration.findAll({ it.@name == "Minecraft Client" || it.@name == "Minecraft Server" }).each { configuration ->
it.remove(configuration)
}
}
}
new XmlNodePrinter(new PrintWriter(new FileWriter(workspaceFile))).print(workspace)
}
}
tasks.genIntellijRuns.doLast {
def workspaceFile = file(".idea/workspace.xml")
def workspace = new XmlParser().parse(workspaceFile)
workspace.component.findAll({ it.@name == "RunManager" }).each {
it.configuration.findAll({ it.@name == "Minecraft Client" || it.@name == "Minecraft Server" }).each {
// The module name specified in the run configuration generated by the genIntellijRuns task is wrong.
// It uses underscores instead of dots.
// https://github.com/MinecraftForge/ForgeGradle/blob/FG_2.3/src/main/java/net/minecraftforge/gradle/user/UserBasePlugin.java#L1325
it.module.@name = project.idea.module.name + '.' + project.minecraft.runSourceSet.name
}
}
new XmlNodePrinter(new PrintWriter(new FileWriter(workspaceFile))).print(workspace)
}