-
Notifications
You must be signed in to change notification settings - Fork 2
/
buildscript.gradle
166 lines (153 loc) · 7.13 KB
/
buildscript.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'eclipse'
JavaLanguageVersion.of(17)
ext {
replace = this.&replace
}
Hashtable<String, ?> getTokens() {
if(!project.ext.has("tokens"))
project.ext.set("tokens", new Hashtable<String, ?>())
return project.ext["tokens"]
}
void replace(String token, String replacement) {
getTokens().put(token, replacement)
}
repositories {
mavenCentral()
maven {
url 'https://maven.ellpeck.de'
}
maven {
url "https://clojars.org/repo/"
}
}
task processSources(type: Copy) {
from sourceSets.main.allSource
into 'build/processedSrc'
filter(ReplaceTokens, tokens: getTokens())
}
compileJava {
new File("$projectDir", "build"+File.separator+"classes").deleteDir()
dependsOn(processSources)
source = processSources.destinationDir
}
def mainClassName = "de.ellpeck.rockbottom.Main"
task runServer(type: JavaExec) {
args = ["--unpackedModsDir", "./build/classes/java/main", "--server", "--gameDir", "./RockBottom"]
if ( project.hasProperty("additionalArgs") ) {
args += Eval.me(additionalArgs)
}
main = mainClassName
}
task runClient(type: JavaExec) {
args = ["--unpackedModsDir", "./build/classes/java/main", "--gameDir", "./RockBottom"]
if ( project.hasProperty("additionalArgs") ) {
args += Eval.me(additionalArgs)
}
main = mainClassName
}
task run {
dependsOn(runClient)
}
task createIntelliJRuns {
group = 'ide'
description = 'Creates the project run configuration for IntelliJ IDEA'
def file = new File("$projectDir", ".idea" + File.separator + "runConfigurations" + File.separator + "Launch RB.xml")
if (!file.exists()) {
file.getParentFile().mkdirs()
file.createNewFile()
}
file.setText("<component name=\"ProjectRunConfigurationManager\">\n" +
" <configuration default=\"false\" name=\"Launch RB\" type=\"GradleRunConfiguration\" factoryName=\"Gradle\">\n" +
" <ExternalSystemSettings>\n" +
" <option name=\"executionName\" />\n" +
" <option name=\"externalProjectPath\" value=\"\$PROJECT_DIR\$\" />\n" +
" <option name=\"externalSystemIdString\" value=\"GRADLE\" />\n" +
" <option name=\"scriptParameters\" />\n" +
" <option name=\"taskDescriptions\">\n" +
" <list />\n" +
" </option\n>" +
" <option name=\"taskNames\">\n" +
" <list>\n" +
" <option value=\"runClient\" />" +
" </list>\n" +
" </option>\n" +
" <option name=\"vmOptions\" />\n" +
" </ExternalSystemSettings>\n" +
" <method />\n" +
" </configuration>\n" +
"</component>", "UTF-8")
file = new File("$projectDir", ".idea" + File.separator + "runConfigurations" + File.separator + "Launch RB Server.xml")
if (!file.exists()) {
file.getParentFile().mkdirs()
file.createNewFile()
}
file.setText("<component name=\"ProjectRunConfigurationManager\">\n" +
" <configuration default=\"false\" name=\"Launch RB Server\" type=\"GradleRunConfiguration\" factoryName=\"Gradle\">\n" +
" <ExternalSystemSettings>\n" +
" <option name=\"executionName\" />\n" +
" <option name=\"externalProjectPath\" value=\"\$PROJECT_DIR\$\" />\n" +
" <option name=\"externalSystemIdString\" value=\"GRADLE\" />\n" +
" <option name=\"scriptParameters\" />\n" +
" <option name=\"taskDescriptions\">\n" +
" <list />\n" +
" </option\n>" +
" <option name=\"taskNames\">\n" +
" <list>\n" +
" <option value=\"runServer\" />" +
" </list>\n" +
" </option>\n" +
" <option name=\"vmOptions\" />\n" +
" </ExternalSystemSettings>\n" +
" <method />\n" +
" </configuration>\n" +
"</component>", "UTF-8")
}
task createEclipseRuns {
group = 'ide'
description = 'Creates the project run configuration for Eclipse'
def file = new File("$projectDir", "Launch RB.launch")
if (!file.exists()) {
file.getParentFile().mkdirs()
file.createNewFile()
}
file.setText("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
"<launchConfiguration type=\"org.eclipse.jdt.launching.localJavaApplication\">\n" +
"<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_PATHS\">\n" +
"<listEntry value=\"/Launch RB\"/>\n" +
"</listAttribute>\n" +
"<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_TYPES\">\n" +
"<listEntry value=\"4\"/>\n" +
"</listAttribute>\n" +
"<listAttribute key=\"org.eclipse.debug.ui.favoriteGroups\">\n" +
"<listEntry value=\"org.eclipse.debug.ui.launchGroup.debug\"/>\n" +
"<listEntry value=\"org.eclipse.debug.ui.launchGroup.run\"/>\n" +
"</listAttribute>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.MAIN_TYPE\" value=\"de.ellpeck.rockbottom.Main\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.PROGRAM_ARGUMENTS\" value=\"--unpackedModsDir ./build/classes/java/main\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"$project.name\"/>\n" +
"</launchConfiguration>", "UTF-8")
file = new File("$projectDir", "Launch RB Server.launch")
if (!file.exists()) {
file.getParentFile().mkdirs()
file.createNewFile()
}
file.setText("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
"<launchConfiguration type=\"org.eclipse.jdt.launching.localJavaApplication\">\n" +
"<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_PATHS\">\n" +
"<listEntry value=\"/Launch RB\"/>\n" +
"</listAttribute>\n" +
"<listAttribute key=\"org.eclipse.debug.core.MAPPED_RESOURCE_TYPES\">\n" +
"<listEntry value=\"4\"/>\n" +
"</listAttribute>\n" +
"<listAttribute key=\"org.eclipse.debug.ui.favoriteGroups\">\n" +
"<listEntry value=\"org.eclipse.debug.ui.launchGroup.debug\"/>\n" +
"<listEntry value=\"org.eclipse.debug.ui.launchGroup.run\"/>\n" +
"</listAttribute>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.MAIN_TYPE\" value=\"de.ellpeck.rockbottom.Main\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.PROGRAM_ARGUMENTS\" value=\"--unpackedModsDir ./build/classes/java/main --server\"/>\n" +
"<stringAttribute key=\"org.eclipse.jdt.launching.PROJECT_ATTR\" value=\"$project.name\"/>\n" +
"</launchConfiguration>", "UTF-8")
}