Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<apiPackage>remote.org.openapitools.client.api</apiPackage>
<modelPackage>remote.org.openapitools.client.model</modelPackage>
<invokerPackage>remote.org.openapitools.client</invokerPackage>
<cleanupOutput>true</cleanupOutput>
</configuration>
</execution>
</executions>
Expand All @@ -76,8 +77,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc>
</configuration>
</plugin>
Expand Down
1 change: 1 addition & 0 deletions modules/openapi-generator-maven-plugin/examples/kotlin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<configuration>
<!-- specify the swagger yaml -->
<inputSpec>${project.basedir}/swagger.yaml</inputSpec>
<cleanupOutput>true</cleanupOutput>

<!-- target to generate kotlin client code -->
<generatorName>kotlin</generatorName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
<proc>none</proc>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.google.common.io.ByteSource;
import com.google.common.io.CharSource;
import io.swagger.v3.parser.util.ClasspathHelper;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
Expand Down Expand Up @@ -99,6 +100,9 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "output", property = "openapi.generator.maven.plugin.output")
private File output;

@Parameter(name = "cleanupOutput", property = "openapi.generator.maven.plugin.cleanupOutput", defaultValue = "false")
private boolean cleanupOutput;

/**
* Location of the OpenAPI spec, as URL or file.
*/
Expand Down Expand Up @@ -494,6 +498,16 @@ public void execute() throws MojoExecutionException {
LifecyclePhase.GENERATE_TEST_SOURCES.id().equals(mojo.getLifecyclePhase()) ?
"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