-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
253 lines (219 loc) · 8.29 KB
/
Copy pathbuild.gradle
File metadata and controls
253 lines (219 loc) · 8.29 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
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
/*
* 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: 'java'
apply plugin: 'project-report'
apply plugin: 'idea'
apply plugin: 'eclipse'
apply plugin: 'java-library-distribution'
apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'findbugs'
apply plugin: 'maven'
apply plugin: 'artifactory-publish'
apply plugin: 'maven-publish'
// 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')
}
}
// 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"
}
}
// Primary dependencies definition
dependencies {
compile group: 'org.terasology', name: 'gestalt-module', version: '2.2.4-SNAPSHOT'
compile group: 'com.googlecode.gentyref', name: 'gentyref', version: '1.2.0'
// These dependencies are only needed for running tests
testCompile group: 'junit', name: 'junit', version: '4.11'
testCompile group: 'ch.qos.logback', name: 'logback-classic', version: '1.1.2'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.5'
testCompile group: 'org.jboss.shrinkwrap', name: 'shrinkwrap-impl-base', version: '1.2.2'
testCompile group: 'org.jboss.shrinkwrap', name: 'shrinkwrap-impl-nio2', version: '1.2.2'
}
// Set the expected module Java level (can use a higher Java to run, but should not use features from a higher Java)
sourceCompatibility = 1.7
targetCompatibility = 1.7
// Library and distribution config
group = 'org.terasology'
description = 'Provides support for assets - binary resources that can be loaded from modules or procedurally generated at runtime.'
distributions {
main {
baseName = 'gestalt-assets-core'
}
}
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
configProperties.samedir = checkstyle.configFile.parentFile
}
pmd {
ignoreFailures = true
ruleSetFiles = files("config/pmd/pmd.xml")
}
findbugs {
toolVersion = '2.0.3'
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
}
// Setup IntelliJ-IDEA
idea {
project {
jdkName = '1.7'
languageLevel = 'JDK_1_7'
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')
downloadSources = true
}
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:gestalt-module 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-module 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 2014 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>
'''))
}
}
// 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"])
}
}
}