#38 - Polishing.
Renamed workspace purge artifacts to build purge artifacts as it requires knowledge about the build, not only the workspace. Some JavaDoc and assertions. Moved logging of workspace cleanup from operations to Workspace. Re-enabled workspace command as @CliComponent was missing on the class.
This commit is contained in:
@@ -53,7 +53,7 @@ class BuildCommands extends TimedCommand {
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@CliCommand("workspace purge artifacts")
|
||||
@CliCommand("build purge artifacts")
|
||||
public void purge() throws IOException {
|
||||
|
||||
logger.log("Workspace", "Cleaning up workspace directory at %s.",
|
||||
|
||||
@@ -121,6 +121,11 @@ public class BuildOperations {
|
||||
return doWithBuildSystem(iteration, (system, module) -> system.prepareVersion(module, phase));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Path} of the local artifact repository.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Path getLocalRepository() {
|
||||
return properties.getLocalRepository().toPath();
|
||||
}
|
||||
@@ -135,6 +140,12 @@ public class BuildOperations {
|
||||
return doWithBuildSystem(module, BuildSystem::deploy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a nomarl build for the given {@link ModuleIteration}.
|
||||
*
|
||||
* @param module must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
public ModuleIteration triggerBuild(ModuleIteration module) {
|
||||
return doWithBuildSystem(module, BuildSystem::triggerBuild);
|
||||
}
|
||||
@@ -177,6 +188,8 @@ public class BuildOperations {
|
||||
*/
|
||||
private <T> T doWithBuildSystem(ModuleIteration module, BiFunction<BuildSystem, ModuleIteration, T> function) {
|
||||
|
||||
Assert.notNull(module, "ModuleIteration must not be null!");
|
||||
|
||||
Supplier<IllegalStateException> exception = () -> new IllegalStateException(
|
||||
String.format("No build system plugin found for project %s!", module.getProject()));
|
||||
|
||||
|
||||
@@ -276,6 +276,15 @@ class MavenBuildSystem implements BuildSystem {
|
||||
return module;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(Project project) {
|
||||
return isMavenProject(project);
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers Maven commands to deploy module artifacts to Spring Artifactory.
|
||||
*
|
||||
@@ -337,15 +346,6 @@ class MavenBuildSystem implements BuildSystem {
|
||||
mvn.execute(module.getProject(), arguments);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.springframework.plugin.core.Plugin#supports(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean supports(Project project) {
|
||||
return isMavenProject(project);
|
||||
}
|
||||
|
||||
private boolean isMavenProject(Project project) {
|
||||
return workspace.getFile(POM_XML, project).exists();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@ package org.springframework.data.release.io;
|
||||
|
||||
import static org.springframework.data.release.utils.StreamUtils.*;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -40,6 +42,7 @@ import javax.annotation.PostConstruct;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.core.io.support.ResourcePatternResolver;
|
||||
import org.springframework.data.release.model.Project;
|
||||
import org.springframework.data.release.utils.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -50,12 +53,14 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
||||
public class Workspace {
|
||||
|
||||
private static final Charset UTF_8 = StandardCharsets.UTF_8;
|
||||
|
||||
private final @NonNull IoProperties ioProperties;
|
||||
private final @NonNull ResourcePatternResolver resolver;
|
||||
@NonNull IoProperties ioProperties;
|
||||
@NonNull ResourcePatternResolver resolver;
|
||||
@NonNull Logger logger;
|
||||
|
||||
/**
|
||||
* Returns the current working directory.
|
||||
@@ -73,6 +78,8 @@ public class Workspace {
|
||||
*/
|
||||
public void cleanup() throws IOException {
|
||||
|
||||
logger.log("Workspace", "Cleaning up workspace directory at %s.", getWorkingDirectory().getAbsolutePath());
|
||||
|
||||
Path workingDirPath = getWorkingDirectory().toPath();
|
||||
|
||||
Files.walkFileTree(workingDirPath, new SimpleFileVisitor<Path>() {
|
||||
|
||||
@@ -22,6 +22,7 @@ import lombok.experimental.FieldDefaults;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.data.release.CliComponent;
|
||||
import org.springframework.data.release.TimedCommand;
|
||||
import org.springframework.data.release.utils.Logger;
|
||||
import org.springframework.shell.core.annotation.CliCommand;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.shell.core.annotation.CliCommand;
|
||||
/**
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@CliComponent
|
||||
@RequiredArgsConstructor
|
||||
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
|
||||
class WorkspaceCommands extends TimedCommand {
|
||||
@@ -38,10 +40,6 @@ class WorkspaceCommands extends TimedCommand {
|
||||
|
||||
@CliCommand("workspace cleanup")
|
||||
public void cleanup() throws IOException {
|
||||
|
||||
logger.log("Workspace", "Cleaning up workspace directory at %s.",
|
||||
workspace.getWorkingDirectory().getAbsolutePath());
|
||||
|
||||
workspace.cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user