You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by lb...@apache.org on 2019/10/01 04:23:48 UTC

[camel-quarkus] branch master updated: Remove scaffold-integration-test.groovy #173

This is an automated email from the ASF dual-hosted git repository.

lburgazzoli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git


The following commit(s) were added to refs/heads/master by this push:
     new 9843061  Remove scaffold-integration-test.groovy #173
9843061 is described below

commit 984306138820622ff6fa7f02323f6f33d9d65a22
Author: lburgazzoli <lb...@gmail.com>
AuthorDate: Mon Sep 30 20:59:20 2019 +0200

    Remove scaffold-integration-test.groovy #173
---
 .../TestRouteBuilder.java                          |  26 ----
 build/scripts/scaffold-integration-test.groovy     | 131 ---------------------
 docs/modules/ROOT/pages/contributor-guide.adoc     |   2 +-
 extensions/pom.xml                                 |  43 +------
 4 files changed, 3 insertions(+), 199 deletions(-)

diff --git a/build/create-extension-templates/TestRouteBuilder.java b/build/create-extension-templates/TestRouteBuilder.java
deleted file mode 100644
index d870e1e..0000000
--- a/build/create-extension-templates/TestRouteBuilder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * 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 [=javaPackageBase].it;
-
-import org.apache.camel.builder.RouteBuilder;
-
-public class [=artifactIdBaseCamelCase]RouteBuilder extends RouteBuilder {
-    @Override
-    public void configure() {
-        // Add some routes or remove this class
-    }
-}
diff --git a/build/scripts/scaffold-integration-test.groovy b/build/scripts/scaffold-integration-test.groovy
deleted file mode 100644
index d470be9..0000000
--- a/build/scripts/scaffold-integration-test.groovy
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * 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.
- */
-import java.util.stream.Collectors
-import java.nio.charset.Charset
-import java.nio.charset.StandardCharsets
-import java.nio.file.Files
-import java.nio.file.Path
-import java.nio.file.Paths
-
-import freemarker.cache.ClassTemplateLoader
-import freemarker.cache.FileTemplateLoader
-import freemarker.cache.MultiTemplateLoader
-import freemarker.cache.TemplateLoader
-import freemarker.template.Configuration
-import freemarker.template.Template
-import freemarker.template.TemplateException
-import freemarker.template.TemplateExceptionHandler
-
-import io.quarkus.maven.CreateExtensionMojo.TemplateParams
-import io.quarkus.maven.utilities.PomTransformer
-import io.quarkus.maven.utilities.PomTransformer.Transformation
-
-import org.slf4j.Logger
-import org.slf4j.LoggerFactory
-
-/* Keep in sync with the current file name */
-@groovy.transform.Field static final String currentScript = "scaffold-integration-test.groovy"
-@groovy.transform.Field static final Logger log = LoggerFactory.getLogger('scaffold-integration-test')
-final Path extensionsDir = project.basedir.toPath()
-final Path templatesDir = extensionsDir.resolve('../build/create-extension-templates')
-final String artifactIdBase = properties['quarkus.artifactIdBase']
-final Path itestDir = extensionsDir.resolve('../integration-tests/' + artifactIdBase)
-final Charset charset = StandardCharsets.UTF_8
-
-final nameBase = properties['quarkus.nameBase'] == null ? artifactIdBase.split(' ').collect{it.capitalize()}.join(' ') : artifactIdBase
-
-Files.createDirectories(itestDir)
-
-final Configuration cfg = new Configuration(Configuration.VERSION_2_3_28)
-cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER)
-cfg.setTemplateLoader(createTemplateLoader(templatesDir))
-cfg.setDefaultEncoding('UTF-8')
-cfg.setInterpolationSyntax(Configuration.SQUARE_BRACKET_INTERPOLATION_SYNTAX)
-cfg.setTagSyntax(Configuration.SQUARE_BRACKET_TAG_SYNTAX)
-
-TemplateParams model = new TemplateParams()
-
-model.artifactIdBase = artifactIdBase
-model.artifactIdBaseCamelCase = toCapCamelCase(model.artifactIdBase)
-model.version = project.version
-
-model.nameBase = nameBase
-
-model.javaPackageBase = getJavaPackage('org.apache.camel.quarkus', 'component', artifactIdBase)
-final String javaPackageBasePath = model.javaPackageBase.replace('.', '/')
-
-evalTemplate(cfg, "integration-test-pom.xml", itestDir.resolve('pom.xml'), charset, model)
-evalTemplate(cfg, "TestResource.java", itestDir.resolve('src/main/java/' + javaPackageBasePath + '/it/'+ model.artifactIdBaseCamelCase + 'Resource.java'), charset, model)
-evalTemplate(cfg, "TestRouteBuilder.java", itestDir.resolve('src/main/java/' + javaPackageBasePath + '/it/'+ model.artifactIdBaseCamelCase + 'RouteBuilder.java'), charset, model)
-evalTemplate(cfg, "Test.java", itestDir.resolve('src/test/java/' + javaPackageBasePath + '/it/'+ model.artifactIdBaseCamelCase + 'Test.java'), charset, model)
-evalTemplate(cfg, "IT.java", itestDir.resolve('src/test/java/' + javaPackageBasePath + '/it/'+ model.artifactIdBaseCamelCase + 'IT.java'), charset, model)
-
-log.info(String.format("Adding module [%s] to [%s]", model.artifactIdBase, itestDir.resolve('../pom.xml')))
-new PomTransformer(itestDir.resolve('../pom.xml'), charset).transform(Transformation.addModule(model.artifactIdBase))
-
-static TemplateLoader createTemplateLoader(Path templatesDir) throws IOException {
-    return new MultiTemplateLoader([new FileTemplateLoader(templatesDir.toFile())] as TemplateLoader[])
-}
-
-static void evalTemplate(Configuration cfg, String templateUri, Path dest, Charset charset, TemplateParams model)
-        throws IOException, TemplateException {
-    log.info("Adding '{}'", dest)
-    final Template template = cfg.getTemplate(templateUri)
-    Files.createDirectories(dest.getParent())
-    Writer out
-    try {
-        out = Files.newBufferedWriter(dest)
-        template.process(model, out)
-    } finally {
-        out.close()
-    }
-}
-
-static String toCapCamelCase(String artifactIdBase) {
-    final StringBuilder sb = new StringBuilder(artifactIdBase.length())
-    for (String segment : artifactIdBase.split("[.\\-]+")) {
-        sb.append(Character.toUpperCase(segment.charAt(0)))
-        if (segment.length() > 1) {
-            sb.append(segment.substring(1))
-        }
-    }
-    return sb.toString()
-}
-
-static String getJavaPackage(String groupId, String javaPackageInfix, String artifactId) {
-    final Stack<String> segments = new Stack<>()
-    for (String segment : groupId.split("[.\\-]+")) {
-        if (segments.isEmpty() || !segments.peek().equals(segment)) {
-            segments.add(segment)
-        }
-    }
-    if (javaPackageInfix != null) {
-        for (String segment : javaPackageInfix.split("[.\\-]+")) {
-            segments.add(segment)
-        }
-    }
-    for (String segment : artifactId.split("[.\\-]+")) {
-        if (!segments.contains(segment)) {
-            segments.add(segment)
-        }
-    }
-    return segments.stream() //
-            .map{s -> s.toLowerCase(Locale.ROOT)} //
-            .map{s -> javax.lang.model.SourceVersion.isKeyword(s) ? s + "_" : s} //
-            .collect(Collectors.joining("."))
-}
-
diff --git a/docs/modules/ROOT/pages/contributor-guide.adoc b/docs/modules/ROOT/pages/contributor-guide.adoc
index 2db3ebd..a1a6e57 100644
--- a/docs/modules/ROOT/pages/contributor-guide.adoc
+++ b/docs/modules/ROOT/pages/contributor-guide.adoc
@@ -62,7 +62,7 @@ mvn clean install -Dnative
 ----
 cd camel-quarkus
 cd extensions
