forked from SpongePowered/nbt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
213 lines (188 loc) · 6.17 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
// Default tasks
defaultTasks 'clean', 'licenseFormat', 'build', 'install'
// Apply plugins
apply plugin: 'java'
apply plugin: 'cobertura' // Coveralls dependency
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'license'
apply plugin: 'maven'
apply plugin: 'signing'
// Project information
ext.projectName = 'Flow NBT'
group = 'com.flowpowered'
archivesBaseName = 'flow-nbt'
version = '2.0.0'
ext.packaging = 'jar'
ext.inceptionYear = '2011'
ext.url = 'https://flowpowered.com/nbt'
ext.description = 'Named Binary Tag (NBT) library for Java based on Graham Edgecombe\'s JNBT library.'
// Organization information
ext.organization = 'Flow Powered'
ext.organizationUrl = 'https://flowpowered.com'
// Build properties
ext.buildNumber = project.hasProperty('buildNumber') ? buildNumber : '0'
ext.ciSystem = project.hasProperty('ciSystem') ? ciSystem : 'unknown'
ext.commit = project.hasProperty('commit') ? commit : 'unknown'
// Build plugin repositories and dependencies
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'sonatype-nexus'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
classpath 'net.saliman:gradle-cobertura-plugin:2.6.0' // Coveralls dependency
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.4.0'
}
}
// Project repositories
repositories {
mavenLocal()
mavenCentral()
maven {
name = 'sonatype-nexus'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
// Project dependencies
dependencies {
testCompile 'junit:junit:4.12'
}
// Filter, process, and include resources
processResources {
// Include in final JAR
from(rootProject.rootDir) {
include 'LICENSE.txt'
}
}
// License header formatting
license {
ext.project = projectName
ext.year = inceptionYear
ext.name = organization
ext.url = organizationUrl
header rootProject.file('HEADER.txt')
ignoreFailures true
strictCheck true
useDefaultMappings false
mapping { java = 'SLASHSTAR_STYLE' }
}
// Source compiler configuration
configure([compileJava, compileTestJava]) {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
options.encoding = 'UTF-8'
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'] + ')',
'Specification-Title': projectName,
'Specification-Version': version + '+' + ciSystem + '-b' + buildNumber + '.git-' + commit,
'Specification-Vendor': organization + ' - ' + organizationUrl)
// Javadoc doclint configuration
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
// 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/'
/*
// Artifact signing
signing {
// 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/flow/nbt.git'
developerConnection 'scm:git:ssh://[email protected]:flow/nbt.git'
url 'https://github.com/flow/nbt'
}
licenses {
license {
name 'MIT License'
url 'https://tldrlegal.com/l/mit'
distribution 'repo'
}
}
organization {
name organization
url organizationUrl
}
developers {
developer {
id 'DDoS'
name 'Aleksi Sapon'
email '[email protected]'
}
developer {
id 'kitskub'
name 'Jack Huey'
email '[email protected]'
}
developer {
id 'Wolf480pl'
name 'Wolf480pl'
email '[email protected]'
}
developer {
id 'lukespragg'
name 'Luke Spragg'
email '[email protected]'
}
}
}
}
}