Skip to content

Commit

Permalink
Fix allureResultsDirectory parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
tegorov committed Apr 26, 2022
1 parent da747b9 commit 6697d3f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/main/java/ru/tegorov/AllureEnvironmentGenerateMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,22 @@
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;

@Mojo(name = "allure-environment", defaultPhase = LifecyclePhase.VALIDATE)
@Mojo(name = "allure-environment", defaultPhase = LifecyclePhase.TEST)
public class AllureEnvironmentGenerateMojo extends AbstractMojo {

private static final String ALLURE_ENVIRONMENT_PROPERTIES = "environment.properties";

@Parameter(required = true, readonly = true)
protected Properties properties;

@Parameter(defaultValue = "target/allure-results", readonly = true)
@Parameter(defaultValue = "${project.build.directory}", readonly = true)
protected String buildDirectory;

@Parameter(property = "allure.results.directory", defaultValue = "allure-results", readonly = true)
protected String allureResultsDirectory;

public void execute() throws MojoExecutionException {
Expand All @@ -46,10 +51,12 @@ public void execute() throws MojoExecutionException {
return;
}

File allureResultsDir = new File(allureResultsDirectory);
allureResultsDir.mkdirs();
Path targetPath = Paths.get(buildDirectory);
Path allureResultsPath = Paths.get(allureResultsDirectory);
File allureResultsFile = targetPath.resolve(allureResultsPath).toFile();
allureResultsFile.mkdirs();

File propertiesFile = new File(allureResultsDirectory, ALLURE_ENVIRONMENT_PROPERTIES);
File propertiesFile = new File(allureResultsFile, ALLURE_ENVIRONMENT_PROPERTIES);
if (propertiesFile.exists()) {
propertiesFile.delete();
}
Expand Down

0 comments on commit 6697d3f

Please sign in to comment.