forked from BenjaminAmos/TeraNUI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
159 lines (137 loc) · 5.8 KB
/
build.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
/*
* This is a Gradle build file:
* - Gradle Homepage: http://gradle.org/
* - Gradle Documentation: http://gradle.org/documentation
* - View tasks for this project: $ gradlew tasks
*/
// gradle wrapper version
wrapper {
gradleVersion '2.11'
}
allprojects {
apply plugin: 'idea'
group = 'org.terasology'
// Declare remote repositories we're interested in - library files will be fetched from here
repositories {
// Main Maven repo
mavenCentral()
// MovingBlocks Artifactory instance for libs not readily available elsewhere plus our own libs
maven {
url "http://artifactory.terasology.org/artifactory/virtual-repo-live"
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
// Primary dependencies definition
dependencies {
compile group: 'org.terasology', name: 'gestalt-asset-core', version: '5.0.1'
}
// Set the expected module Java level (can use a higher Java to run, but should not use features from a higher Java)
sourceCompatibility = 1.8
targetCompatibility = 1.8
// TODO: add CI-specific settings on first release
checkstyle {
ignoreFailures = true
configFile = new File(rootDir, 'config/checkstyle/checkstyle.xml')
configProperties.samedir = checkstyle.configFile.parentFile
}
pmd {
ignoreFailures = true
ruleSetFiles = files("$rootDir/config/pmd/pmd.xml")
}
}
// Setup IntelliJ-IDEA
idea {
project {
jdkName = '1.8'
languageLevel = 'JDK_1_8'
ipr {
withXml { xmlProvider ->
def iprNode = xmlProvider.asNode()
ideaActivateGit(iprNode)
ideaActivateCheckstyle(iprNode)
ideaActivateCopyright(iprNode)
}
}
}
module {
// Exclude Gradle dir
excludeDirs += file('gradle')
// Exclude Eclipse dirs
excludeDirs += file('bin')
excludeDirs += file('.settings')
}
workspace {
iws {
withXml { xmlProvider ->
def iwsNode = xmlProvider.asNode()
ideaMakeAutomatically(iwsNode)
}
}
}
}
ext {
// Activate 'git' as VCS
ideaActivateGit = { Node iprNode ->
def vcsMappings = iprNode.component.find { it.'@name' == 'VcsDirectoryMappings' }
vcsMappings.mapping.@vcs = 'Git'
}
// Activate and config 'Checkstyle' plugin
ideaActivateCheckstyle = { Node iprNode ->
def checkstyle = iprNode.component.find { it.'@name' == 'CheckStyle-IDEA' }
if (checkstyle == null) {
// Create new CheckStyle component
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/checkstyle/checkstyle.xml:TeraNUI 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/checkstyle/checkstyle.xml:TeraNUI CheckStyle')
entry(key: 'property-1.samedir', value: 'config/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 ->
def copyrightManager = iprNode.component.find { it.'@name' == 'CopyrightManager' }
copyrightManager.'@default' = "nui-core"
def copyright = copyrightManager.copyright.find {
it.option.find { it.'@name' == "myName" }?.'@value' == "TeraNUI"
}
if (copyright == null) {
copyrightManager.append(new XmlParser().parseText('''
<copyright>
<option name="notice" value="Copyright 2016 MovingBlocks Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License." />
<option name="keyword" value="Copyright" />
<option name="allowReplaceKeyword" value="" />
<option name="myName" value="TeraNUI" />
<option name="myLocal" value="true" />
</copyright>
'''))
}
}
// Enable "make project automatically"
ideaMakeAutomatically = { Node iwsNode ->
def compilerWsConf = iwsNode.find { it.'@name' == 'CompilerWorkspaceConfiguration' }
if (compilerWsConf == null) {
compilerWsConf = iwsNode.appendNode('component', [name: 'CompilerWorkspaceConfiguration'])
compilerWsConf.appendNode("option", [name: "MAKE_PROJECT_ON_SAVE", value: "true"])
}
}
}