Skip to content

Commit 64713ad

Browse files
committed
Modernization updates
* Java 7 * OSGi * Gradle 5.6.3 * lint / errorprone, plus some fixes * TravisCI * bump validator version to latest * bump mockito-core version to latest
1 parent 30cec8a commit 64713ad

File tree

9 files changed

+204
-113
lines changed

9 files changed

+204
-113
lines changed

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: java
2+
jdk:
3+
- openjdk8
4+
- openjdk11
5+
install: {}
6+
script:
7+
- ./gradlew assemble check
8+
9+
before_cache:
10+
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
11+
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
12+
13+
cache:
14+
directories:
15+
- $HOME/.gradle/caches/
16+
- $HOME/.gradle/wrapper/
17+

build.gradle

+83-30
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
1717
*/
1818

19+
buildscript {
20+
repositories {
21+
mavenCentral()
22+
}
23+
dependencies {
24+
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0'
25+
}
26+
};
1927

28+
plugins {
29+
id("net.ltgt.errorprone") version "0.8.1" apply false
30+
}
2031

2132
/*
2233
* This has to be here... It will not be taken into account in common.gradle!
@@ -51,24 +62,50 @@
5162
apply(plugin: "java");
5263
apply(plugin: "maven");
5364
apply(plugin: "signing");
54-
apply(plugin: "osgi");
65+
apply(plugin: "biz.aQute.bnd.builder");
5566
apply(plugin: "idea");
5667
apply(plugin: "eclipse");
68+
apply(plugin: "net.ltgt.errorprone");
5769

5870
apply(from: "project.gradle");
5971

72+
group = "com.github.java-json-tools";
73+
74+
ext.forRelease = !version.endsWith("-SNAPSHOT");
75+
6076
/*
6177
* Repositories to use
6278
*/
6379
repositories {
6480
mavenCentral();
81+
if (!forRelease) {
82+
maven {
83+
url "https://oss.sonatype.org/content/repositories/snapshots"
84+
}
85+
}
86+
/* Allow staging references for last pre-release testing. */
87+
if (project.properties.containsKey("sonatypeUsername")) {
88+
maven {
89+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
90+
credentials {
91+
username = project.properties["sonatypeUsername"]
92+
password = project.properties["sonatypePassword"]
93+
}
94+
}
95+
}
96+
}
97+
98+
/*
99+
* Add errorprone checking.
100+
*/
101+
dependencies {
102+
errorprone("com.google.errorprone:error_prone_core:2.3.3")
103+
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
65104
}
66105

