Skip to content

Commit ac9cb52

Browse files
committed
Split monolithic build.gradle into project and settings.
1 parent 23d0e5f commit ac9cb52

File tree

3 files changed

+142
-74
lines changed

3 files changed

+142
-74
lines changed

Diff for: build.gradle

+47-74
Original file line numberDiff line numberDiff line change
@@ -16,87 +16,66 @@
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+
};
27+
1928
plugins {
2029
id("net.ltgt.errorprone") version "0.8.1" apply false
2130
}
2231

2332
apply(plugin: "java");
2433
apply(plugin: "maven");
2534
apply(plugin: "signing");
26-
apply(plugin: "osgi");
35+
apply(plugin: "biz.aQute.bnd.builder");
2736
apply(plugin: "idea");
2837
apply(plugin: "eclipse");
2938
apply(plugin: "net.ltgt.errorprone");
3039

31-
group = "com.github.java-json-tools";
32-
33-
version = "0.8.2-SNAPSHOT";
34-
sourceCompatibility = JavaVersion.VERSION_1_7;
35-
targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility
40+
apply(from: "project.gradle");
3641

37-
project.ext {
38-
description = "Sample JSON Schema related processors using json-schema-core and various external libraries";
39-
};
42+
group = "com.github.java-json-tools";
4043

44+
ext.forRelease = !version.endsWith("-SNAPSHOT");
4145

4246
/*
4347
* Repositories to use
4448
*/
4549
repositories {
4650
mavenCentral();
51+
if (!forRelease) {
52+
maven {
53+
url "https://oss.sonatype.org/content/repositories/snapshots"
54+
}
55+
}
56+
/* Allow staging references for last pre-release testing. */
57+
if (project.properties.containsKey("sonatypeUsername")) {
58+
maven {
59+
url "https://oss.sonatype.org/service/local/staging/deploy/maven2"
60+
credentials {
61+
username = project.properties["sonatypeUsername"]
62+
password = project.properties["sonatypePassword"]
63+
}
64+
}
65+
}
4766
}
4867

49-
5068
/*
51-
* List of dependencies
69+
* Add errorprone checking.
5270
*/
5371
dependencies {
5472
errorprone("com.google.errorprone:error_prone_core:2.3.3")
5573
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
56-
compile(group: "com.github.java-json-tools", name: "json-schema-validator",
57-
version: "2.2.12");
58-
compile(group: "com.github.reinert", name: "jjschema", version: "0.6") {
59-
exclude(group: "com.google.guava", module: "guava");
60-
exclude(group: "com.fasterxml.jackson.core", module: "jackson-core");
61-
exclude(group: "com.fasterxml.jackson.core", module: "jackson-databind");
62-
}
63-
compile(group: "com.googlecode.jsonschema2pojo",
64-
name: "jsonschema2pojo-core", version: "0.3.5") {
65-
exclude(group: "com.fasterxml.jackson.core", module: "jackson-core");
66-
exclude(group: "com.fasterxml.jackson.core", module: "jackson-databind");
67-
}
68-
compile(group: "com.github.java-json-tools", name: "json-schema-avro",
69-
version: "0.1.5");
70-
compile(group: "com.github.java-json-tools", name: "json-patch",
71-
version: "1.11");
72-
testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
73-
exclude(group: "junit", module: "junit");
74-
exclude(group: "org.beanshell", module: "bsh");
75-
exclude(group: "org.yaml", module: "snakeyaml");
76-
};
77-
testCompile(group: "org.mockito", name: "mockito-core", version: "2.28.2");
78-
}
79-
80-
javadoc {
81-
options {
82-
def currentJavaVersion = org.gradle.api.JavaVersion.current()
83-
// FIXME: https://github.com/gradle/gradle/issues/11182
84-
if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
85-
addStringOption("-release", "7");
86-
}
87-
links("https://docs.oracle.com/javase/7/docs/api/");
88-
links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.1/");
89-
links("https://fasterxml.github.com/jackson-databind/javadoc/2.2.0/");
90-
links("https://www.javadoc.io/doc/com.google.guava/guava/16.0.1/");
91-
links("https://fge.github.io/msg-simple/");
92-
}
9374
}
9475

