forked from RPTools/rplib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
288 lines (259 loc) · 8.84 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/*
* The goal is for this build file to be usable for all RPTools library
* projects in the future. When you make changes, keep that in mind and
* try to use variables for things that will be different from library
* to library, preferably with a function that can automatically
* determine the value...
*
* Search for 'RPTools' to see the variables defined so far.
*/
import org.apache.tools.ant.filters.ReplaceTokens
import java.text.SimpleDateFormat
import org.ajoberstar.grgit.*
buildscript {
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
// Currently holds withay-util and abeille-formsrt
url "http://maptool.craigs-stuff.net/repo/"
}
}
dependencies {
classpath 'org.ajoberstar:gradle-git:0.11.2'
classpath 'com.diffplug.gradle.spotless:spotless:1.3.0-SNAPSHOT'
}
}
plugins {
id "com.jfrog.bintray" version "1.7.3"
id "maven-publish"
id "java-library" // Solution for gradle issue#1118
id "java"
id 'findbugs'
id 'pmd'
id 'maven'
id 'com.diffplug.gradle.spotless' version "1.3.0"
id 'eclipse'
}
// ================================================================
// Change these below for each library. Don't touch anything else!
String reponame = 'RPTools'
String repourl = 'github.com/'+reponame+'/'+project.name
String userOrganization = 'rptools'
String description = 'General library of role-playing functionality'
String libName = 'RP lib' // only used by bintrayUpload (unused)
// Change these above for each library. Don't touch anything else!
// ================================================================
ext.gitrepo = Grgit.open(project.file('.'))
ext.compileDate = new Date();
ext.yyyymmdd = (new SimpleDateFormat('yyyyMMDD')).format(ext.compileDate);
sourceCompatibility = 1.8
version = getVersionName()
task createBintrayDeploymentDescription(type: Copy) {
from 'package'
into 'package'
include 'template.deploy.json'
rename { String filename -> filename.replace('template', 'bintray') }
// Use some of the filters provided by Ant
filter(ReplaceTokens, tokens: [
NAME: project.name,
DESCRIPTION: description,
LICENSE: "LGPL-3.0", // All libs are LGPLv3
VERSION: version
])
// Use a closure to remove comment lines
// (we're not currently using any, but...)
filter { String line -> line.startsWith('#') ? null : line }
filteringCharset = 'UTF-8'
}
// When building the JAR, make sure the deployment descriptor for
// bintray is also created. While this runs the descriptor creation
// before the JAR is actually built, the order doesn't really matter.
jar.dependsOn(createBintrayDeploymentDescription)
spotless {
java {
eclipseFormatFile 'build-resources/eclipse.prefs.formatter.xml'
}
format 'misc', {
target '**/*.gradle', '**/*.md', '**/.gitignore'
// spotless has built-in rules for the most basic formatting tasks
trimTrailingWhitespace()
indentWithSpaces(4)
}
}
// Travis is now using Gradle 4.0 by default (required by Java9) so
// maybe we don't need to specify something more recent than that...
task wrapper(type: Wrapper) {
gradleVersion = '4.5.1'
}
dependencies {
compile 'antlr:antlr:2.7.6'
compile 'commons-io:commons-io:2.4'
compile 'com.thoughtworks.xstream:xstream:1.4.10'
compile 'commons-lang:commons-lang:2.6'
compile 'commons-logging:commons-logging:1.1.1'
compile 'commons-net:commons-net:3.2'
compile 'log4j:log4j:1.2.16'
compile 'com.withay:withay-util:1.0'
compile 'de.huxhorn.sulky:de.huxhorn.sulky.3rdparty.jlayer:1.0'
compile 'net.java.abeille:abeille-formsrt:2.0'
testCompile 'junit:junit:4.11'
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven {
// Currently holds withay-util and abeille-formsrt
url "http://maptool.craigs-stuff.net/repo/"
}
}
def pomConfig = {
licenses {
license {
name "The Lesser General Public License, v3.0"
url "http://www.gnu.org/licenses/"
distribution "repo"
}
}
developers {
developer {
id userOrganization // 'rptools'
name userOrganization // 'rptools'
email "[email protected]"
}
}
scm {
url "https://"+repourl
}
}
publishing {
publications {
bintrayPublication(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
artifactId = project.name
version = project.version
groupId = 'net.rptools.'+project.name;
pom.withXml {
def root = asNode()
root.appendNode('description', description)
root.appendNode('name', libName)
root.appendNode('url', "https://"+repourl)
root.children().last() + pomConfig
}
}
}
}
bintray {
user = System.getProperty('bintray.user')
key = System.getProperty('bintray.key')
String publishProperty = System.getProperty('publish')
publications = ['bintrayPublication']
// Whether to run this as dry-run, without deploying
dryRun = false
// Whether version should be auto published after an upload
publish = (publishProperty == "true")
if (publish) {
println "Publishing uploaded files for " + getVersionName()
} else {
println "Not publishing uploaded files for " + getVersionName()
}
// Whether to override version artifacts already published
override = true
pkg {
// result is 'rptools/RPTools/rplib'
userOrg = userOrganization
repo = reponame
name = project.name
// The rest of these are supposed to establish the contents of
// the various fields at the bintray site, but so far they
// haven't seemed to propagate. Will figure out why at some
// point (but I have hand-edited the 1419 details).
desc = description
licenses = ['LGPL-3.0']
websiteUrl = 'http://www.rptools.net/'
issueTrackerUrl = 'http://'+repourl+'/issues'
vcsUrl = 'https://'+repourl+'.git'
//labels = ['blah', 'yada', 'meh']
publicDownloadNumbers = true
githubRepo = reponame+'/'+userOrg
githubReleaseNotesFile = 'README.md'
version {
name = getVersionName()
// It would be nice if 'desc' could contain "dev" when the
// third field is an odd number and "stable" when the third
// field is an even number... Too much work right now.
desc = "Description of " + name // Where does this show up?
released = new Date()
vcsTag = name
// At some point, we may want to publish to Maven, but these
// are unused for now.
gpg {
sign = true
passphrase = 'my_passphrase'
}
mavenCentralSync {
sync = false
user = 'rptools'
password = 'password'
close = '1'
}
}
}
}
/*
* Gets the version name from
* 1. The command line (allows using $TRAVIS_TAG),
* 2. 'gradle.properties' (for development builds), or
* 3. 'build-resources/version.txt' (the 'official' version number).
*/
def getVersionName() {
String vers = System.getProperty('version')
if (vers != null && vers != '')
return vers
if (project.hasProperty('buildVersion'))
return buildVersion
vers = new File('build-resources/version.txt').text.trim()
return vers
}
findbugs {
ignoreFailures = true
toolVersion = '3.0.0'
effort = 'max'
sourceSets = [] // Empty source set so it wont run during build/check
}
pmd {
ignoreFailures = true
sourceSets = [] // Empty source set so it wont run during tebuild/check
}
jar {
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Built-By': System.getProperty('user.name'),
'Built-Date': new Date(),
'Built-JDK': System.getProperty('java.version'),
'Source-Compatibility': project.sourceCompatibility
}
/*
include("**")
// This next line doesn't work. figure it out later...
include("../../packages/license/COPYING.LGPLv3")
*/
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources' // Added to the end of the filename
from sourceSets.main.allSource
}
javadoc.failOnError = false
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc' // Added to the end of the filename
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}