-mvn quarkus:create-extension groovy:execute@scaffold-integration-test -N \
+mvn quarkus:create-extension -N \
     -Dquarkus.artifactIdBase=foo \
     -Dquarkus.nameBase="Foo"
 ----
diff --git a/extensions/pom.xml b/extensions/pom.xml
index 3067117..43cfda2 100644
--- a/extensions/pom.xml
+++ b/extensions/pom.xml
@@ -71,7 +71,7 @@
                 <artifactId>quarkus-maven-plugin</artifactId>
                 <inherited>false</inherited>
                 <!-- Setting for stubbing new extensions via
-                       mvn quarkus:create-extension groovy:execute@scaffold-integration-test -N -Dquarkus.artifactIdBase=my-new-extension
+                       mvn quarkus:create-extension -N -Dquarkus.artifactIdBase=my-new-extension
                 -->
                 <configuration>
                     <artifactIdPrefix>camel-quarkus-</artifactIdPrefix>
@@ -81,6 +81,7 @@
                     <templatesUriBase>file:///${project.basedir}/../build/create-extension-templates</templatesUriBase>
                     <runtimeBomPath>../poms/bom/pom.xml</runtimeBomPath>
                     <deploymentBomPath>../poms/bom-deployment/pom.xml</deploymentBomPath>
+                    <itestParentPath>../integration-tests/pom.xml</itestParentPath>
                 </configuration>
             </plugin>
             <plugin>
@@ -111,44 +112,4 @@
             </plugin>
         </plugins>
     </build>
-
-    <profiles>
-        <profile>
-            <id>scaffold-integration-test</id>
-            <activation>
-                <property><name>quarkus.artifactIdBase</name></property>
-            </activation>
-
-            <build>
-                <plugins>
-                    <plugin>
-                        <groupId>org.codehaus.gmaven</groupId>
-                        <artifactId>groovy-maven-plugin</artifactId>
-                        <inherited>false</inherited>
-                        <executions>
-                            <execution>
-                                <id>scaffold-integration-test</id>
-                                <goals>
-                                    <goal>execute</goal>
-                                </goals>
-                                <phase>validate</phase>
-                                <configuration>
-                                    <source>file://${basedir}/../build/scripts/scaffold-integration-test.groovy</source>
-                                </configuration>
-                            </execution>
-                        </executions>
-                        <dependencies>
-                            <dependency>
-                                <groupId>io.quarkus</groupId>
-                                <artifactId>quarkus-maven-plugin</artifactId>
-                                <version>${quarkus.version}</version>
-                            </dependency>
-                        </dependencies>
-                    </plugin>
-
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
-
 </project>