Skip to content

Commit 761cd6e

Browse files
committed
build.gradle splitting, Java 7, lint
1 parent 08009be commit 761cd6e

File tree

4 files changed

+130
-38
lines changed

4 files changed

+130
-38
lines changed

Diff for: build.gradle

+51-38
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/* * Copyright (c) 2014, Francis Galiegue ([email protected])
1+
/*
2+
* Copyright (c) 2014, Francis Galiegue ([email protected])
23
*
34
* This software is dual-licensed under:
45
*
@@ -18,15 +19,21 @@
1819

1920
buildscript {
2021
repositories {
22+
mavenCentral()
2123
maven {
2224
url "http://repo.springsource.org/plugins-release";
2325
}
2426
}
2527
dependencies {
28+
classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:4.2.0'
2629
classpath(group: "org.springframework.build.gradle", name: "propdeps-plugin", version: "0.0.7");
2730
}
2831
};
2932

33+
plugins {
34+
id("net.ltgt.errorprone") version "0.8.1" apply false
35+
}
36+
3037
configure(allprojects) {
3138
apply(plugin: "propdeps");
3239
apply(plugin: "propdeps-maven");
@@ -37,51 +44,45 @@ configure(allprojects) {
3744
apply(plugin: "java");
3845
apply(plugin: "maven");
3946
apply(plugin: "signing");
40-
apply(plugin: "osgi");
47+
apply(plugin: "biz.aQute.bnd.builder");
4148
apply(plugin: "idea");
4249
apply(plugin: "eclipse");
50+
apply(plugin: "net.ltgt.errorprone");
51+
52+
apply(from: "project.gradle");
4353

4454
group = "com.github.java-json-tools";
45-
version = "1.11-SNAPSHOT";
46-
sourceCompatibility = "1.6";
47-
targetCompatibility = "1.6"; // defaults to sourceCompatibility
55+
56+
ext.forRelease = !version.endsWith("-SNAPSHOT");
4857

4958
/*
50-
* List of dependencies
59+
* Repositories to use
5160
*/
52-
dependencies {
53-
provided(group: "com.google.code.findbugs", name: "jsr305", version: "2.0.1");
54-
compile(group: "com.github.java-json-tools", name: "jackson-coreutils", version: "1.9");
55-
testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
56-
exclude(group: "junit", module: "junit");
57-
exclude(group: "org.beanshell", module: "bsh");
58-
exclude(group: "org.yaml", module: "snakeyaml");
59-
};
60-
testCompile(group: "org.mockito", name: "mockito-core", version: "1.9.5");
61-
testCompile(group: "org.assertj", name: "assertj-core", version: "1.7.0");
62-
}
63-
64-
javadoc.options {
65-
def currentJavaVersion = org.gradle.api.JavaVersion.current()
66-
// FIXME: https://github.com/gradle/gradle/issues/11182
67-
if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
68-
addStringOption("-release", "6");
61+
repositories {
62+
mavenCentral();
63+
if (!forRelease) {
64+
maven {
65+
url "https://oss.sonatype.org/content/repositories/snapshots"
66+
}
67+
}
68+
/* Allow staging references for last pre-release testing. */
69+
if (project.properties.containsKey("sonatypeUsername")) {
70+
maven {
71+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
72+
credentials {
73+
username = project.properties["sonatypeUsername"]
74+
password = project.properties["sonatypePassword"]
75+
}
76+
}
6977
}
70-
links("https://docs.oracle.com/javase/6/docs/api/");
71-
links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.1/");
72-
links("https://fasterxml.github.com/jackson-databind/javadoc/2.2.0/");
73-
links("https://fasterxml.github.com/jackson-core/javadoc/2.2.0/");
74-
links("https://fasterxml.github.com/jackson-annotations/javadoc/2.2.0/");
75-
links("https://www.javadoc.io/doc/com.google.guava/guava/16.0.1/");
76-
links("https://fge.github.io/msg-simple/");
77-
links("https://fge.github.io/jackson-coreutils/");
7878
}
7979

8080
/*
81-
* Repositories to use
81+
* Add errorprone checking.
8282
*/
83-
repositories {
84-
mavenCentral();
83+
dependencies {
84+
errorprone("com.google.errorprone:error_prone_core:2.3.3")
85+
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
8586
}
8687

8788
/*
@@ -102,6 +103,20 @@ task sourcesJar(type: Jar, dependsOn: classes) {
102103
from sourceSets.main.allSource;
103104
}
104105

106+
/*
107+
* Lint all the things!
108+
*/
109+
allprojects {
110+
gradle.projectsEvaluated {
111+
tasks.withType(JavaCompile) {
112+
options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Werror"
113+
}
114+
tasks.withType(Javadoc) {
115+
options.addStringOption('Xwerror', '-quiet')
116+
}
117+
}
118+
}
119+
105120
/*
106121
* Javadoc: we need to tell where the overview.html is, it will not pick it up
107122
* automatically...
@@ -138,8 +153,7 @@ task pom {
138153
*/
139154

140155
project.ext {
141-
description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java";
142-
scmUrl = sprintf("[email protected]:java-json-tools/%s.git", name)
156+
scmUrl = sprintf("[email protected]:java-json-tools/%s.git", name);
143157
projectURL = sprintf("https://github.com/java-json-tools/%s", name);
144158
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
145159
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
@@ -152,7 +166,7 @@ task checkSigningRequirements {
152166
requiredProperties.each {
153167
if (project.properties[it] == null) {
154168
noDice = true;
155-
System.err.printf("property \"%s\" is not defined!")
169+
System.err.printf("property \"%s\" is not defined!\n", it);
156170
}
157171
}
158172
if (noDice)
@@ -228,7 +242,6 @@ uploadArchives {
228242
}
229243
}
230244

231-
ext.forRelease = !version.endsWith("-SNAPSHOT");
232245
signing {
233246
required { forRelease && gradle.taskGraph.hasTask("uploadArchives") };
234247
sign configurations.archives;

Diff for: project.gradle

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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 this file and of both licenses is available at the root of this
11+
* project or, if you have the jar distribution, in directory META-INF/, under
12+
* the names LGPL-3.0.txt and ASL-2.0.txt respectively.
13+
*
14+
* Direct link to the sources:
15+
*
16+
* - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
17+
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
18+
*/
19+
20+
/*
21+
* Project-specific settings. Unfortunately we cannot put the name in there!
22+
*/
23+
group = "com.github.java-json-tools";
24+
version = "1.11-SNAPSHOT";
25+
sourceCompatibility = JavaVersion.VERSION_1_7;
26+
targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility
27+
project.ext.description = "JSON Patch (RFC 6902) and JSON Merge Patch (RFC 7386) implementation in Java";
28+
29+
/*
30+
* List of dependencies
31+
*/
32+
dependencies {
33+
provided(group: "com.google.code.findbugs", name: "jsr305", version: "2.0.1");
34+
compile(group: "com.github.java-json-tools", name: "jackson-coreutils", version: "1.9");
35+
testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
36+
exclude(group: "junit", module: "junit");
37+
exclude(group: "org.beanshell", module: "bsh");
38+
exclude(group: "org.yaml", module: "snakeyaml");
39+
};
40+
testCompile(group: "org.mockito", name: "mockito-core", version: "1.9.5");
41+
testCompile(group: "org.assertj", name: "assertj-core", version: "1.7.0");
42+
}
43+
44+
javadoc.options {
45+
def currentJavaVersion = org.gradle.api.JavaVersion.current()
46+
// FIXME: https://github.com/gradle/gradle/issues/11182
47+
if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
48+
addStringOption("-release", "7");
49+
}
50+
links("https://docs.oracle.com/javase/7/docs/api/");
51+
links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.1/");
52+
links("https://fasterxml.github.com/jackson-databind/javadoc/2.2.0/");
53+
links("https://fasterxml.github.com/jackson-core/javadoc/2.2.0/");
54+
links("https://fasterxml.github.com/jackson-annotations/javadoc/2.2.0/");
55+
links("https://www.javadoc.io/doc/com.google.guava/guava/16.0.1/");
56+
links("https://fge.github.io/msg-simple/");
57+
links("https://fge.github.io/jackson-coreutils/");
58+
}

Diff for: settings.gradle

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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 this file and of both licenses is available at the root of this
11+
* project or, if you have the jar distribution, in directory META-INF/, under
12+
* the names LGPL-3.0.txt and ASL-2.0.txt respectively.
13+
*
14+
* Direct link to the sources:
15+
*
16+
* - LGPL 3.0: https://www.gnu.org/licenses/lgpl-3.0.txt
17+
* - ASL 2.0: http://www.apache.org/licenses/LICENSE-2.0.txt
18+
*/
19+
20+
rootProject.name = "json-patch";

Diff for: src/main/java/com/github/fge/jsonpatch/diff/JsonDiff.java

+1
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ private static void computeUnchanged(final Map<JsonPointer, JsonNode> ret,
235235
break;
236236
case ARRAY:
237237
computeArray(ret, pointer, first, second);
238+
break;
238239
default:
239240
/* nothing */
240241
}

0 commit comments

Comments
 (0)