Skip to content

Commit 9595adc

Browse files
committed
Fix #6260 - make plugin thread safe by preventing parallelism. This naive approach should be replaced in the future and allow parallel runs to achieve faster build times but this change will at least allow users to run maven with threads and other plugins and modules will run in parallel. This approach is also suggested by Apache Maven as a workaround: https://cwiki.apache.org/confluence/display/MAVEN/Parallel+builds+in+Maven+3
1 parent 75a4426 commit 9595adc

File tree

1 file changed

+8
-1
lines changed
  • modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin

1 file changed

+8
-1
lines changed

modules/swagger-codegen-maven-plugin/src/main/java/io/swagger/codegen/plugin/CodeGenMojo.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
/**
5151
* Goal which generates client/server code from a swagger json/yaml definition.
5252
*/
53-
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
53+
@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true)
5454
public class CodeGenMojo extends AbstractMojo {
5555

5656
@Parameter(name = "verbose", required = false, defaultValue = "false")
@@ -315,6 +315,13 @@ public class CodeGenMojo extends AbstractMojo {
315315

316316
@Override
317317
public void execute() throws MojoExecutionException {
318+
// Using the naive approach for achieving thread safety
319+
synchronized (CodeGenMojo.class) {
320+
execute_();
321+
}
322+
}
323+
324+
protected void execute_() throws MojoExecutionException {
318325

319326
if (skip) {
320327
getLog().info("Code generation is skipped.");

0 commit comments

Comments
 (0)