Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SaveMojo] create the savedir for explictl targets #1013

Merged
merged 1 commit into from
Apr 25, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/java/io/fabric8/maven/docker/SaveMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ protected void executeInternal(ServiceHub serviceHub) throws DockerAccessExcepti
}
String imageName = getImageName();
String fileName = getFileName(imageName);
ensureSaveDir(fileName);
log.info("Saving image %s to %s", imageName, fileName);
if (!serviceHub.getQueryService().hasImage(imageName)) {
throw new MojoExecutionException("No image " + imageName + " exists");
Expand Down Expand Up @@ -83,15 +84,14 @@ private String getConfiguredFileName() {
}

private String completeCalculatedFileName(String file) throws MojoExecutionException {
ensureBuildDir();
return project.getBuild().getDirectory() + "/" + file.replace("/","-");
}

private void ensureBuildDir() throws MojoExecutionException {
File buildDir = new File(project.getBuild().getDirectory());
if (!buildDir.exists()) {
if (!buildDir.mkdirs()) {
throw new MojoExecutionException("Can not create directory " + buildDir + " for storing save file");
private void ensureSaveDir(String fileName) throws MojoExecutionException {
File saveDir = new File(fileName).getParentFile();
if (!saveDir.exists()) {
if (!saveDir.mkdirs()) {
throw new MojoExecutionException("Can not create directory " + saveDir + " for storing save file");
}
}
}
Expand Down