Skip to content

Commit

Permalink
[maven-generator] Do not cleanup output if spec file is unchanged and…
Browse files Browse the repository at this point in the history
… skipIfSpecIsUnchanged=true (Fixes OpenAPITools#16490) (OpenAPITools#16491)

* Don't delete output directory if spec is unchanged

Resolves OpenAPITools#16490

* Fix some typos
  • Loading branch information
Philzen authored Sep 12, 2023
1 parent c6d355e commit 196c2b1
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -520,15 +520,6 @@ public void execute() throws MojoExecutionException {
"generated-test-sources/openapi" : "generated-sources/openapi");
}

if (cleanupOutput) {
try {
FileUtils.deleteDirectory(output);
LOGGER.info("Previous run output is removed from {}", output);
} catch (IOException e) {
LOGGER.warn("Failed to clean-up output directory {}", output, e);
}
}

addCompileSourceRootIfConfigured();

try {
Expand Down Expand Up @@ -566,10 +557,19 @@ public void execute() throws MojoExecutionException {
}
}

if (cleanupOutput) {
try {
FileUtils.deleteDirectory(output);
LOGGER.info("Previous run output is removed from {}", output);
} catch (IOException e) {
LOGGER.warn("Failed to clean up output directory {}", output, e);
}
}

// attempt to read from config file
CodegenConfigurator configurator = CodegenConfigurator.fromFile(configurationFile);

// if a config file wasn't specified or we were unable to read it
// if a config file wasn't specified, or we were unable to read it
if (configurator == null) {
configurator = new CodegenConfigurator();
}
Expand Down Expand Up @@ -938,8 +938,8 @@ public void execute() throws MojoExecutionException {
/**
* Calculate openapi specification file hash. If specification is hosted on remote resource it is downloaded first
*
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
* Does not taken into account if input spec is hosted on remote resource
* @param inputSpecFile - Openapi specification input file to calculate its hash.
* Does not take into account if input spec is hosted on remote resource
* @return openapi specification file hash
* @throws IOException
*/
Expand Down Expand Up @@ -991,8 +991,8 @@ private URL inputSpecRemoteUrl(){

/**
* Get specification hash file
* @param inputSpecFile - Openapi specification input file to calculate it's hash.
* Does not taken into account if input spec is hosted on remote resource
* @param inputSpecFile - Openapi specification input file to calculate its hash.
* Does not take into account if input spec is hosted on remote resource
* @return a file with previously calculated hash
*/
private File getHashFile(File inputSpecFile) {
Expand Down

0 comments on commit 196c2b1

Please sign in to comment.