ppalaga commented on a change in pull request #242: quarkus-camel-catalog URL: https://github.com/apache/camel-quarkus/pull/242#discussion_r332563512
########## File path: tooling/maven/package-maven-plugin/src/main/java/org/apache/camel/quarkus/maven/PrepareCatalogQuarkusMojo.java ########## @@ -0,0 +1,416 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.maven; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; +import org.apache.maven.project.ProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; +import org.apache.maven.project.ProjectBuildingResult; +import org.apache.maven.repository.RepositorySystem; +import org.mvel2.templates.TemplateRuntime; + +import static org.apache.camel.quarkus.maven.PackageHelper.camelDashToTitle; +import static org.apache.camel.quarkus.maven.PackageHelper.loadText; +import static org.apache.camel.quarkus.maven.PackageHelper.writeText; + +/** + * Prepares the Quarkus provider camel catalog to include component it supports + */ +@Mojo(name = "prepare-catalog-quarkus", threadSafe = true, requiresDependencyCollection = ResolutionScope.COMPILE_PLUS_RUNTIME) +public class PrepareCatalogQuarkusMojo extends AbstractMojo { + + private static final String[] EXCLUDE_EXTENSIONS = { + "http-common", "jetty-common", "support", "xml-common", "xstream-common" + }; + + private static final Pattern SCHEME_PATTERN = Pattern.compile("\"scheme\": \"(.*)\""); + private static final Pattern NAME_PATTERN = Pattern.compile("\"name\": \"(.*)\""); + private static final Pattern GROUP_PATTERN = Pattern.compile("\"groupId\": \"(org.apache.camel)\""); + private static final Pattern ARTIFACT_PATTERN = Pattern.compile("\"artifactId\": \"camel-(.*)\""); + private static final Pattern VERSION_PATTERN = Pattern.compile("\"version\": \"(.*)\""); + + /** + * The maven project. + */ + @Parameter(property = "project", required = true, readonly = true) + protected MavenProject project; + + @Component + private RepositorySystem repositorySystem; + + @Component + private ProjectBuilder mavenProjectBuilder; + + @Parameter(defaultValue = "${session}", readonly = true) + private MavenSession session; + + @Component + private MavenProjectHelper projectHelper; + + /** + * The output directory for components catalog + */ + @Parameter(defaultValue = "${project.build.directory}/classes/org/apache/camel/catalog/quarkus/components") + protected File componentsOutDir; + + /** + * The output directory for dataformats catalog + */ + @Parameter(defaultValue = "${project.build.directory}/classes/org/apache/camel/catalog/quarkus/dataformats") + protected File dataFormatsOutDir; + + /** + * The output directory for languages catalog + */ + @Parameter(defaultValue = "${project.build.directory}/classes/org/apache/camel/catalog/quarkus/languages") + protected File languagesOutDir; + + /** + * The output directory for others catalog + */ + @Parameter(defaultValue = "${project.build.directory}/classes/org/apache/camel/catalog/quarkus/others") + protected File othersOutDir; + + /** + * The directory where all quarkus extension starters are + */ + @Parameter(defaultValue = "${project.build.directory}/../../../extensions") + protected File extensionsDir; + + /** + * Execute goal. + * + * @throws MojoExecutionException execution of the main class or one of the + * threads it generated failed. + * @throws MojoFailureException something bad happened... + */ + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + Set<String> extensions = findExtensions(); + Set<String> artifacts = extractArtifactIds(extensions); + executeComponents(artifacts); + executeLanguages(artifacts); + executeDataFormats(artifacts); + executeOthers(extensions); Review comment: Execute everybody who is still alive! :) ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
