-
Notifications
You must be signed in to change notification settings - Fork 126
Expand file tree
/
Copy pathide.gradle
More file actions
142 lines (127 loc) · 8.12 KB
/
ide.gradle
File metadata and controls
142 lines (127 loc) · 8.12 KB
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
// Stuff specific to IDEA IntelliJ setup - meant to be included by more central Gradle files
ext {
// Activate Checkstyle config
ideaActivateCheckstyle = { Node iprNode ->
// Even if the component already exists this'll just overwrite it - shouldn't duplicate
def checkstyle = iprNode.appendNode('component', [name: 'CheckStyle-IDEA'])
// use NodeBuilder to create the config block in the xml structure
def builder = new NodeBuilder()
def option = builder.option(name: 'configuration') {
map {
entry(key: 'active-configuration',
value: 'PROJECT_RELATIVE:$PROJECT_DIR$/config/metrics/checkstyle/checkstyle.xml:Terasology CheckStyle')
entry(key: 'check-nonjava-files', value: false)
entry(key: 'check-test-classes', value: true)
entry(key: 'location-0',
value: 'CLASSPATH:/sun_checks.xml:The default CheckStyle rules')
entry(key: 'location-1',
value: 'PROJECT_RELATIVE:$PROJECT_DIR$/config/metrics/checkstyle/checkstyle.xml:Terasology CheckStyle')
entry(key: 'property-1.samedir', value: 'config/metrics/checkstyle')
entry(key: 'suppress-errors', value: false)
entry(key: 'thirdparty-classpath', value: '')
}
}
// Add result from NodeBuilder
checkstyle.append option
}
// Activate copyright conventions
ideaActivateCopyright = { Node iprNode ->
// Setup copyright statement injection
def copyrightManager = iprNode.find { it.@name == 'CopyrightManager' }
copyrightManager.@default = "TerasologyEngine"
def copyright = copyrightManager.appendNode("copyright")
copyright.appendNode("option", [name: "notice", value: 'Copyright 2020 The Terasology Foundation\n\nLicensed under the Apache License, Version 2.0 (the "License");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an "AS IS" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.'])
copyright.appendNode("option", [name: "keyword", value: "Copyright"])
copyright.appendNode("option", [name: "allowReplaceKeyword", value: ""])
copyright.appendNode("option", [name: "myName", value: "TerasologyEngine"])
copyright.appendNode("option", [name: "myLocal", value: "true"])
def langOptions = copyrightManager.appendNode("LanguageOptions", [name: "__TEMPLATE__"])
langOptions.appendNode("option", [name: "addBlankAfter", value: "false"])
}
// Activate special cases for annotations
ideaActivateAnnotations = { Node iprNode ->
// Setup knowledge of certain annotations being entry points (so don't mark annotated items as unused)
def entryPointsManager = iprNode.appendNode('component', [name: "EntryPointsManager"])
def entryPoints = entryPointsManager.appendNode('entry_points', [version: '2.0'])
def entryPointsList = entryPointsManager.appendNode('list', [size: '3'])
entryPointsList.appendNode('item', [index: '0', class: 'java.lang.String', itemvalue: 'org.terasology.entitySystem.event.ReceiveEvent'])
entryPointsList.appendNode('item', [index: '1', class: 'java.lang.String', itemvalue: 'org.terasology.registry.In'])
entryPointsList.appendNode('item', [index: '2', class: 'java.lang.String', itemvalue: 'org.terasology.entitySystem.systems.RegisterSystem'])
entryPointsList.appendNode('item', [index: '3', class: 'java.lang.String', itemvalue: 'org.terasology.logic.console.Command'])
}
// Activate Git for the root + appropriate sub projects (may add more later)
ideaActivateGit = { Node iprNode ->
// Set root project to use Git
def vcsMappings = iprNode.component.find { it.@name == 'VcsDirectoryMappings' }
vcsMappings.mapping.@vcs = 'Git'
}
// Activate 'Gradle' plugin - TODO: Doesn't actually work with the Gradle wrapper in a non-default location :-(
ideaActivateGradle = { Node iprNode ->
def gradleSettings = iprNode.component.find { it.@name == 'GradleSettings' }
if (gradleSettings == null) {
gradleSettings = iprNode.appendNode('component', [name: 'GradleSettings'])
gradleSettings.appendNode('option', [name: 'linkedProjectPath', value: '$PROJECT_DIR$/build.gradle'])
}
}
// Enable "make project automatically"
ideaMakeAutomatically = { Node iwsNode ->
def compilerWsConf = iwsNode.find { it.@name == 'CompilerWorkspaceConfiguration' }
// Slowly realizing the XML stuff is smart enough to not insert dupes even without an if, but .. scary!
if (compilerWsConf == null) {
compilerWsConf = iwsNode.appendNode('component', [name: 'CompilerWorkspaceConfiguration'])
compilerWsConf.appendNode("option", [name: "MAKE_PROJECT_ON_SAVE", value: "true"])
}
}
// Generate a run configuration for the primary PC facade way of running the game
ideaRunConfig = { Node iwsNode ->
// Add our run configs - this one launches with homedir set to local and the Crash Reporter off
def runManager = iwsNode.find { it.@name == 'RunManager' }
// TODO: Probably should make these run config blocks generic already ...
// TODO: Undo the -noSplash tag and -XstartOnFirstThread when the splash screen works on Macs again. See https://github.com/MovingBlocks/DestinationSol/issues/414
def startOnFirstThread = ""
def noSplash = ""
if (System.properties["os.name"].toLowerCase().contains("mac")) {
startOnFirstThread = "-XstartOnFirstThread"
noSplash = "-noSplash"
}
runManager.append(new XmlParser().parseText(String.format('''
<configuration default="false" name="DestSol" type="Application" factoryName="Application">
<extension name="coverage" enabled="false" merge="false" runner="idea">
<pattern>
<option name="PATTERN" value="org.destinationsol.desktop.*"/>
<option name="ENABLED" value="true"/>
</pattern>
</extension>
<option name="MAIN_CLASS_NAME" value="org.destinationsol.desktop.SolDesktop"/>
<option name="VM_PARAMETERS" value="-splash:engine/src/main/resources/assets/textures/mainMenu/mainMenuLogo.png %s -Xms256m -Xmx1024m/>
<option name="PROGRAM_PARAMETERS" value="-noCrashReport %s"/>
<option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false"/>
<option name="ALTERNATIVE_JRE_PATH" value=""/>
<option name="ENABLE_SWING_INSPECTOR" value="false"/>
<option name="ENV_VARIABLES"/>
<option name="PASS_PARENT_ENVS" value="true"/>
<module name="desktop"/>
<envs/>
<RunnerSettings RunnerId="Debug">
<option name="DEBUG_PORT" value=""/>
<option name="TRANSPORT" value="0"/>
<option name="LOCAL" value="true"/>
</RunnerSettings>
<RunnerSettings RunnerId="Run"/>
<ConfigurationWrapper RunnerId="Debug"/>
<ConfigurationWrapper RunnerId="Run"/>
<method/>
</configuration>
''', startOnFirstThread, noSplash)))
// This part puts the added run config into the actual "Run" drop-down
runManager.append(new XmlParser().parseText('''
<list size="1">
<item index="0" class="java.lang.String" itemvalue="Application.DestSol"/>
</list>
'''))
// Makes the added run config the selected item
def runManagerTag = iwsNode.component.find { it.@name == 'RunManager' }
runManagerTag.@selected = 'Application.DestSol'
}
}