Skip to content

Commit 268702c

Browse files
committed
use File.separator, add targetDir to compiler sources only if id!=json
1 parent 8d4f42e commit 268702c

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

src/main/java/io/openapiprocessor/maven/ProcessMojo.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
/**
2222
* run an openapi-processor.
23+
* Except for id==json the generated sources are added to the compile source roots.
2324
*/
2425
@Mojo (name = "process", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
2526
public class ProcessMojo extends AbstractMojo {
@@ -49,12 +50,16 @@ public void execute () throws MojoExecutionException {
4950

5051
File source = apiPath.getParentFile ();
5152
String relativeSource = stripBaseDir (source.getAbsolutePath ());
52-
getLog().info(String.format ("%10s - ${project.basedir}/%s", "apiPath", relativeSource));
53+
getLog().info(String.format ("%10s - ${project.basedir}%s%s", "apiPath", File.pathSeparator, relativeSource));
54+
55+
String targetDir = (String) properties.computeIfAbsent (TARGET_DIR, k -> project.getBuild().getDirectory() + File.pathSeparator + "generated-sources" + File.pathSeparator + id);
56+
57+
if (!"json".equals(id)) {
58+
project.addCompileSourceRoot(targetDir);
59+
}
5360

54-
String targetDir = (String) properties.computeIfAbsent (TARGET_DIR, k -> project.getBuild().getDirectory() + "/generated-sources/" + id);
55-
project.addCompileSourceRoot(targetDir);
5661
String relativeTargetDir = stripBaseDir (targetDir);
57-
getLog().info(String.format ("%10s - ${project.basedir}/%s", "targetDir", relativeTargetDir));
62+
getLog().info(String.format ("%10s - ${project.basedir}%s%s", "targetDir", File.pathSeparator, relativeTargetDir));
5863

5964
File targetRoot = new File(targetDir);
6065
UpToDateCheck upToDateCheck = new UpToDateCheck ();

0 commit comments

Comments
 (0)