From 598bb68af61adf01201f6509515505b23cf3dc77 Mon Sep 17 00:00:00 2001 From: Philzen Date: Sun, 3 Sep 2023 13:31:22 +0200 Subject: [PATCH 1/2] Don't delete output directory if spec is unchanged Resolves #16490 --- .../codegen/plugin/CodeGenMojo.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java index b45318b9f853..983dc856b39a 100644 --- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java +++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java @@ -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 { @@ -566,6 +557,15 @@ 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); From d33433eeef3b268b291069b15e49b9e535f170a4 Mon Sep 17 00:00:00 2001 From: Philzen Date: Sun, 3 Sep 2023 13:33:52 +0200 Subject: [PATCH 2/2] Fix some typos --- .../org/openapitools/codegen/plugin/CodeGenMojo.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java index 983dc856b39a..40de961a11e7 100644 --- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java +++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java @@ -562,14 +562,14 @@ public void execute() throws MojoExecutionException { 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); + 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(); } @@ -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 */ @@ -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) {