forked from MovingBlocks/gestalt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
254 lines (218 loc) · 8.56 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
/*
* This is a Gradle build file:
* - Gradle Homepage: http://gradle.org/
* - Gradle Documentation: http://gradle.org/documentation
* - View tasks for this project: $ gradlew tasks
*/
apply plugin: 'project-report'
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()
maven {
url "http://artifactory.terasology.org/artifactory/repo"
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'eclipse'
}
configure(subprojects.findAll { !it.name.contains("testpack") && !it.name.startsWith("module") }) {
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: 'java-library-distribution'
apply plugin: 'artifactory-publish'
apply plugin: 'maven-publish'
// Primary dependencies definition
dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.21'
compile group: 'com.google.guava', name: 'guava', version: '19.0'
// These dependencies are only needed for running tests
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.7'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.10.19'
}
// 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
jar {
manifest {
attributes("Implementation-Title": project.name,
"Implementation-Version": version)
}
from(['LICENSE', 'NOTICE'])
}
task sourceJar(type: Jar) {
description = "Create a JAR with all sources"
from sourceSets.main.allSource
from sourceSets.test.allSource
classifier = 'sources'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
description = "Create a JAR with the JavaDoc for the java sources"
from javadoc.destinationDir
classifier = 'javadoc'
}
// A configuration for publishing artifacts
configurations {
published
}
// Define the artifacts we want to publish (the .pom will also be included since the Maven plugin is active)
artifacts {
published jar
published sourceJar
published javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact jar {
}
artifact sourceJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
}
}
}
artifactory {
publish {
defaults {
publications('mavenJava')
}
}
}
// Technically the plain "jar" both here and above is included automatically, but leaving it explicit for clarity
artifactoryPublish {
dependsOn jar, sourceJar, javadocJar
}
checkstyle {
ignoreFailures = true
configFile = new File(rootDir, "config/checkstyle/checkstyle.xml")
configProperties.samedir = new File(rootDir, "config/checkstyle")
toolVersion = "6.5"
}
pmd {
ignoreFailures = true
ruleSetFiles = files(new File(rootDir, "config/pmd/pmd.xml"))
}
findbugs {
toolVersion = '3.0.0'
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
excludeFilter = new File(rootDir, "config/findbugs/findbugs-exclude.xml")
}
}
// gradle wrapper version
wrapper {
gradleVersion '1.10'
}
ext {
// Read environment variables, including variables passed by jenkins continuous integration server
env = System.getenv()
}
// Dependencies needed for what our Gradle scripts themselves use. It cannot be included via an external Gradle file :-(
buildscript {
repositories {
mavenCentral()
maven {
url 'http://dl.bintray.com/jfrog/jfrog-jars'
}
}
dependencies {
// Artifactory plugin
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.3')
}
}
// Library and distribution config
description = 'A set of libraries providing core capabilities for games and game engines'
// 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()
def runManager = iwsNode.find { it.@name == 'RunManager' }
def junitDefault = runManager.find { it.@factoryName == 'JUnit' }
def workingDir = junitDefault.find { it.@name == 'WORKING_DIRECTORY' }
workingDir.@value = 'file://$MODULE_DIR$'
}
}
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:gestalt 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:gestalt 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' = "gestalt-module"
def copyright = copyrightManager.copyright.find { it.option.find { it.'@name' == "myName" }?.'@value' == "gestalt-module" }
if (copyright == null) {
copyrightManager.append(new XmlParser().parseText('''
<copyright>
<option name="notice" value="Copyright 2015 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="gestalt-module" />
<option name="myLocal" value="true" />
</copyright>
'''))
}
}
}