-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
221 lines (196 loc) · 6.68 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
// 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 Commons'
group = 'com.flowpowered'
archivesBaseName = 'flow-commons'
version = '1.0.1-SNAPSHOT'
ext.packaging = 'jar'
ext.inceptionYear = '2013'
ext.url = 'https://flowpowered.com/commons'
ext.description = 'A library for Java that provides re-usable components commonly used by Flow libraries.'
// 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.2.8' // 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 {
compile 'com.flowpowered:flow-math:1.0.1'
compile 'com.github.wolf480pl:jline-log4j2-appender:1.0.0'
compile 'jline:jline:2.13'
compile 'net.sf.trove4j:trove4j:3.0.3'
compile 'org.apache.commons:commons-lang3:3.3.4'
compile 'org.slf4j:slf4j-api:1.7.12'
compile 'uk.org.lidalia:lidalia-slf4j-ext:1.0.0'
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-library:1.3'
testCompile 'org.powermock:powermock-api-mockito:1.6.2'
testCompile 'org.powermock:powermock-module-junit4:1.6.2'
}
// 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.7'
targetCompatibility = '1.7'
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/commons.git'
developerConnection 'scm:git:ssh://[email protected]:flow/commons.git'
url 'https://github.com/flow/commons'
}
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]'
}
}
}
}
}