Skip to content

Commit 8c62850

Browse files
committed
openapi: fix/update maven/gradle plugins
- ref #3733
1 parent 974a896 commit 8c62850

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

modules/jooby-gradle-plugin/src/main/java/io/jooby/gradle/OpenAPITask.java

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import org.gradle.api.tasks.TaskAction;
1414

1515
import edu.umd.cs.findbugs.annotations.Nullable;
16+
17+
import java.io.File;
1618
import java.nio.file.Path;
1719
import java.util.List;
1820
import java.util.Optional;
@@ -44,27 +46,27 @@ public void generate() throws Throwable {
4446

4547
String mainClass = Optional.ofNullable(this.mainClass)
4648
.orElseGet(() -> computeMainClassName(projects));
47-
48-
Path outputDir = classes(getProject(), false);
49-
// Reduce lookup to current project: See https://github.com/jooby-project/jooby/issues/2756
50-
String metaInf =
51-
outputDir
52-
.resolve("META-INF")
53-
.resolve("services")
54-
.resolve("io.jooby.MvcFactory")
55-
.toAbsolutePath()
56-
.toString();
49+
var sources = projects.stream()
50+
.flatMap(project -> {
51+
var sourceSet = sourceSet(project, false);
52+
return sourceSet.stream()
53+
.flatMap(it -> it.getAllSource().getSrcDirs().stream())
54+
.map(File::toPath);
55+
})
56+
.distinct()
57+
.toList(); Path outputDir = classes(getProject(), false);
5758

5859
ClassLoader classLoader = createClassLoader(projects);
5960

6061
getLogger().info("Generating OpenAPI: " + mainClass);
6162
getLogger().debug("Using classloader: " + classLoader);
6263
getLogger().debug("Output directory: " + outputDir);
63-
getLogger().debug("META-INF: " + metaInf);
64+
getLogger().debug("Source directories: " + sources);
6465

65-
OpenAPIGenerator tool = new OpenAPIGenerator(metaInf);
66+
OpenAPIGenerator tool = new OpenAPIGenerator();
6667
tool.setClassLoader(classLoader);
6768
tool.setOutputDir(outputDir);
69+
tool.setSources(sources);
6870
trim(includes).ifPresent(tool::setIncludes);
6971
trim(excludes).ifPresent(tool::setExcludes);
7072

modules/jooby-maven-plugin/src/main/java/io/jooby/maven/OpenAPIMojo.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,21 @@ protected void doExecute(@NonNull List<MavenProject> projects, @NonNull String m
4949
throws Exception {
5050
ClassLoader classLoader = createClassLoader(projects);
5151
Path outputDir = Paths.get(project.getBuild().getOutputDirectory());
52-
// Reduce lookup to current project: See https://github.com/jooby-project/jooby/issues/2756
52+
var sources =
53+
projects.stream()
54+
.map(project -> Paths.get(project.getBuild().getSourceDirectory()))
55+
.distinct()
56+
.toList();
5357

5458
getLog().info("Generating OpenAPI: " + mainClass);
5559
getLog().debug("Using classloader: " + classLoader);
5660
getLog().debug("Output directory: " + outputDir);
61+
getLog().debug("Source directories: " + sources);
5762

5863
OpenAPIGenerator tool = new OpenAPIGenerator();
5964
tool.setClassLoader(classLoader);
6065
tool.setOutputDir(outputDir);
66+
tool.setSources(sources);
6167
trim(includes).ifPresent(tool::setIncludes);
6268
trim(excludes).ifPresent(tool::setExcludes);
6369

0 commit comments

Comments
 (0)