Skip to content

Commit

Permalink
Implement Java modularity
Browse files Browse the repository at this point in the history
Resolves #66
  • Loading branch information
acoburn committed Jan 23, 2019
1 parent a570db2 commit 726c063
Show file tree
Hide file tree
Showing 48 changed files with 822 additions and 59 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
- env: JOB=sonatype
- env: JOB=docker
- env: JOB=aws
- env: JOB=jpms

include:
# JDK 8
Expand All @@ -57,6 +58,13 @@ jobs:
jdk: openjdk11
script: travis_retry ./gradlew check install

# JDK 11 (modules)
- name: "Java 11 (modules)"
stage: test
jdk: openjdk11
env: JOB=jpms
script: ./gradlew clean check install --continue -Pjpms

# deploy JDK 8 builds to Sonatype
- name: "Publish to Sonatype"
stage: deploy
Expand Down
3 changes: 2 additions & 1 deletion auth/basic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description = 'Trellis Basic authentication filter'

ext {
moduleName = 'org.trellisldp.auth.basic'
testModules = ['tamaya.core']
}

dependencies {
Expand All @@ -14,8 +15,8 @@ dependencies {

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

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

testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
Expand Down
25 changes: 25 additions & 0 deletions auth/basic/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module org.trellisldp.auth.basic {
exports org.trellisldp.auth.basic;

requires slf4j.api;
requires tamaya.api;
requires javax.inject;
requires java.ws.rs;
requires java.xml.bind;
requires java.annotation;

uses org.apache.tamaya.spi.ConfigurationProviderSpi;
}
10 changes: 5 additions & 5 deletions auth/oauth/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ ext {
}

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

implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
implementation("commons-io:commons-io:$commonsIoVersion")
implementation("io.jsonwebtoken:jjwt-impl:$jjwtVersion")
implementation("io.jsonwebtoken:jjwt-jackson:$jjwtVersion")
implementation("org.apache.tamaya:tamaya-api:$tamayaVersion")
implementation("org.slf4j:slf4j-api:$slf4jVersion")
implementation("javax.xml.bind:jaxb-api:$jaxbVersion")
implementation("io.jsonwebtoken:jjwt-jackson:$jjwtVersion")
implementation("io.jsonwebtoken:jjwt-api:$jjwtVersion")
implementation("io.jsonwebtoken:jjwt-impl:$jjwtVersion")

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

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

85 changes: 77 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ext {
commonsRdfVersion = '0.5.0'
javaxAnnotationsVersion = '1.3.2'
javaxInjectVersion = '2.5.0-b62'
javaxJmsVersion = '2.0.1'
javaxManagementVersion = '1.1.2'
jaxrsVersion = '2.1.1'
metricsVersion = '4.0.5'
slf4jVersion = '1.7.25'
Expand All @@ -43,6 +45,7 @@ ext {
kafkaVersion = '2.0.0'
mustacheVersion = '0.9.5'
rabbitMqVersion = '5.5.2'
validationVersion = '2.0.1.Final'

/* Testing */
apiguardianVersion = '1.0.0'
Expand All @@ -51,6 +54,7 @@ ext {
commonsTextVersion = '1.6'
junitVersion = '5.3.2'
junitLauncherVersion = '1.3.2'
hamcrestVersion = '2.1'
logbackVersion = '1.2.3'
mockitoVersion = '2.23.4'
qpidVersion = '7.1.0'
Expand Down Expand Up @@ -149,8 +153,11 @@ allprojects { subproj ->
}

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

subprojects { subproj ->

sourceCompatibility = 1.8
targetCompatibility = 1.8
def jpms = JavaVersion.current().isJava11Compatible() && subproj.hasProperty("jpms") &&
sourceSets.main.allJava.getFiles().stream().map { file -> file.getName() }
.anyMatch { file -> file == "module-info.java"}

sourceCompatibility = jpms ? 11 : 8
targetCompatibility = jpms ? 11 : 8

afterEvaluate {
if (jpms) {
compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}
compileTestJava {
inputs.property("moduleName", moduleName)
def mods = subproj.ext.has("testModules") ? subproj.ext.get("testModules") : []
mods.add('org.junit.jupiter.api')
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', mods.join(','),
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
]
mods.forEach { mod -> options.compilerArgs += [ '--add-reads', "$moduleName=$mod"] }
classpath = files()
}
}
test {
inputs.property("moduleName", moduleName)
def mods = subproj.ext.has("testModules") ? subproj.ext.get("testModules") : []
mods.add('org.junit.jupiter.api')
doFirst {
jvmArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'ALL-MODULE-PATH',
'--add-opens', "$moduleName/$moduleName=org.junit.platform.commons",
'--add-opens', "$moduleName/$moduleName=org.mockito",
'--patch-module', "$moduleName=" + files(sourceSets.main.output.resourcesDir, sourceSets.test.output).asPath,
]
mods.forEach { mod -> jvmArgs += [ '--add-reads', "$moduleName=$mod"] }
classpath = files()
}
}

javadoc {
options.addStringOption('-module-path', classpath.asPath)
}
}
}

sourceSets {
main {
java {
if (!jpms) {
exclude '**/module-info.java'
}
}
}
}

jar {
from("$rootDir/LICENSE") {
into "META-INF"
}
}

test {
useJUnitPlatform()
}

checkstyle {
configFile = rootProject.file('buildtools/src/main/resources/checkstyle/checkstyle.xml')
configProperties.checkstyleConfigDir = rootProject.file('buildtools/src/main/resources/checkstyle/')
Expand Down Expand Up @@ -337,7 +410,7 @@ subprojects { subproj ->
links 'https://www.dropwizard.io/1.3.5/dropwizard-core/apidocs/'
}

if (JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava11Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand All @@ -347,7 +420,7 @@ subprojects { subproj ->
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"]

if (JavaVersion.current().isJava9Compatible()) {
if (JavaVersion.current().isJava11Compatible()) {
options.addBooleanOption('html5', true)
}
}
Expand All @@ -356,10 +429,6 @@ subprojects { subproj ->
skipProject = JavaVersion.current().isJava10Compatible()
}

test {
useJUnitPlatform()
}

afterReleaseBuild.dependsOn docs
afterReleaseBuild.dependsOn publish

Expand Down
2 changes: 1 addition & 1 deletion components/agent/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ description = 'Trellis Agent'

ext {
moduleName = 'org.trellisldp.agent'
testModules = ['org.apache.commons.rdf.simple']
}

dependencies {
Expand All @@ -15,4 +16,3 @@ dependencies {
testImplementation("ch.qos.logback:logback-classic:$logbackVersion")
testImplementation("org.apache.commons:commons-rdf-simple:$commonsRdfVersion")
}

24 changes: 24 additions & 0 deletions components/agent/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module org.trellisldp.agent {
exports org.trellisldp.agent;

requires transitive org.trellisldp.api;
requires transitive org.trellisldp.vocabulary;

requires org.apache.commons.rdf.api;

provides org.trellisldp.api.AgentService
with org.trellisldp.agent.SimpleAgentService;
}
36 changes: 26 additions & 10 deletions components/app-triplestore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ ext {
moduleName = 'org.trellisldp.app.triplestore'
}

configurations.all {
exclude group: 'javax.el', module: 'javax.el-api'
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}

dependencies {
compile("com.github.jsonld-java:jsonld-java:$jsonldVersion")
compile("com.github.jsonld-java:jsonld-java:$jsonldVersion") {
exclude group: 'org.apache.httpcomponents', module: 'httpclient-osgi'
exclude group: 'org.apache.httpcomponents', module: 'httpcore-osgi'
}
compile("commons-codec:commons-codec:$commonsCodecVersion")
compile("io.dropwizard:dropwizard-core:$dropwizardVersion")
compile("io.dropwizard:dropwizard-metrics:$dropwizardVersion")
compile("io.dropwizard:dropwizard-http2:$dropwizardVersion")
compile("javax.activation:javax.activation-api:$activationApiVersion")
compile("javax.jms:javax.jms-api:$jmsApiVersion")
compile("org.apache.activemq:activemq-client:$activeMqVersion")
Expand All @@ -20,6 +25,10 @@ dependencies {
compile("org.apache.jena:jena-tdb2:$jenaVersion")
compile("org.apache.tamaya:tamaya-core:$tamayaVersion")
compile("org.slf4j:slf4j-api:$slf4jVersion")
compile("javax.jms:javax.jms-api:$jmsApiVersion")
compile("javax.xml.bind:jaxb-api:$jaxbVersion")
compile("javax.validation:validation-api:$validationVersion")
compile("org.apache.commons:commons-rdf-api:$commonsRdfVersion")
compile("org.apache.commons:commons-rdf-jena:$commonsRdfVersion") {
exclude group: 'org.apache.jena', module: 'jena-osgi'
exclude group: 'org.apache.servicemix.bundles', module: 'org.apache.servicemix.bundles.xerces'
Expand All @@ -29,6 +38,7 @@ dependencies {
compile project(':trellis-io-jena')
compile project(':trellis-api')
compile project(':trellis-http')
compile project(':trellis-app')
compile project(':trellis-vocabulary')
compile project(':trellis-file')
compile project(':trellis-namespaces')
Expand All @@ -40,23 +50,29 @@ dependencies {
compile project(':trellis-jms')
compile project(':trellis-rdfa')
compile project(':trellis-kafka')
compile project(':trellis-app')
compile project(':trellis-auth-oauth')
compile project(':trellis-auth-basic')

runtime ("javax.xml.bind:jaxb-api:$jaxbVersion")
compile("io.dropwizard:dropwizard-core:$dropwizardVersion")
compile("io.dropwizard:dropwizard-metrics:$dropwizardVersion")
compile("io.dropwizard:dropwizard-http2:$dropwizardVersion")

testCompile("io.dropwizard:dropwizard-client:$dropwizardVersion")
testCompile("io.dropwizard:dropwizard-testing:$dropwizardVersion")
testCompile("org.apache.activemq:activemq-broker:$activeMqVersion")
testCompile("org.awaitility:awaitility:$awaitilityVersion")
testCompile("org.awaitility:awaitility:$awaitilityVersion") {
exclude group: "org.hamcrest", module: 'hamcrest-core'
exclude group: 'org.hamcrest', module: 'hamcrest-library'
}
testCompile("org.hamcrest:hamcrest:$hamcrestVersion")
testCompile("ch.qos.logback:logback-classic:$logbackVersion")
testCompile("org.mockito:mockito-core:$mockitoVersion")
testCompile project(':trellis-test')
testCompile("io.dropwizard:dropwizard-client:$dropwizardVersion")
testCompile("io.dropwizard:dropwizard-testing:$dropwizardVersion")
testCompile("org.apache.activemq:activemq-broker:$activeMqVersion")
}

jar {
manifest {
attributes('Automatic-Module-Name': moduleName)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ private static DropwizardTestSupport<AppConfiguration> buildApplication() {
config("notifications.type", "JMS"),
config("notifications.connectionString", "vm://localhost"),
config("auth.basic.usersFile", resourceFilePath("users.auth")),
config("binaries", resourceFilePath("data") + "/binaries"),
config("mementos", resourceFilePath("data") + "/mementos"),
config("namespaces", resourceFilePath("data/namespaces.json")));
config("binaries", resourceFilePath("app-data") + "/binaries"),
config("mementos", resourceFilePath("app-data") + "/mementos"),
config("namespaces", resourceFilePath("app-data/namespaces.json")));
}

private Graph convertToGraph(final Message msg) {
Expand Down
Loading

0 comments on commit 726c063

Please sign in to comment.