Jdk 11 releaser

This commit is contained in:
Marcin Grzejszczak
2023-07-04 12:55:42 +02:00
parent b993d63f46
commit b26f0199bc
15 changed files with 133 additions and 122 deletions

View File

@@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
</parent>
<artifactId>releaser-docs</artifactId>
<packaging>pom</packaging>

View File

@@ -6,13 +6,13 @@
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.0.3</version>
<version>3.1.8</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
@@ -28,9 +28,9 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>11</java.version>
<spring-cloud-bom.version>2022.0.3</spring-cloud-bom.version>
<spring-cloud-bom.version>2021.0.8</spring-cloud-bom.version>
<github-api.version>1.315</github-api.version>
<jsch-agent.version>0.0.9</jsch-agent.version>
<!--Matches JGit in Boot:-->

View File

@@ -5,13 +5,13 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>releaser-projects</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

View File

@@ -10,13 +10,13 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-projects</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>11</java.version>
</properties>
<dependencies>

View File

@@ -138,30 +138,30 @@ class SpringCloudStreamMavenBomParser implements CustomBomParser {
public Set<Project> setVersion(Set<Project> projects, String projectName, String version) {
Set<Project> newProjects = new LinkedHashSet<>(projects);
switch (projectName) {
case SPRING_BOOT:
case BOOT_STARTER_ARTIFACT_ID:
case BOOT_STARTER_PARENT_ARTIFACT_ID:
case BOOT_DEPENDENCIES_ARTIFACT_ID:
updateBootVersions(newProjects, version);
break;
case BUILD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
updateBuildVersions(newProjects, version);
break;
case CLOUD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
case CLOUD_RELEASE_ARTIFACT_ID:
case CLOUD_STARTER_ARTIFACT_ID:
case CLOUD_STARTER_PARENT_ARTIFACT_ID:
updateSpringCloudVersions(newProjects, version);
break;
case STREAM_DEPS_ARTIFACT_ID:
case STREAM_STARTER_ARTIFACT_ID:
case STREAM_STARTER_BUILD_ARTIFACT_ID:
case STREAM_STARTER_PARENT_ARTIFACT_ID:
case STREAM_DOCS_ARTIFACT_ID:
updateStreamVersions(newProjects, version);
break;
case SPRING_BOOT:
case BOOT_STARTER_ARTIFACT_ID:
case BOOT_STARTER_PARENT_ARTIFACT_ID:
case BOOT_DEPENDENCIES_ARTIFACT_ID:
updateBootVersions(newProjects, version);
break;
case BUILD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
updateBuildVersions(newProjects, version);
break;
case CLOUD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
case CLOUD_RELEASE_ARTIFACT_ID:
case CLOUD_STARTER_ARTIFACT_ID:
case CLOUD_STARTER_PARENT_ARTIFACT_ID:
updateSpringCloudVersions(newProjects, version);
break;
case STREAM_DEPS_ARTIFACT_ID:
case STREAM_STARTER_ARTIFACT_ID:
case STREAM_STARTER_BUILD_ARTIFACT_ID:
case STREAM_STARTER_PARENT_ARTIFACT_ID:
case STREAM_DOCS_ARTIFACT_ID:
updateStreamVersions(newProjects, version);
break;
}
return newProjects;
}

View File

@@ -10,13 +10,13 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-projects</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>11</java.version>
</properties>
<dependencies>

View File

@@ -139,31 +139,31 @@ class SpringCloudMavenBomParser implements CustomBomParser {
public Set<Project> setVersion(Set<Project> projects, String projectName, String version) {
Set<Project> newProjects = new LinkedHashSet<>(projects);
switch (projectName) {
case SPRING_BOOT:
case BOOT_STARTER_ARTIFACT_ID:
case BOOT_STARTER_PARENT_ARTIFACT_ID:
case BOOT_DEPENDENCIES_ARTIFACT_ID:
updateBootVersions(newProjects, version);
break;
case BUILD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
updateBuildVersions(newProjects, version);
break;
case CLOUD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
case CLOUD_RELEASE_ARTIFACT_ID:
case CLOUD_STARTER_ARTIFACT_ID:
case CLOUD_STARTER_PARENT_ARTIFACT_ID:
case CLOUD_STARTER_BUILD_ARTIFACT_ID:
updateSpringCloudVersions(newProjects, version);
break;
case STREAM_DEPS_ARTIFACT_ID:
case STREAM_STARTER_ARTIFACT_ID:
case STREAM_STARTER_BUILD_ARTIFACT_ID:
case STREAM_STARTER_PARENT_ARTIFACT_ID:
case STREAM_DOCS_ARTIFACT_ID:
updateStreamVersions(newProjects, version);
break;
case SPRING_BOOT:
case BOOT_STARTER_ARTIFACT_ID:
case BOOT_STARTER_PARENT_ARTIFACT_ID:
case BOOT_DEPENDENCIES_ARTIFACT_ID:
updateBootVersions(newProjects, version);
break;
case BUILD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_PARENT_ARTIFACT_ID:
updateBuildVersions(newProjects, version);
break;
case CLOUD_ARTIFACT_ID:
case CLOUD_DEPENDENCIES_ARTIFACT_ID:
case CLOUD_RELEASE_ARTIFACT_ID:
case CLOUD_STARTER_ARTIFACT_ID:
case CLOUD_STARTER_PARENT_ARTIFACT_ID:
case CLOUD_STARTER_BUILD_ARTIFACT_ID:
updateSpringCloudVersions(newProjects, version);
break;
case STREAM_DEPS_ARTIFACT_ID:
case STREAM_STARTER_ARTIFACT_ID:
case STREAM_STARTER_BUILD_ARTIFACT_ID:
case STREAM_STARTER_PARENT_ARTIFACT_ID:
case STREAM_DOCS_ARTIFACT_ID:
updateStreamVersions(newProjects, version);
break;
}
return newProjects;
}

View File

@@ -10,7 +10,7 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>

View File

@@ -27,7 +27,8 @@ import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import jakarta.validation.constraints.NotBlank;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang.SerializationUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;

View File

@@ -10,13 +10,13 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>11</java.version>
</properties>
<dependencies>

View File

@@ -16,15 +16,24 @@
package releaser.internal.spring;
import javax.sql.DataSource;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import releaser.internal.ReleaserProperties;
import org.springframework.batch.core.configuration.annotation.BatchConfigurer;
import org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.explore.support.JobExplorerFactoryBean;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.repository.dao.Jackson2ExecutionContextStringSerializer;
import org.springframework.batch.core.repository.support.JobRepositoryFactoryBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -34,6 +43,7 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;
@Configuration
@EnableBatchProcessing
class BatchConfiguration {
@Bean
@@ -66,11 +76,11 @@ class BatchConfiguration {
@Bean
@ConditionalOnMissingBean
FlowRunner flowRunner(JobRepository jobRepository, PlatformTransactionManager manager,
FlowRunner flowRunner(StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory,
ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier, ConfigurableApplicationContext context,
ReleaserProperties releaserProperties, BuildReportHandler reportHandler) {
return new SpringBatchFlowRunner(jobRepository, manager, projectsToRunFactory, jobLauncher,
return new SpringBatchFlowRunner(stepBuilderFactory, jobBuilderFactory, projectsToRunFactory, jobLauncher,
flowRunnerTaskExecutorSupplier, context, releaserProperties, reportHandler);
}
@@ -85,28 +95,32 @@ class BatchConfiguration {
serializer.setObjectMapper(objectMapper);
return serializer;
}
/*
* // Needed to add this to serialize the exceptions
*
* @Bean BatchConfigurer myBatchConfigurer(DataSource dataSource,
* Jackson2ExecutionContextStringSerializer
* myJackson2ExecutionContextStringSerializer, PlatformTransactionManager
* transactionManager) { return new DefaultBatchConfigurer(dataSource) {
*
* @Override protected JobExplorer createJobExplorer() throws Exception {
* JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
* jobExplorerFactoryBean.setDataSource(dataSource);
* jobExplorerFactoryBean.setSerializer(myJackson2ExecutionContextStringSerializer);
* jobExplorerFactoryBean.afterPropertiesSet(); return
* jobExplorerFactoryBean.getObject(); }
*
* @Override protected JobRepository createJobRepository() throws Exception {
* JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
* jobRepositoryFactoryBean.setDataSource(dataSource);
* jobRepositoryFactoryBean.setSerializer(myJackson2ExecutionContextStringSerializer);
* jobRepositoryFactoryBean.setTransactionManager(transactionManager);
* jobRepositoryFactoryBean.afterPropertiesSet(); return
* jobRepositoryFactoryBean.getObject(); } }; }
*/
// Needed to add this to serialize the exceptions
@Bean
BatchConfigurer myBatchConfigurer(DataSource dataSource,
Jackson2ExecutionContextStringSerializer myJackson2ExecutionContextStringSerializer,
PlatformTransactionManager transactionManager) {
return new DefaultBatchConfigurer(dataSource) {
@Override
protected JobExplorer createJobExplorer() throws Exception {
JobExplorerFactoryBean jobExplorerFactoryBean = new JobExplorerFactoryBean();
jobExplorerFactoryBean.setDataSource(dataSource);
jobExplorerFactoryBean.setSerializer(myJackson2ExecutionContextStringSerializer);
jobExplorerFactoryBean.afterPropertiesSet();
return jobExplorerFactoryBean.getObject();
}
@Override
protected JobRepository createJobRepository() throws Exception {
JobRepositoryFactoryBean jobRepositoryFactoryBean = new JobRepositoryFactoryBean();
jobRepositoryFactoryBean.setDataSource(dataSource);
jobRepositoryFactoryBean.setSerializer(myJackson2ExecutionContextStringSerializer);
jobRepositoryFactoryBean.setTransactionManager(transactionManager);
jobRepositoryFactoryBean.afterPropertiesSet();
return jobRepositoryFactoryBean.getObject();
}
};
}
}

View File

@@ -16,8 +16,7 @@
package releaser.internal.spring;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatterBuilder;
import java.text.SimpleDateFormat;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Comparator;
@@ -62,10 +61,8 @@ class SpringBatchBuildReportHandler implements BuildReportHandler {
private List<Table> buildTable(List<StepExecution> stepContexts) {
return stepContexts.stream().map(step -> {
String date = step.getStartTime()
.format(new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd HH:mm:ss.SSS").toFormatter());
long millis = ChronoUnit.MILLIS.between(step.getStartTime().toInstant(ZoneOffset.UTC),
step.getEndTime().toInstant(ZoneOffset.UTC));
String date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(step.getStartTime());
long millis = ChronoUnit.MILLIS.between(step.getStartTime().toInstant(), step.getEndTime().toInstant());
ExecutionContext context = step.getExecutionContext();
ExecutionResultReport entity = (ExecutionResultReport) context.get("entity");
if (entity == null) {

View File

@@ -50,6 +50,8 @@ import org.springframework.batch.core.Step;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.batch.core.UnexpectedJobExecutionException;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.job.builder.FlowBuilder;
import org.springframework.batch.core.job.builder.FlowJobBuilder;
import org.springframework.batch.core.job.builder.JobBuilder;
@@ -57,14 +59,11 @@ import org.springframework.batch.core.job.builder.JobFlowBuilder;
import org.springframework.batch.core.job.flow.Flow;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.listener.StepExecutionListenerSupport;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.batch.core.step.builder.StepBuilder;
import org.springframework.batch.repeat.RepeatStatus;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.task.TaskExecutor;
import org.springframework.transaction.PlatformTransactionManager;
class SpringBatchFlowRunner implements FlowRunner, Closeable {
@@ -74,9 +73,9 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
private final ConsoleInputStepSkipper stepSkipper;
private final JobRepository jobRepository;
private final StepBuilderFactory stepBuilderFactory;
private final PlatformTransactionManager manager;
private final JobBuilderFactory jobBuilderFactory;
private final ProjectsToRunFactory projectsToRunFactory;
@@ -90,12 +89,12 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
private final ReleaserProperties releaserProperties;
SpringBatchFlowRunner(JobRepository jobRepository, PlatformTransactionManager manager,
SpringBatchFlowRunner(StepBuilderFactory stepBuilderFactory, JobBuilderFactory jobBuilderFactory,
ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier, ConfigurableApplicationContext context,
ReleaserProperties releaserProperties, BuildReportHandler reportHandler) {
this.jobRepository = jobRepository;
this.manager = manager;
this.stepBuilderFactory = stepBuilderFactory;
this.jobBuilderFactory = jobBuilderFactory;
this.projectsToRunFactory = projectsToRunFactory;
this.jobLauncher = jobLauncher;
this.flowRunnerTaskExecutorSupplier = flowRunnerTaskExecutorSupplier;
@@ -111,7 +110,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
}
private Step createStep(ReleaserTask releaserTask, NamedArgumentsSupplier argsSupplier) {
return new StepBuilder(argsSupplier.projectName + "_" + releaserTask.name(), jobRepository)
return this.stepBuilderFactory.get(argsSupplier.projectName + "_" + releaserTask.name())
.tasklet((contribution, chunkContext) -> {
Arguments args = argsSupplier.get();
FlowRunner.Decision decision = beforeTask(args.options, args.properties, releaserTask);
@@ -139,7 +138,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
log.info("Skipping step [{}]", releaserTask.name());
}
return RepeatStatus.FINISHED;
}, this.manager).listener(releaserListener(argsSupplier, releaserTask)).build();
}).listener(releaserListener(argsSupplier, releaserTask)).build();
}
private List<Throwable> addExceptionToErrors(List<Throwable> errors, RuntimeException exception) {
@@ -305,7 +304,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
}
private Job buildJobForFlows(Iterator<StuffToRun> flowsIterator) {
JobBuilder release = new JobBuilder("release_" + System.currentTimeMillis(), this.jobRepository);
JobBuilder release = this.jobBuilderFactory.get("release_" + System.currentTimeMillis());
StuffToRun stuffToRun = flowsIterator.next();
Flow first = stuffToRun.flow;
JobFlowBuilder start = release.start(first);
@@ -363,7 +362,7 @@ class SpringBatchFlowRunner implements FlowRunner, Closeable {
log.info("No release train post release tasks to run, will do nothing");
return ExecutionResult.success();
}
Job job = new JobBuilder(name, this.jobRepository).start(flow).build().build();
Job job = this.jobBuilderFactory.get(name).start(flow).build().build();
return runJob(job);
}
@@ -512,14 +511,14 @@ class ConsoleInputStepSkipper {
public boolean skipStep() {
String input = chosenOption();
switch (input.toLowerCase()) {
case "s":
return true;
case "q":
reportHandler.reportBuildSummary();
System.exit(SpringApplication.exit(this.context, () -> 0));
return true;
default:
return false;
case "s":
return true;
case "q":
reportHandler.reportBuildSummary();
System.exit(SpringApplication.exit(this.context, () -> 0));
return true;
default:
return false;
}
}

View File

@@ -10,13 +10,13 @@
<parent>
<groupId>org.springframework.cloud.internal</groupId>
<artifactId>releaser-parent</artifactId>
<version>3.0.0-SNAPSHOT</version>
<version>2.0.0-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>11</java.version>
</properties>
<dependencies>

View File

@@ -50,14 +50,14 @@ import releaser.internal.sagan.Project;
import releaser.internal.sagan.Release;
import releaser.internal.tasks.ReleaserTask;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.util.FileSystemUtils;
import static org.assertj.core.api.BDDAssertions.then;
@@ -320,11 +320,11 @@ public abstract class AbstractSpringAcceptanceTests {
public static class DefaultTestConfiguration {
@Bean
SpringBatchFlowRunner mySpringBatchFlowRunner(JobRepository jobRepository, PlatformTransactionManager manager,
ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
SpringBatchFlowRunner mySpringBatchFlowRunner(StepBuilderFactory stepBuilderFactory,
JobBuilderFactory jobBuilderFactory, ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier, ConfigurableApplicationContext context,
ReleaserProperties releaserProperties, BuildReportHandler reportHandler) {
return new SpringBatchFlowRunner(jobRepository, manager, projectsToRunFactory, jobLauncher,
return new SpringBatchFlowRunner(stepBuilderFactory, jobBuilderFactory, projectsToRunFactory, jobLauncher,
flowRunnerTaskExecutorSupplier, context, releaserProperties, reportHandler) {
@Override
Decision decide(Options options, ReleaserTask task) {