#35 - Added command to trigger builds.
This commit is contained in:
@@ -21,12 +21,19 @@ import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.release.CliComponent;
|
||||
import org.springframework.data.release.TimedCommand;
|
||||
import org.springframework.data.release.git.GitOperations;
|
||||
import org.springframework.data.release.io.Workspace;
|
||||
import org.springframework.data.release.model.Project;
|
||||
import org.springframework.data.release.model.Projects;
|
||||
import org.springframework.data.release.model.TrainIteration;
|
||||
import org.springframework.data.release.utils.Logger;
|
||||
import org.springframework.shell.core.annotation.CliCommand;
|
||||
import org.springframework.shell.core.annotation.CliOption;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
@@ -38,6 +45,7 @@ class BuildCommands extends TimedCommand {
|
||||
|
||||
@NonNull BuildOperations build;
|
||||
@NonNull Workspace workspace;
|
||||
@NonNull GitOperations git;
|
||||
@NonNull Logger logger;
|
||||
|
||||
/**
|
||||
@@ -54,4 +62,25 @@ class BuildCommands extends TimedCommand {
|
||||
workspace.purge(build.getLocalRepository(),
|
||||
path -> build.getLocalRepository().relativize(path).startsWith("org/springframework/data"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a build for all modules of the given {@link TrainIteration}.
|
||||
*
|
||||
* @param iteration must not be {@literal null}.
|
||||
* @param projectKey can be {@literal null} or empty.
|
||||
*/
|
||||
@CliCommand("build")
|
||||
public void build(@CliOption(key = "", mandatory = true) TrainIteration iteration, //
|
||||
@CliOption(key = "module") String projectKey) {
|
||||
|
||||
Assert.notNull(iteration, "Train iteration must not be null!");
|
||||
Optional<Project> project = Projects.byName(projectKey);
|
||||
|
||||
project.ifPresent(it -> build.triggerBuild(iteration.getModule(it)));
|
||||
|
||||
if (!project.isPresent()) {
|
||||
git.prepare(iteration);
|
||||
iteration.forEach(module -> build.triggerBuild(module));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,6 +135,10 @@ public class BuildOperations {
|
||||
return doWithBuildSystem(module, BuildSystem::deploy);
|
||||
}
|
||||
|
||||
public ModuleIteration triggerBuild(ModuleIteration module) {
|
||||
return doWithBuildSystem(module, BuildSystem::triggerBuild);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the build system for each {@link ModuleIteration} contained in the given {@link TrainIteration} and
|
||||
* executes the given function for it.
|
||||
|
||||
@@ -60,4 +60,6 @@ interface BuildSystem extends Plugin<Project> {
|
||||
* @return
|
||||
*/
|
||||
ModuleIteration triggerDistributionBuild(ModuleIteration module);
|
||||
|
||||
ModuleIteration triggerBuild(ModuleIteration module);
|
||||
}
|
||||
|
||||
@@ -221,6 +221,8 @@ class MavenBuildSystem implements BuildSystem {
|
||||
"-DnewVersion=".concat(information.getReleaseTrainVersion()), //
|
||||
"-DgroupId=org.springframework.data", //
|
||||
"-DartifactId=spring-data-releasetrain");
|
||||
|
||||
mvn.execute(project, "install");
|
||||
}
|
||||
|
||||
return module;
|
||||
@@ -243,6 +245,26 @@ class MavenBuildSystem implements BuildSystem {
|
||||
return information;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.data.release.build.BuildSystem#triggerBuild(org.springframework.data.release.model.ModuleIteration)
|
||||
*/
|
||||
@Override
|
||||
public ModuleIteration triggerBuild(ModuleIteration module) {
|
||||
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.add("clean");
|
||||
arguments.add("install");
|
||||
|
||||
if (module.getProject().skipTests()) {
|
||||
arguments.add("-DskipTests");
|
||||
}
|
||||
|
||||
mvn.execute(module.getProject(), arguments);
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers Maven commands to deploy module artifacts to Spring Artifactory.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user