-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
199 lines (172 loc) · 5.88 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
// Default tasks
defaultTasks 'licenseFormat', 'build', 'install'
// Apply plugins
apply from: 'magma.gradle'
apply plugin: 'cobertura'
apply plugin: 'coveralls'
apply plugin: 'license'
apply plugin: 'maven'
apply plugin: 'signing'
// Basic project information
group = 'org.obsidianbox'
archivesBaseName = 'magma'
version = '1.0.0-SNAPSHOT'
// Extended project information
ext.projectName = 'Magma'
ext.inceptionYear = '2013'
ext.currentYear = '2014'
ext.packaging = 'jar'
ext.url = 'http://obsidianbox.org'
ext.description = 'Magma is an API that extends Minecraft Forge to easier deliver content through addons.'
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'
// Exclude reobfuscation task
gradle.startParameter.excludedTaskNames += "reobf"
// Gradle repositories and dependencies
buildscript {
repositories {
mavenCentral()
maven {
name = 'sonatype-nexus-public'
url = 'https://oss.sonatype.org/content/repositories/public/'
}
}
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'
}
}
// 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'
}
// Filter, process, and include resources
processResources {
// Include in final JAR
from(rootProject.rootDir) {
include 'LICENSE.txt'
}
}
// License header formatting
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/Magma.git'
developerConnection 'scm:git:ssh://[email protected]:ObsidianBox/Magma.git'
url 'https://github.com/ObsidianBox/Magma'
}
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/Magma/issues'
}
}
}
}