|
2 | 2 |
|
3 | 3 | /*
|
4 | 4 | * Copyright 2001-2005 The Apache Software Foundation.
|
5 |
| - * |
| 5 | + * |
6 | 6 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
|
7 | 7 | * in compliance with the License. You may obtain a copy of the License at
|
8 |
| - * |
| 8 | + * |
9 | 9 | * http://www.apache.org/licenses/LICENSE-2.0
|
10 |
| - * |
| 10 | + * |
11 | 11 | * Unless required by applicable law or agreed to in writing, software distributed under the License
|
12 | 12 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
13 | 13 | * or implied. See the License for the specific language governing permissions and limitations under
|
|
52 | 52 | /**
|
53 | 53 | * Goal which generates client/server code from a swagger json/yaml definition.
|
54 | 54 | */
|
55 |
| -@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES) |
| 55 | +@Mojo(name = "generate", defaultPhase = LifecyclePhase.GENERATE_SOURCES, threadSafe = true) |
56 | 56 | public class CodeGenMojo extends AbstractMojo {
|
57 | 57 |
|
58 | 58 | @Parameter(name = "verbose", required = false, defaultValue = "false")
|
@@ -220,7 +220,7 @@ public class CodeGenMojo extends AbstractMojo {
|
220 | 220 | * A map of reserved names and how they should be escaped
|
221 | 221 | */
|
222 | 222 | @Parameter(name = "reservedWordsMappings")
|
223 |
| - private List<String> reservedWordsMappings; |
| 223 | + private List<String> reservedWordsMappings; |
224 | 224 |
|
225 | 225 | /**
|
226 | 226 | * Generate the apis
|
@@ -314,6 +314,13 @@ public class CodeGenMojo extends AbstractMojo {
|
314 | 314 |
|
315 | 315 | @Override
|
316 | 316 | public void execute() throws MojoExecutionException {
|
| 317 | + // Using the naive approach for achieving thread safety |
| 318 | + synchronized (CodeGenMojo.class) { |
| 319 | + execute_(); |
| 320 | + } |
| 321 | + } |
| 322 | + |
| 323 | + protected void execute_() throws MojoExecutionException { |
317 | 324 |
|
318 | 325 | if (skip) {
|
319 | 326 | getLog().info("Code generation is skipped.");
|
|
0 commit comments