67106
/*
68107
* Necessary! Otherwise TestNG will not be used...
69108
*
70-
* Also, we don't want gradle's default HTML report: it does not support
71-
* parameterized tests which I use a _lot_.
72109
*/
73110
test {
74111
useTestNG() {
@@ -84,6 +121,20 @@ task sourcesJar(type: Jar, dependsOn: classes) {
84121
from sourceSets.main.allSource;
85122
}
86123

124+
/*
125+
* Lint all the things!
126+
*/
127+
allprojects {
128+
gradle.projectsEvaluated {
129+
tasks.withType(JavaCompile) {
130+
options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Xlint:-deprecation" << "-Werror"
131+
}
132+
tasks.withType(Javadoc) {
133+
options.addStringOption('Xwerror', '-quiet')
134+
}
135+
}
136+
}
137+
87138
/*
88139
* Javadoc: we need to tell where the overview.html is, it will not pick it up
89140
* automatically...
@@ -104,39 +155,42 @@ artifacts {
104155
archives javadocJar;
105156
}
106157

107-
task wrapper(type: Wrapper) {
108-
gradleVersion = "1.11";
109-
distributionUrl = "http://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
158+
wrapper {
159+
gradleVersion = "5.6.3";
160+
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip";
110161
}
111162

112-
task pom << {
113-
pom {}.writeTo("${projectDir}/pom.xml");
163+
task pom {
164+
doLast {
165+
pom {}.writeTo("${projectDir}/pom.xml");
166+
}
114167
}
115168

116169
/*
117170
* SIGNING
118171
*/
119172

120173
project.ext {
121-
gitrwscm = sprintf("[email protected]:fge/%s", name);
122-
gitroscm = sprintf("https://github.com/fge/%s.git", name);
123-
projectURL = sprintf("https://github.com/fge/%s", name);
174+
scmUrl = sprintf("[email protected]:java-json-tools/%s.git", name);
175+
projectURL = sprintf("https://github.com/java-json-tools/%s", name);
124176
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
125177
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
126178
};
127179

128-
task checkSigningRequirements << {
129-
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
130-
def noDice = false;
131-
requiredProperties.each {
132-
if (project.properties[it] == null) {
133-
noDice = true;
134-
System.err.printf("property \"%s\" is not defined!")
180+
task checkSigningRequirements {
181+
doLast {
182+
def requiredProperties = [ "sonatypeUsername", "sonatypePassword" ];
183+
def noDice = false;
184+
requiredProperties.each {
185+
if (project.properties[it] == null) {
186+
noDice = true;
187+
System.err.printf("property \"%s\" is not defined!\n", it);
188+
}
135189
}
190+
if (noDice)
191+
throw new IllegalStateException("missing required properties for " +
192+
"upload");
136193
}
137-
if (noDice)
138-
throw new IllegalStateException("missing required properties for " +
139-
"upload");
140194
}
141195

142196
uploadArchives {
@@ -172,15 +226,15 @@ uploadArchives {
172226
uploadArchives.repositories.mavenDeployer
173227
]*.pom*.whenConfigured { pom ->
174228
pom.project {
175-
name "${name}";
229+
name "${project.name}";
176230
packaging "jar";
177-
description "${description}";
231+
description "${project.ext.description}";
178232
url "${projectURL}";
179233

180234
scm {
181-
url "${gitrwscm}";
182-
connection "${gitrwscm}";
183-
developerConnection "${gitroscm}";
235+
url "${scmUrl}";
236+
connection "${scmUrl}";
237+
developerConnection "scm:git:${scmUrl}";
184238
}
185239

186240
licenses {
@@ -198,15 +252,14 @@ uploadArchives {
198252

199253
developers {
200254
developer {
201-
id "fge";
202-
name "Francis Galiegue";
203-
email "fgaliegue@gmail.com";
255+
id "huggsboson";
256+
name "John Huffaker";
257+
email "jhuffaker+java-json-tools@gmail.com";
204258
}
205259
}
206260
}
207261
}
208262

209-
ext.forRelease = !version.endsWith("-SNAPSHOT");
210263
signing {
211264
required { forRelease && gradle.taskGraph.hasTask("uploadArchives") };
212265
sign configurations.archives;

gradle/wrapper/gradle-wrapper.jar

4.4 KB
Binary file not shown.
+1-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,5 @@
1-
#
2-
# Copyright (c) 2014, Francis Galiegue ([email protected])
3-
#
4-
# This software is dual-licensed under:
5-
#
6-
# - the Lesser General Public License (LGPL) version 3.0 or, at your option, any
7-
# later version;
8-
# - the Apache Software License (ASL) version 2.0.
9-
#
10-
# The text of both licenses is available under the src/resources/ directory of
11-
# this project (under the names LGPL-3.0.txt and ASL-2.0.txt respectively).
12-
#
13-
# Direct link to the sources:
14-
#
15-
# - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
16-
# - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
17-
#
18-
19-
#Tue Apr 08 12:56:01 CEST 2014
201
distributionBase=GRADLE_USER_HOME
212
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-all.zip
224
zipStoreBase=GRADLE_USER_HOME
235
zipStorePath=wrapper/dists
24-
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip

gradlew

+61-37
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,59 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env sh
2+
3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
218

319
##############################################################################
420
##
521
## Gradle start up script for UN*X
622
##
723
##############################################################################
824

9-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10-
DEFAULT_JVM_OPTS=""
25+
# Attempt to set APP_HOME
26+
# Resolve links: $0 may be a link
27+
PRG="$0"
28+
# Need this for relative symlinks.
29+
while [ -h "$PRG" ] ; do
30+
ls=`ls -ld "$PRG"`
31+
link=`expr "$ls" : '.*-> \(.*\)$'`
32+
if expr "$link" : '/.*' > /dev/null; then
33+
PRG="$link"
34+
else
35+
PRG=`dirname "$PRG"`"/$link"
36+
fi
37+
done
38+
SAVED="`pwd`"
39+
cd "`dirname \"$PRG\"`/" >/dev/null
40+
APP_HOME="`pwd -P`"
41+
cd "$SAVED" >/dev/null
1142

1243
APP_NAME="Gradle"
1344
APP_BASE_NAME=`basename "$0"`
1445

46+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48+
1549
# Use the maximum available, or set MAX_FD != -1 to use that value.
1650
MAX_FD="maximum"
1751

18-
warn ( ) {
52+
warn () {
1953
echo "$*"
2054
}
2155

22-
die ( ) {
56+
die () {
2357
echo
2458
echo "$*"
2559
echo
@@ -30,6 +64,7 @@ die ( ) {
3064
cygwin=false
3165
msys=false
3266
darwin=false
67+
nonstop=false
3368
case "`uname`" in
3469
CYGWIN* )
3570
cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
4075
MINGW* )
4176
msys=true
4277
;;
78+
NONSTOP* )
79+
nonstop=true
80+
;;
4381
esac
4482

45-
# For Cygwin, ensure paths are in UNIX format before anything is touched.
46-
if $cygwin ; then
47-
[ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48-
fi
49-
50-
# Attempt to set APP_HOME
51-
# Resolve links: $0 may be a link
52-
PRG="$0"
53-
# Need this for relative symlinks.
54-
while [ -h "$PRG" ] ; do
55-
ls=`ls -ld "$PRG"`
56-
link=`expr "$ls" : '.*-> \(.*\)$'`
57-
if expr "$link" : '/.*' > /dev/null; then
58-
PRG="$link"
59-
else
60-
PRG=`dirname "$PRG"`"/$link"
61-
fi
62-
done
63-
SAVED="`pwd`"
64-
cd "`dirname \"$PRG\"`/" >&-
65-
APP_HOME="`pwd -P`"
66-
cd "$SAVED" >&-
67-
6883
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6984

7085
# Determine the Java command to use to start the JVM.
@@ -90,7 +105,7 @@ location of your Java installation."
90105
fi
91106

92107
# Increase the maximum file descriptors if we can.
93-
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
108+
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
94109
MAX_FD_LIMIT=`ulimit -H -n`
95110
if [ $? -eq 0 ] ; then
96111
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -110,10 +125,11 @@ if $darwin; then
110125
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111126
fi
112127

113-
# For Cygwin, switch paths to Windows format before running java
114-
if $cygwin ; then
128+
# For Cygwin or MSYS, switch paths to Windows format before running java
129+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
115130
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116131
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132+
JAVACMD=`cygpath --unix "$JAVACMD"`
117133

118134
# We build the pattern for arguments to be converted via cygpath
119135
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -154,11 +170,19 @@ if $cygwin ; then
154170
esac
155171
fi
156172

157-
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158-
function splitJvmOpts() {
159-
JVM_OPTS=("$@")
173+
# Escape application args
174+
save () {
175+
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176+
echo " "
160177
}
161-
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162-
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
178+
APP_ARGS=$(save "$@")
179+
180+
# Collect all arguments for the java command, following the shell quoting and substitution rules
181+
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182+
183+
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184+
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185+
cd "$(dirname "$0")"
186+
fi
163187

164-
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
188+
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)