-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
236 lines (206 loc) · 7.27 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
// Default tasks
defaultTasks 'licenseFormat', 'build', 'shadowJar'
// Apply plugins
apply from: 'magma.gradle'
apply plugin: 'cobertura'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'coveralls'
apply plugin: 'license'
apply plugin: 'maven'
apply plugin: 'signing'
// Basic project information
group = 'org.obsidianbox'
archivesBaseName = 'obsidian'
version = '1.0.0-SNAPSHOT'
// Extended project information
ext.projectName = 'Obsidian'
ext.inceptionYear = '2013'
ext.currentYear = '2014'
ext.packaging = 'jar'
ext.url = 'http://obsidianbox.org'
ext.description = 'Obsidian is a framework that extends Forge to deliver server-side content on demand.'
ext.organization = 'ObsidianBox'
// Define variables
ext.buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0'
ext.ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown'
ext.commit = project.hasProperty("commit") ? commit : 'unknown'
// Gradle repositories and dependencies
buildscript {
repositories {
mavenCentral()
maven {
name = 'sonatype-nexus-public'
url = 'https://oss.sonatype.org/content/repositories/public/'
}
jcenter()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.9.0'
classpath 'net.saliman:gradle-cobertura-plugin:2.2.4' // Coveralls plugin dependency
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:0.5.0'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.0.2'
}
}
// Project repositories
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'sonatype-nexus-public'
url = 'https://oss.sonatype.org/content/repositories/public/'
}
}
// Project dependencies
dependencies {
compile 'junit:junit:4.11'
compile 'org.spout:caustic-lwjgl:1.0.0-SNAPSHOT'
testCompile 'junit:junit:4.11'
}
// Include dependencies in the final JAR
shadowJar {
classifier = ''
destinationDir = file("build/distributions")
dependencies {
include(dependency('com.flowpowered:flow-math:0.1.0-SNAPSHOT'))
include(dependency('org.obsidianbox:magma:1.0.0-SNAPSHOT'))
include(dependency('org.spout:caustic-api:1.0.0-SNAPSHOT'))
include(dependency('org.spout:caustic-lwjgl:1.0.0-SNAPSHOT'))
}
exclude 'shaders/'
}
// Obfuscate based on the shaded jars content
reobf { reobf(file('build/distributions/' + archivesBaseName + '-' + version + '.jar')) {spec -> spec.classpath = configurations.compile } }
reobf.dependsOn shadowJar
// Filter, process, and include resources
processResources {
inputs.property "version", version
inputs.property "mcversion", project.minecraft.version
// Include in final JAR
from(rootProject.rootDir) {
include 'LICENSE.txt'
}
// Replace variables
from('src/main/resources/mcmod.info') {
expand 'modid': projectName,
'name': projectName,
'description': project.ext.description,
'version': version,
'buildNumber': buildNumber,
'mcversion': minecraft.version.split("-")[0],
'url': url,
'authorList': organization
}
}
// License header formatting
import nl.javadude.gradle.plugins.license.License
tasks.withType(License).each { licenseTask ->
licenseTask.exclude 'assets/**'
licenseTask.exclude '**/*.info'
}
license {
ext.name = project.name
ext.organization = organization
ext.url = url
ext.year = inceptionYear + '-' + currentYear
header rootProject.file('HEADER.txt')
ignoreFailures true
strictCheck true
}
// Source compiler configuration
configure([compileJava, compileTestJava]) {
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Xlint:-path'
options.deprecation = true
}
// JAR manifest configuration
jar.manifest.mainAttributes(
"Built-By": System.properties['user.name'],
"Created-By": System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")",
"Implementation-Title": name,
"Implementation-Version": version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit,
"Implementation-Vendor": url)
// Coveralls report configuration
cobertura.coverageFormats = [ 'html', 'xml' ] // Coveralls requires xml format
// Artifact deployment
uploadArchives {
repositories.mavenDeployer {
// Javadoc JAR generation
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
// Source JAR generation
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.java.srcDirs
}
// Set all artifacts
artifacts {
archives jar, javadocJar, sourcesJar
}
// Tasks and variables based on if release or snapshot
if (version.endsWith('-SNAPSHOT')) {
// Set variable to snapshots repository URL
ext.sonatypeUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
} else {
// Set variable to releases repository URL
ext.sonatypeUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
// Deployment signing
signing {
// Check if uploadArchives task is used
required { isReleaseVersion && gradle.taskGraph.hasTask("uploadArchives") }
// Sign JAR artifacts
sign configurations.archives
// Sign Maven POM
beforeDeployment {
org.gradle.api.artifacts.maven.MavenDeployment deployment -> signing.signPom(deployment)
}
}
}
// Set login credentials for repository
repository(url: sonatypeUrl) {
authentication(userName: System.getenv("sonatypeUsername"), password: System.getenv("sonatypePassword"))
}
// Maven POM generation
pom.project {
name projectName
artifactId archivesBaseName
packaging packaging
inceptionYear inceptionYear
url url
description project.ext.description
scm {
connection 'scm:git:git://github.com/ObsidianBox/Obsidian.git'
developerConnection 'scm:git:ssh://[email protected]:ObsidianBox/Obsidian.git'
url 'https://github.com/ObsidianBox/Obsidian'
}
licenses {
license {
name 'The MIT License'
url 'http://www.tldrlegal.com/license/mit-license'
distribution 'repo'
}
}
developers {
developer {
id 'Zidane'
name 'Chris Sanders'
email '[email protected]'
}
developer {
id 'Grinch'
name 'Steven Downer'
email '[email protected]'
}
}
organization {
name organization
url url
}
issueManagement {
system 'github'
url 'https://github.com/ObsidianBox/Obsidian/issues'
}
}
}
}