Skip to content

Add support to build/run on Java 9 #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ allprojects {
gsonVersion = '2.8.5'
javaMailVersion = '1.6.0'
javaxBatchApiVersion = '1.0'
javaxAnnotationApiVersion = '1.3.2'
javaxInjectVersion = '1'
javaxTransactionVersion = '1.2'
jbatchTckSpi = '1.0'
Expand Down Expand Up @@ -113,7 +114,7 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
apply plugin: 'merge'

jacoco {
toolVersion = "0.7.6.201602180812"
toolVersion = "0.8.2"
}

compileJava {
Expand Down Expand Up @@ -169,6 +170,10 @@ configure(subprojects - project(":spring-build-src")) { subproject ->
// testLogging {
// showStandardStreams = true
// }

if (JavaVersion.current().isJava9Compatible()) {
jvmArgs '--add-modules', 'java.xml.bind'
}
}

task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -288,6 +293,7 @@ project('spring-batch-core') {
optional "org.springframework:spring-jdbc:$springVersion"
optional "org.apache.logging.log4j:log4j-api:$log4jVersion"
optional "org.apache.logging.log4j:log4j-core:$log4jVersion"
optional "javax.annotation:javax.annotation-api:$javaxAnnotationApiVersion"
// JSR-305 only used for non-required meta-annotations
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
testCompileOnly("com.google.code.findbugs:jsr305:3.0.2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,13 @@ private final class ResourceXmlApplicationContext extends GenericXmlApplicationC
* @param parent
*/
public ResourceXmlApplicationContext(ConfigurableApplicationContext parent, Object... resources) {
helper = new ApplicationContextHelper(parent, this, resources) {

class ResourceXmlApplicationContextHelper extends ApplicationContextHelper {

ResourceXmlApplicationContextHelper(ConfigurableApplicationContext parent, GenericApplicationContext context, Object... config) {
super(parent, context, config);
}

@Override
protected String generateId(Object... configs) {
Resource[] resources = Arrays.copyOfRange(configs, 0, configs.length, Resource[].class);
Expand All @@ -155,9 +161,10 @@ protected String generateId(Object... configs) {
@Override
protected void loadConfiguration(Object... configs) {
Resource[] resources = Arrays.copyOfRange(configs, 0, configs.length, Resource[].class);
load(resources);
load(resources);
}
};
}
helper = new ResourceXmlApplicationContextHelper(parent, this, resources);
refresh();
}

Expand All @@ -179,7 +186,13 @@ private final class ResourceAnnotationApplicationContext extends AnnotationConfi
private final ApplicationContextHelper helper;

public ResourceAnnotationApplicationContext(ConfigurableApplicationContext parent, Object... resources) {
helper = new ApplicationContextHelper(parent, this, resources) {

class ResourceAnnotationApplicationContextHelper extends ApplicationContextHelper {

public ResourceAnnotationApplicationContextHelper(ConfigurableApplicationContext parent, GenericApplicationContext context, Object... config) {
super(parent, context, config);
}

@Override
protected String generateId(Object... configs) {
if (allObjectsOfType(configs, Class.class)) {
Expand All @@ -205,7 +218,8 @@ protected void loadConfiguration(Object... configs) {
scan(pkgs);
}
}
};
}
helper = new ResourceAnnotationApplicationContextHelper(parent, this, resources);
refresh();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ public void testSpringArtifactUniqueness() throws Exception {
}

private Document getDocument(String location) {
InputStream inputStream = ClassLoader.class.getResourceAsStream(location);
InputStream inputStream = this.getClass().getResourceAsStream(location);

try {
return documentLoader.loadDocument(new InputSource(inputStream),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ public void testGetAllJobParameters() throws Exception {
StepExecution stepExecution = getStepExecution("foo=bar,spam=bucket");
extractor.setKeys(new String[] {"foo", "bar"});
JobParameters jobParameters = extractor.getJobParameters(null, stepExecution);
assertEquals("{spam=bucket, foo=bar}", jobParameters.toString());
assertEquals("bar", jobParameters.getString("foo"));
assertEquals("bucket", jobParameters.getString("spam"));
}

@Test
Expand Down