public void execute()

in geronimo-openapi-maven-plugin/src/main/java/org/apache/geronimo/microprofile/openapi/mojo/OpenAPIMojo.java [98:184]


    public void execute() throws MojoExecutionException {
        if (skip) {
            getLog().warn("Execution is skipped");
            return;
        }

        final OpenAPIImpl api = new OpenAPIImpl();
        final Thread thread = Thread.currentThread();
        final ClassLoader pluginLoader = thread.getContextClassLoader();
        try {
            try (final URLClassLoader loader = new URLClassLoader(
                    Stream.concat(
                            Stream.of(classes),
                            ofNullable(project)
                                    .map(p -> p.getArtifacts().stream().map(Artifact::getFile)).orElseGet(Stream::empty))
                            .filter(Objects::nonNull)
                            .map(file -> {
                                try {
                                    return file.toURI().toURL();
                                } catch (final MalformedURLException e) {
                                    throw new IllegalStateException(e.getMessage());
                                }
                            })
                            .toArray(URL[]::new), pluginLoader) {

                {
                    thread.setContextClassLoader(this);
                }

                @Override
                public void close() throws IOException {
                    thread.setContextClassLoader(pluginLoader);
                    super.close();
                }
            }) {
                if ((application == null || hasNoEndpoint()) &&
                        classes != null && classes.exists()) {
                    scan(loader);
                }

                final AnnotationProcessor processor = new AnnotationProcessor(
                        (value, def) -> ofNullable(configuration).orElseGet(Collections::emptyMap).getOrDefault(value, def),
                        loadNamingStrategy(), null);
                if (application != null) {
                    processor.processApplication(api, new ClassElement(load(application)));
                    getLog().info("Processed application " + application);
                }
                if (endpointClasses != null) {
                    final String binding = hasNoApplication() ? "" : processor.getApplicationBinding(load(application));
                    endpointClasses.stream().map(this::load)
                            .peek(c -> getLog().info("Processing class " + c.getName()))
                            .forEach(c -> processor.processClass(
                                    binding, api, new ClassElement(c),
                                    Stream.of(c.getMethods()).map(MethodElement::new)));
                } else {
                    getLog().warn("No <endpointClasses> registered, your OpenAPI will be empty.");
                }
            }
        } catch (final IOException e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }

        // info are required
        if (info == null) {
            info = new InfoImpl();
        }
        if (info.getVersion() == null) {
            info.setVersion(project.getVersion());
        }
        if (info.getTitle() == null) {
            info.setTitle(project.getName());
        }
        if (info.getDescription() == null) {
            info.setDescription(project.getDescription());
        }
        api.info(info);

        output.getParentFile().mkdirs();
        try (final Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withFormatting(prettify));
             final Writer writer = Files.newBufferedWriter(
                     output.toPath(), encoding == null ? StandardCharsets.UTF_8 : Charset.forName(encoding))) {
            jsonb.toJson(api, writer);
        } catch (final Exception e) {
            throw new MojoExecutionException(e.getMessage(), e);
        }
        getLog().info("Wrote " + output);
    }