Update Task to BOOT 2.1.M1

Migrating to use ApplicationContextRunner or ImportAutoConfiguration with SpringApp.run, instead of SpringApplicationBuilder, because builder does not handle AutoConfiguration properly

SimpleTaskAutoConfiguration now has an annotation AutoConfigureBefore the BatchTaskAutoConfig so that it is processed prior.  THis is so that that BatchTaskAutoConfig can create the appropriate beans

SimpleTaskAutoConfiguration has new annotations so that it is AutoConfigured after BindingServiceConfiguration and after SimpleTaskAutoConfiguration.  This is so that it does not attempt to start emitting messages before stream is ready and it can create the appropriate beans after SimpleTaskAutoConfiguration has run.

Renamed SimpleTaskConfiguration to SimpleTaskAutoConfiguration.

Task version updated to  2.1.0

Added missing headers

Updated documentation.

Deprecated EnableTask

Added ability to disable Task autoconfiguration.

Removed @EnableTask from tests

Resolves #439
Resolves #440
Resolves #448
Resolves #466
This commit is contained in:
Glenn Renfro
2018-08-09 17:54:56 -04:00
committed by Michael Minella
parent d2c90c5256
commit d2bc2530cc
70 changed files with 1381 additions and 801 deletions

View File

@@ -4,7 +4,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>batch-events</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Batch Events Sample Application</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -47,19 +47,19 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit-test-support</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support-internal</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -70,6 +70,7 @@
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -34,12 +34,10 @@ import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
@EnableTask
@EnableBatchProcessing
public class BatchEventsApplication {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,12 +50,14 @@ public class BatchEventsApplicationTests {
context.close();
}
}
@Test
public void testExecution() throws Exception {
SpringApplication.run(JobExecutionListenerBinding.class, "--spring.main.web-environment=false");
SpringApplication.run(BatchEventsApplication.class, "--server.port=0",
"--spring.cloud.stream.bindings.output.producer.requiredGroups=testgroup");
"--spring.cloud.stream.bindings.output.producer.requiredGroups=testgroup",
"--spring.jmx.default-domain=fakedomain",
"--spring.main.webEnvironment=false");
Assert.assertTrue("The latch did not count down to zero before timeout",
jobExecutionLatch.await(60, TimeUnit.SECONDS));
}

View File

@@ -5,7 +5,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>batch-job</artifactId>
<packaging>jar</packaging>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<description>Spring Cloud Task Batch Example</description>
<name>Batch Job Sample Application</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -53,6 +53,10 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
</dependencies>
<repositories>

View File

@@ -3,10 +3,8 @@ package io.spring;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
@SpringBootApplication
@EnableTask
@EnableBatchProcessing
public class BatchJobApplication {

View File

@@ -19,7 +19,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>jpa-sample</artifactId>
<packaging>jar</packaging>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<description>To show users how to enable a task with a JPA application.</description>
<name>Spring Cloud Task JPA Sample Application</name>
@@ -27,7 +27,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -41,7 +41,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -18,10 +18,8 @@ package io.spring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
@SpringBootApplication
@EnableTask
public class JpaApplication {
public static void main(String[] args) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2017-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -101,7 +101,7 @@ public class JpaApplicationTests {
assertTrue("Unable to find the insert message: " + output, output.contains(INSERT_MESSAGE));
JdbcTemplate template = new JdbcTemplate(this.dataSource);
Map<String, Object> result = template.queryForMap("Select * from TASK_RUN_OUTPUT");
assertThat((result.get("ID")), is(1L));
assertThat((Long)(result.get("ID")), is(1L));
assertThat(((String) result.get("OUTPUT")), containsString("Executed at"));
}

View File

@@ -5,7 +5,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>multiple-datasources</artifactId>
<packaging>jar</packaging>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<description>To show users how to enable a task with a multiple DataSources.</description>
<name>Spring Cloud Task Multiple DataSources Application</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -18,14 +18,12 @@ package io.spring;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
/**
* @author Michael Minella
*/
@SpringBootApplication
@EnableTask
public class MultipleDataSourcesApplication {
public static void main(String[] args) {

View File

@@ -6,13 +6,13 @@
<artifactId>partitioned-batch-job</artifactId>
<packaging>jar</packaging>
<name>Partitioned Batch Job</name>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<description>Sample of using the DeployerPartitionHandler</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -26,7 +26,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2016 the original author or authors.
* Copyright 2016-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -81,15 +81,6 @@ public class JobConfiguration {
private static final int GRID_SIZE = 4;
@Bean
public JobExplorerFactoryBean jobExplorer() {
JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
jobExplorerFactoryBean.setDataSource(this.dataSource);
return jobExplorerFactoryBean;
}
@Bean
public PartitionHandler partitionHandler(TaskLauncher taskLauncher, JobExplorer jobExplorer) throws Exception {
Resource resource = resourceLoader.getResource("maven://io.spring.cloud:partitioned-batch-job:1.1.0.RELEASE");

View File

@@ -3,11 +3,9 @@ package io.spring;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
@SpringBootApplication
@EnableBatchProcessing
@EnableTask
public class PartitionedBatchJobApplication {
public static void main(String[] args) {

View File

@@ -11,7 +11,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-parent</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
</parent>
<properties>
@@ -36,7 +36,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>

View File

@@ -4,7 +4,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>task-events</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Task Events</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -43,10 +43,9 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>

View File

@@ -18,12 +18,10 @@ package io.spring;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@SpringBootApplication
@EnableTask
public class TaskEventsApplication {
public static void main(String[] args) {

View File

@@ -4,7 +4,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>taskprocessor</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Task Processor Sample Application</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -42,7 +42,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
@@ -52,7 +52,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -4,7 +4,7 @@
<groupId>io.spring.cloud</groupId>
<artifactId>tasksink</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Task Sink Sample Application</name>
@@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-stream-rabbit</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-test-support</artifactId>
<version>2.0.0.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -7,13 +7,13 @@
<artifactId>timestamp-task</artifactId>
<packaging>jar</packaging>
<name>Timestamp Task</name>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<description>Spring Cloud Timestamp Task</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.1.RELEASE</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<relativePath />
</parent>
@@ -27,7 +27,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-task-dependencies</artifactId>
<version>2.0.1.BUILD-SNAPSHOT</version>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@@ -57,6 +57,10 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
</dependency>
</dependencies>
<pluginRepositories>

View File

@@ -29,14 +29,12 @@ import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.task.configuration.EnableTask;
import org.springframework.context.annotation.Bean;
/**
* Spring Boot Application that has tasks enabled.
*/
@SpringBootApplication
@EnableTask
@EnableConfigurationProperties({ TimestampTaskProperties.class })
public class TaskApplication {