Skip to content

Commit 726c063

Browse files
committed
Implement Java modularity
Resolves #66
1 parent a570db2 commit 726c063

File tree

48 files changed

+822
-59
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+822
-59
lines changed

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
- env: JOB=sonatype
4343
- env: JOB=docker
4444
- env: JOB=aws
45+
- env: JOB=jpms
4546

4647
include:
4748
# JDK 8
@@ -57,6 +58,13 @@ jobs:
5758
jdk: openjdk11
5859
script: travis_retry ./gradlew check install
5960

61+
# JDK 11 (modules)
62+
- name: "Java 11 (modules)"
63+
stage: test
64+
jdk: openjdk11
65+
env: JOB=jpms
66+
script: ./gradlew clean check install --continue -Pjpms
67+
6068
# deploy JDK 8 builds to Sonatype
6169
- name: "Publish to Sonatype"
6270
stage: deploy

auth/basic/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = 'Trellis Basic authentication filter'
55

66
ext {
77
moduleName = 'org.trellisldp.auth.basic'
8+
testModules = ['tamaya.core']
89
}
910

1011
dependencies {
@@ -14,8 +15,8 @@ dependencies {
1415

1516
implementation("org.apache.tamaya:tamaya-api:$tamayaVersion")
1617
implementation("org.slf4j:slf4j-api:$slf4jVersion")
18+
implementation("javax.xml.bind:jaxb-api:$jaxbVersion")
1719

18-
testRuntime("javax.xml.bind:jaxb-api:$jaxbVersion")
1920
testRuntime("javax.activation:javax.activation-api:$activationApiVersion")
2021

2122
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
module org.trellisldp.auth.basic {
15+
exports org.trellisldp.auth.basic;
16+
17+
requires slf4j.api;
18+
requires tamaya.api;
19+
requires javax.inject;
20+
requires java.ws.rs;
21+
requires java.xml.bind;
22+
requires java.annotation;
23+
24+
uses org.apache.tamaya.spi.ConfigurationProviderSpi;
25+
}

auth/oauth/build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ ext {
88
}
99

1010
dependencies {
11-
api("io.jsonwebtoken:jjwt-api:$jjwtVersion")
1211
api("javax.annotation:javax.annotation-api:$javaxAnnotationsVersion")
1312
api("javax.ws.rs:javax.ws.rs-api:$jaxrsVersion")
1413
api("org.glassfish.hk2.external:javax.inject:$javaxInjectVersion")
1514

15+
implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
1616
implementation("commons-io:commons-io:$commonsIoVersion")
17-
implementation("io.jsonwebtoken:jjwt-impl:$jjwtVersion")
18-
implementation("io.jsonwebtoken:jjwt-jackson:$jjwtVersion")
1917
implementation("org.apache.tamaya:tamaya-api:$tamayaVersion")
2018
implementation("org.slf4j:slf4j-api:$slf4jVersion")
19+
implementation("javax.xml.bind:jaxb-api:$jaxbVersion")
20+
implementation("io.jsonwebtoken:jjwt-jackson:$jjwtVersion")
21+
implementation("io.jsonwebtoken:jjwt-api:$jjwtVersion")
22+
implementation("io.jsonwebtoken:jjwt-impl:$jjwtVersion")
2123

22-
testRuntime("javax.xml.bind:jaxb-api:$jaxbVersion")
2324
testRuntime("javax.activation:javax.activation-api:$activationApiVersion")
2425

2526
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
@@ -28,4 +29,3 @@ dependencies {
2829
testImplementation("org.glassfish.jersey.core:jersey-server:$jerseyVersion")
2930
testImplementation("org.mockito:mockito-core:$mockitoVersion")
3031
}
31-

build.gradle

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ ext {
1919
commonsRdfVersion = '0.5.0'
2020
javaxAnnotationsVersion = '1.3.2'
2121
javaxInjectVersion = '2.5.0-b62'
22+
javaxJmsVersion = '2.0.1'
23+
javaxManagementVersion = '1.1.2'
2224
jaxrsVersion = '2.1.1'
2325
metricsVersion = '4.0.5'
2426
slf4jVersion = '1.7.25'
@@ -43,6 +45,7 @@ ext {
4345
kafkaVersion = '2.0.0'
4446
mustacheVersion = '0.9.5'
4547
rabbitMqVersion = '5.5.2'
48+
validationVersion = '2.0.1.Final'
4649

4750
/* Testing */
4851
apiguardianVersion = '1.0.0'
@@ -51,6 +54,7 @@ ext {
5154
commonsTextVersion = '1.6'
5255
junitVersion = '5.3.2'
5356
junitLauncherVersion = '1.3.2'
57+
hamcrestVersion = '2.1'
5458
logbackVersion = '1.2.3'
5559
mockitoVersion = '2.23.4'
5660
qpidVersion = '7.1.0'
@@ -149,8 +153,11 @@ allprojects { subproj ->
149153
}
150154

151155
configurations.all {
156+
exclude group: 'commons-logging', module: 'commons-logging'
152157
resolutionStrategy.dependencySubstitution {
153158
substitute module("org.apache.geronimo.specs:geronimo-annotation_1.2_spec") with module ("javax.annotation:javax.annotation-api:$javaxAnnotationsVersion")
159+
substitute module("org.apache.geronimo.specs:geronimo-jms_1.1_spec") with module("javax.jms:javax.jms-api:$javaxJmsVersion")
160+
substitute module("org.apache.geronimo.specs:geronimo-j2ee-management_1.1_spec") with module("javax.management.j2ee:javax.management.j2ee-api:$javaxManagementVersion")
154161
}
155162
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
156163
if (details.requested.group.startsWith('com.fasterxml.jackson.')) {
@@ -163,15 +170,81 @@ allprojects { subproj ->
163170

164171
subprojects { subproj ->
165172

166-
sourceCompatibility = 1.8
167-
targetCompatibility = 1.8
173+
def jpms = JavaVersion.current().isJava11Compatible() && subproj.hasProperty("jpms") &&
174+
sourceSets.main.allJava.getFiles().stream().map { file -> file.getName() }
175+
.anyMatch { file -> file == "module-info.java"}
176+
177+
sourceCompatibility = jpms ? 11 : 8
178+
targetCompatibility = jpms ? 11 : 8
179+
180+
afterEvaluate {
181+
if (jpms) {
182+
compileJava {
183+
inputs.property("moduleName", moduleName)
184+
doFirst {
185+
options.compilerArgs = [
186+
'--module-path', classpath.asPath,
187+
]
188+
classpath = files()
189+
}
190+
}
191+
compileTestJava {
192+
inputs.property("moduleName", moduleName)
193+
def mods = subproj.ext.has("testModules") ? subproj.ext.get("testModules") : []
194+
mods.add('org.junit.jupiter.api')
195+
doFirst {
196+
options.compilerArgs = [
197+
'--module-path', classpath.asPath,
198+
'--add-modules', mods.join(','),
199+
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
200+
]
201+
mods.forEach { mod -> options.compilerArgs += [ '--add-reads', "$moduleName=$mod"] }
202+
classpath = files()
203+
}
204+
}
205+
test {
206+
inputs.property("moduleName", moduleName)
207+
def mods = subproj.ext.has("testModules") ? subproj.ext.get("testModules") : []
208+
mods.add('org.junit.jupiter.api')
209+
doFirst {
210+
jvmArgs = [
211+
'--module-path', classpath.asPath,
212+
'--add-modules', 'ALL-MODULE-PATH',
213+
'--add-opens', "$moduleName/$moduleName=org.junit.platform.commons",
214+
'--add-opens', "$moduleName/$moduleName=org.mockito",
215+
'--patch-module', "$moduleName=" + files(sourceSets.main.output.resourcesDir, sourceSets.test.output).asPath,
216+
]
217+
mods.forEach { mod -> jvmArgs += [ '--add-reads', "$moduleName=$mod"] }
218+
classpath = files()
219+
}
220+
}
221+
222+
javadoc {
223+
options.addStringOption('-module-path', classpath.asPath)
224+
}
225+
}
226+
}
227+
228+
sourceSets {
229+
main {
230+
java {
231+
if (!jpms) {
232+
exclude '**/module-info.java'
233+
}
234+
}
235+
}
236+
}
168237

169238
jar {
170239
from("$rootDir/LICENSE") {
171240
into "META-INF"
172241
}
173242
}
174243

244+
test {
245+
useJUnitPlatform()
246+
}
247+
175248
checkstyle {
176249
configFile = rootProject.file('buildtools/src/main/resources/checkstyle/checkstyle.xml')
177250
configProperties.checkstyleConfigDir = rootProject.file('buildtools/src/main/resources/checkstyle/')
@@ -337,7 +410,7 @@ subprojects { subproj ->
337410
links 'https://www.dropwizard.io/1.3.5/dropwizard-core/apidocs/'
338411
}
339412

340-
if (JavaVersion.current().isJava9Compatible()) {
413+
if (JavaVersion.current().isJava11Compatible()) {
341414
options.addBooleanOption('html5', true)
342415
}
343416
}
@@ -347,7 +420,7 @@ subprojects { subproj ->
347420
"implSpec:a:Implementation Requirements:",
348421
"implNote:a:Implementation Note:"]
349422

350-
if (JavaVersion.current().isJava9Compatible()) {
423+
if (JavaVersion.current().isJava11Compatible()) {
351424
options.addBooleanOption('html5', true)
352425
}
353426
}
@@ -356,10 +429,6 @@ subprojects { subproj ->
356429
skipProject = JavaVersion.current().isJava10Compatible()
357430
}
358431

359-
test {
360-
useJUnitPlatform()
361-
}
362-
363432
afterReleaseBuild.dependsOn docs
364433
afterReleaseBuild.dependsOn publish
365434

components/agent/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description = 'Trellis Agent'
55

66
ext {
77
moduleName = 'org.trellisldp.agent'
8+
testModules = ['org.apache.commons.rdf.simple']
89
}
910

1011
dependencies {
@@ -15,4 +16,3 @@ dependencies {
1516
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
1617
testImplementation("org.apache.commons:commons-rdf-simple:$commonsRdfVersion")
1718
}
18-
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
module org.trellisldp.agent {
15+
exports org.trellisldp.agent;
16+
17+
requires transitive org.trellisldp.api;
18+
requires transitive org.trellisldp.vocabulary;
19+
20+
requires org.apache.commons.rdf.api;
21+
22+
provides org.trellisldp.api.AgentService
23+
with org.trellisldp.agent.SimpleAgentService;
24+
}

components/app-triplestore/build.gradle

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ ext {
66
moduleName = 'org.trellisldp.app.triplestore'
77
}
88

9+
configurations.all {
10+
exclude group: 'javax.el', module: 'javax.el-api'
11+
exclude group: 'com.google.code.findbugs', module: 'jsr305'
12+
}
13+
914
dependencies {
10-
compile("com.github.jsonld-java:jsonld-java:$jsonldVersion")
15+
compile("com.github.jsonld-java:jsonld-java:$jsonldVersion") {
16+
exclude group: 'org.apache.httpcomponents', module: 'httpclient-osgi'
17+
exclude group: 'org.apache.httpcomponents', module: 'httpcore-osgi'
18+
}
1119
compile("commons-codec:commons-codec:$commonsCodecVersion")
12-
compile("io.dropwizard:dropwizard-core:$dropwizardVersion")
13-
compile("io.dropwizard:dropwizard-metrics:$dropwizardVersion")
14-
compile("io.dropwizard:dropwizard-http2:$dropwizardVersion")
1520
compile("javax.activation:javax.activation-api:$activationApiVersion")
1621
compile("javax.jms:javax.jms-api:$jmsApiVersion")
1722
compile("org.apache.activemq:activemq-client:$activeMqVersion")
@@ -20,6 +25,10 @@ dependencies {
2025
compile("org.apache.jena:jena-tdb2:$jenaVersion")
2126
compile("org.apache.tamaya:tamaya-core:$tamayaVersion")
2227
compile("org.slf4j:slf4j-api:$slf4jVersion")
28+
compile("javax.jms:javax.jms-api:$jmsApiVersion")
29+
compile("javax.xml.bind:jaxb-api:$jaxbVersion")
30+
compile("javax.validation:validation-api:$validationVersion")
31+
compile("org.apache.commons:commons-rdf-api:$commonsRdfVersion")
2332
compile("org.apache.commons:commons-rdf-jena:$commonsRdfVersion") {
2433
exclude group: 'org.apache.jena', module: 'jena-osgi'
2534
exclude group: 'org.apache.servicemix.bundles', module: 'org.apache.servicemix.bundles.xerces'
@@ -29,6 +38,7 @@ dependencies {
2938
compile project(':trellis-io-jena')
3039
compile project(':trellis-api')
3140
compile project(':trellis-http')
41+
compile project(':trellis-app')
3242
compile project(':trellis-vocabulary')
3343
compile project(':trellis-file')
3444
compile project(':trellis-namespaces')
@@ -40,23 +50,29 @@ dependencies {
4050
compile project(':trellis-jms')
4151
compile project(':trellis-rdfa')
4252
compile project(':trellis-kafka')
43-
compile project(':trellis-app')
4453
compile project(':trellis-auth-oauth')
4554
compile project(':trellis-auth-basic')
4655

47-
runtime ("javax.xml.bind:jaxb-api:$jaxbVersion")
56+
compile("io.dropwizard:dropwizard-core:$dropwizardVersion")
57+
compile("io.dropwizard:dropwizard-metrics:$dropwizardVersion")
58+
compile("io.dropwizard:dropwizard-http2:$dropwizardVersion")
4859

49-
testCompile("io.dropwizard:dropwizard-client:$dropwizardVersion")
50-
testCompile("io.dropwizard:dropwizard-testing:$dropwizardVersion")
51-
testCompile("org.apache.activemq:activemq-broker:$activeMqVersion")
52-
testCompile("org.awaitility:awaitility:$awaitilityVersion")
60+
testCompile("org.awaitility:awaitility:$awaitilityVersion") {
61+
exclude group: "org.hamcrest", module: 'hamcrest-core'
62+
exclude group: 'org.hamcrest', module: 'hamcrest-library'
63+
}
64+
testCompile("org.hamcrest:hamcrest:$hamcrestVersion")
5365
testCompile("ch.qos.logback:logback-classic:$logbackVersion")
5466
testCompile("org.mockito:mockito-core:$mockitoVersion")
5567
testCompile project(':trellis-test')
68+
testCompile("io.dropwizard:dropwizard-client:$dropwizardVersion")
69+
testCompile("io.dropwizard:dropwizard-testing:$dropwizardVersion")
70+
testCompile("org.apache.activemq:activemq-broker:$activeMqVersion")
5671
}
5772

5873
jar {
5974
manifest {
6075
attributes('Automatic-Module-Name': moduleName)
6176
}
6277
}
78+

components/app-triplestore/src/test/java/org/trellisldp/app/triplestore/TrellisApplicationTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ private static DropwizardTestSupport<AppConfiguration> buildApplication() {
251251
config("notifications.type", "JMS"),
252252
config("notifications.connectionString", "vm://localhost"),
253253
config("auth.basic.usersFile", resourceFilePath("users.auth")),
254-
config("binaries", resourceFilePath("data") + "/binaries"),
255-
config("mementos", resourceFilePath("data") + "/mementos"),
256-
config("namespaces", resourceFilePath("data/namespaces.json")));
254+
config("binaries", resourceFilePath("app-data") + "/binaries"),
255+
config("mementos", resourceFilePath("app-data") + "/mementos"),
256+
config("namespaces", resourceFilePath("app-data/namespaces.json")));
257257
}
258258

259259
private Graph convertToGraph(final Message msg) {

0 commit comments

Comments
 (0)