#35 - Added command to trigger builds.
This commit is contained in:
@@ -21,12 +21,19 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.experimental.FieldDefaults;
|
import lombok.experimental.FieldDefaults;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.release.CliComponent;
|
import org.springframework.data.release.CliComponent;
|
||||||
import org.springframework.data.release.TimedCommand;
|
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.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.data.release.utils.Logger;
|
||||||
import org.springframework.shell.core.annotation.CliCommand;
|
import org.springframework.shell.core.annotation.CliCommand;
|
||||||
|
import org.springframework.shell.core.annotation.CliOption;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oliver Gierke
|
* @author Oliver Gierke
|
||||||
@@ -38,6 +45,7 @@ class BuildCommands extends TimedCommand {
|
|||||||
|
|
||||||
@NonNull BuildOperations build;
|
@NonNull BuildOperations build;
|
||||||
@NonNull Workspace workspace;
|
@NonNull Workspace workspace;
|
||||||
|
@NonNull GitOperations git;
|
||||||
@NonNull Logger logger;
|
@NonNull Logger logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -54,4 +62,25 @@ class BuildCommands extends TimedCommand {
|
|||||||
workspace.purge(build.getLocalRepository(),
|
workspace.purge(build.getLocalRepository(),
|
||||||
path -> build.getLocalRepository().relativize(path).startsWith("org/springframework/data"));
|
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);
|
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
|
* Selects the build system for each {@link ModuleIteration} contained in the given {@link TrainIteration} and
|
||||||
* executes the given function for it.
|
* executes the given function for it.
|
||||||
|
|||||||
@@ -60,4 +60,6 @@ interface BuildSystem extends Plugin<Project> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ModuleIteration triggerDistributionBuild(ModuleIteration module);
|
ModuleIteration triggerDistributionBuild(ModuleIteration module);
|
||||||
|
|
||||||
|
ModuleIteration triggerBuild(ModuleIteration module);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,6 +221,8 @@ class MavenBuildSystem implements BuildSystem {
|
|||||||
"-DnewVersion=".concat(information.getReleaseTrainVersion()), //
|
"-DnewVersion=".concat(information.getReleaseTrainVersion()), //
|
||||||
"-DgroupId=org.springframework.data", //
|
"-DgroupId=org.springframework.data", //
|
||||||
"-DartifactId=spring-data-releasetrain");
|
"-DartifactId=spring-data-releasetrain");
|
||||||
|
|
||||||
|
mvn.execute(project, "install");
|
||||||
}
|
}
|
||||||
|
|
||||||
return module;
|
return module;
|
||||||
@@ -243,6 +245,26 @@ class MavenBuildSystem implements BuildSystem {
|
|||||||
return information;
|
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.
|
* Triggers Maven commands to deploy module artifacts to Spring Artifactory.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user