9576
/*
9677
* Necessary! Otherwise TestNG will not be used...
9778
*
98-
* Also, we don't want gradle's default HTML report: it does not support
99-
* parameterized tests which I use a _lot_.
10079
*/
10180
test {
10281
useTestNG() {
@@ -112,6 +91,20 @@ task sourcesJar(type: Jar, dependsOn: classes) {
11291
from sourceSets.main.allSource;
11392
}
11493

94+
/*
95+
* Lint all the things!
96+
*/
97+
allprojects {
98+
gradle.projectsEvaluated {
99+
tasks.withType(JavaCompile) {
100+
options.compilerArgs << "-Xlint:all" << "-Xlint:-serial"<< "-Werror"
101+
}
102+
tasks.withType(Javadoc) {
103+
options.addStringOption('Xwerror', '-quiet')
104+
}
105+
}
106+
}
107+
115108
/*
116109
* Javadoc: we need to tell where the overview.html is, it will not pick it up
117110
* automatically...
@@ -126,29 +119,10 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
126119
from javadoc.destinationDir;
127120
}
128121

129-
//fatJar {
130-
// classifier = "full";
131-
//}
132-
133-
/*
134-
* Lint all the things!
135-
*/
136-
allprojects {
137-
gradle.projectsEvaluated {
138-
tasks.withType(JavaCompile) {
139-
options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Werror"
140-
}
141-
tasks.withType(Javadoc) {
142-
options.addStringOption('Xwerror', '-quiet')
143-
}
144-
}
145-
}
146-
147122
artifacts {
148123
archives jar;
149124
archives sourcesJar;
150125
archives javadocJar;
151-
// bad idea: archives fatJar;
152126
}
153127

154128
wrapper {
@@ -167,7 +141,7 @@ task pom {
167141
*/
168142

169143
project.ext {
170-
scmUrl = sprintf("[email protected]:java-json-tools/%s.git", name)
144+
scmUrl = sprintf("[email protected]:java-json-tools/%s.git", name);
171145
projectURL = sprintf("https://github.com/java-json-tools/%s", name);
172146
sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/";
173147
sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/";
@@ -180,7 +154,7 @@ task checkSigningRequirements {
180154
requiredProperties.each {
181155
if (project.properties[it] == null) {
182156
noDice = true;
183-
System.err.printf("property \"%s\" is not defined!")
157+
System.err.printf("property \"%s\" is not defined!\n", it);
184158
}
185159
}
186160
if (noDice)
@@ -222,9 +196,9 @@ uploadArchives {
222196
uploadArchives.repositories.mavenDeployer
223197
]*.pom*.whenConfigured { pom ->
224198
pom.project {
225-
name "${name}";
199+
name "${project.name}";
226200
packaging "jar";
227-
description "${description}";
201+
description "${project.ext.description}";
228202
url "${projectURL}";
229203

230204
scm {
@@ -256,7 +230,6 @@ uploadArchives {
256230
}
257231
}
258232

259-
ext.forRelease = !version.endsWith("-SNAPSHOT");
260233
signing {
261234
required { forRelease && gradle.taskGraph.hasTask("uploadArchives") };
262235
sign configurations.archives;

Diff for: project.gradle

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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+
/*
20+
* Project-specific settings. Unfortunately we cannot put the name in there!
21+
*/
22+
group = "com.github.java-json-tools";
23+
version = "0.8.2-SNAPSHOT";
24+
sourceCompatibility = JavaVersion.VERSION_1_7;
25+
targetCompatibility = JavaVersion.VERSION_1_7; // defaults to sourceCompatibility
26+
27+
project.ext {
28+
description = "Sample JSON Schema related processors using json-schema-core and various external libraries";
29+
};
30+
31+
/*
32+
* List of dependencies
33+
*/
34+
dependencies {
35+
errorprone("com.google.errorprone:error_prone_core:2.3.3")
36+
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
37+
compile(group: "com.github.java-json-tools", name: "json-schema-validator",
38+
version: "2.2.12");
39+
compile(group: "com.github.reinert", name: "jjschema", version: "0.6") {
40+
exclude(group: "com.google.guava", module: "guava");
41+
exclude(group: "com.fasterxml.jackson.core", module: "jackson-core");
42+
exclude(group: "com.fasterxml.jackson.core", module: "jackson-databind");
43+
}
44+
compile(group: "com.googlecode.jsonschema2pojo",
45+
name: "jsonschema2pojo-core", version: "0.3.5") {
46+
exclude(group: "com.fasterxml.jackson.core", module: "jackson-core");
47+
exclude(group: "com.fasterxml.jackson.core", module: "jackson-databind");
48+
}
49+
compile(group: "com.github.java-json-tools", name: "json-schema-avro",
50+
version: "0.1.5");
51+
compile(group: "com.github.java-json-tools", name: "json-patch",
52+
version: "1.11");
53+
testCompile(group: "org.testng", name: "testng", version: "6.8.7") {
54+
exclude(group: "junit", module: "junit");
55+
exclude(group: "org.beanshell", module: "bsh");
56+
exclude(group: "org.yaml", module: "snakeyaml");
57+
};
58+
testCompile(group: "org.mockito", name: "mockito-core", version: "2.28.2");
59+
}
60+
61+
javadoc.options {
62+
def currentJavaVersion = org.gradle.api.JavaVersion.current()
63+
// FIXME: https://github.com/gradle/gradle/issues/11182
64+
if (currentJavaVersion.compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
65+
addStringOption("-release", "7");
66+
}
67+
links("https://docs.oracle.com/javase/7/docs/api/");
68+
links("https://www.javadoc.io/doc/com.google.code.findbugs/jsr305/3.0.2/");
69+
links("https://fasterxml.github.com/jackson-databind/javadoc/2.9/");
70+
links("https://fasterxml.github.com/jackson-core/javadoc/2.9/");
71+
links("https://fasterxml.github.com/jackson-annotations/javadoc/2.9/");
72+
links("https://www.javadoc.io/doc/com.google.guava/guava/28.1-android/");
73+
links("https://java-json-tools.github.io/msg-simple/");
74+
links("https://java-json-tools.github.io/json-schema-core/1.2.x/");
75+
links("https://java-json-tools.github.io/json-schema-validator/2.2.x/");
76+
}

Diff for: settings.gradle

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
rootProject.name = "json-schema-processor-examples";

0 commit comments

Comments
 (0)