This is an automated email from the ASF dual-hosted git repository. ppalaga pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit e304605fcfd6fbc986d6ccde22e399a6fd3f44c6 Author: Peter Palaga <ppal...@redhat.com> AuthorDate: Thu Aug 5 22:35:14 2021 +0200 Language component native support #817 --- .../pages/contributor-guide/extension-testing.adoc | 3 +- .../ROOT/pages/reference/extensions/language.adoc | 19 +++-- .../partials/reference/components/language.adoc | 6 +- extensions-jvm/pom.xml | 1 - .../language/deployment/pom.xml | 0 .../language/deployment/LanguageProcessor.java | 14 ---- {extensions-jvm => extensions}/language/pom.xml | 1 - .../language/runtime/pom.xml | 1 + .../main/resources/META-INF/quarkus-extension.yaml | 3 +- extensions/pom.xml | 1 + .../foundation/language}/pom.xml | 80 +++++++++++++++++----- .../component/language/it/LanguageResource.java | 27 +++----- .../component/language/it/LanguageRoutes.java | 20 +++--- .../src/main/resources/application.properties | 17 +++++ .../language/src/main/resources/hello.simple.txt | 1 + .../quarkus/component/language/it/LanguageIT.java | 16 +---- .../component/language/it/LanguageTest.java | 24 +++++-- integration-test-groups/foundation/pom.xml | 1 + integration-tests/foundation-grouped/pom.xml | 17 +++++ tooling/scripts/group-tests.groovy | 17 ++++- 20 files changed, 177 insertions(+), 92 deletions(-) diff --git a/docs/modules/ROOT/pages/contributor-guide/extension-testing.adoc b/docs/modules/ROOT/pages/contributor-guide/extension-testing.adoc index d3fb196..080d6e2 100644 --- a/docs/modules/ROOT/pages/contributor-guide/extension-testing.adoc +++ b/docs/modules/ROOT/pages/contributor-guide/extension-testing.adoc @@ -67,7 +67,8 @@ The grouped module may then be preferred in a CI job that validates pull request E.g. for `https://github.com/apache/camel-quarkus/tree/main/integration-test-groups/azure[integration-test-groups/azure]` there is `https://github.com/apache/camel-quarkus/tree/main/integration-tests/azure-grouped[integration-tests/azure-grouped]`. * Grouped modules dynamically pull all sources from their associated isolated test modules to their `target/[test-]classes` directories respectively. * `application.properties` files and service descriptors are concatenated using a Groovy script. -* The dependencies in the grouped `pom.xml` need to be updated manually via `mvn process-resources -Pformat -N`. +* The dependencies in the grouped `pom.xml` need to be updated manually via `mvn process-resources -Pformat -N` + run from the root directory of the source tree. == Coverage diff --git a/docs/modules/ROOT/pages/reference/extensions/language.adoc b/docs/modules/ROOT/pages/reference/extensions/language.adoc index 3f56d73..abc3322 100644 --- a/docs/modules/ROOT/pages/reference/extensions/language.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/language.adoc @@ -3,16 +3,16 @@ = Language :linkattrs: :cq-artifact-id: camel-quarkus-language -:cq-native-supported: false -:cq-status: Preview -:cq-status-deprecation: Preview +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable :cq-description: Execute scripts in any of the languages supported by Camel. :cq-deprecated: false :cq-jvm-since: 1.1.0 -:cq-native-since: n/a +:cq-native-since: 2.2.0 [.badges] -[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +[.badge-key]##JVM since##[.badge-supported]##1.1.0## [.badge-key]##Native since##[.badge-supported]##2.2.0## Execute scripts in any of the languages supported by Camel. @@ -24,6 +24,10 @@ Please refer to the above link for usage and configuration details. == Maven coordinates +https://code.quarkus.io/?extension-search=camel-quarkus-language[Create a new project with this extension on code.quarkus.io, window="_blank"] + +Or add the coordinates to your existing project: + [source,xml] ---- <dependency> @@ -33,3 +37,8 @@ Please refer to the above link for usage and configuration details. ---- Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. + +== allowContextMapAll option in native mode + +The `allowContextMapAll` option is not supported in native mode as it requires reflective access to security sensitive camel core classes such as +`CamelContext` & `Exchange`. This is considered a security risk and thus access to the feature is not provided by default. diff --git a/docs/modules/ROOT/partials/reference/components/language.adoc b/docs/modules/ROOT/partials/reference/components/language.adoc index 6bc275e..c180610 100644 --- a/docs/modules/ROOT/partials/reference/components/language.adoc +++ b/docs/modules/ROOT/partials/reference/components/language.adoc @@ -2,11 +2,11 @@ // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page :cq-artifact-id: camel-quarkus-language :cq-artifact-id-base: language -:cq-native-supported: false -:cq-status: Preview +:cq-native-supported: true +:cq-status: Stable :cq-deprecated: false :cq-jvm-since: 1.1.0 -:cq-native-since: n/a +:cq-native-since: 2.2.0 :cq-camel-part-name: language :cq-camel-part-title: Language :cq-camel-part-description: Execute scripts in any of the languages supported by Camel. diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index bc44c24..9ea63e4 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -91,7 +91,6 @@ <module>jt400</module> <module>kamelet-reify</module> <module>kotlin-dsl</module> - <module>language</module> <module>ldap</module> <module>ldif</module> <module>lucene</module> diff --git a/extensions-jvm/language/deployment/pom.xml b/extensions/language/deployment/pom.xml similarity index 100% rename from extensions-jvm/language/deployment/pom.xml rename to extensions/language/deployment/pom.xml diff --git a/extensions-jvm/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java b/extensions/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java similarity index 68% rename from extensions-jvm/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java rename to extensions/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java index c1c06b7..31b4f3f 100644 --- a/extensions-jvm/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java +++ b/extensions/language/deployment/src/main/java/org/apache/camel/quarkus/component/language/deployment/LanguageProcessor.java @@ -17,11 +17,7 @@ package org.apache.camel.quarkus.component.language.deployment; import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.pkg.steps.NativeBuild; -import org.apache.camel.quarkus.core.JvmOnlyRecorder; import org.jboss.logging.Logger; class LanguageProcessor { @@ -33,14 +29,4 @@ class LanguageProcessor { FeatureBuildItem feature() { return new FeatureBuildItem(FEATURE); } - - /** - * Remove this once this extension starts supporting the native mode. - */ - @BuildStep(onlyIf = NativeBuild.class) - @Record(value = ExecutionTime.RUNTIME_INIT) - void warnJvmInNative(JvmOnlyRecorder recorder) { - JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time - recorder.warnJvmInNative(FEATURE); // warn at runtime - } } diff --git a/extensions-jvm/language/pom.xml b/extensions/language/pom.xml similarity index 97% rename from extensions-jvm/language/pom.xml rename to extensions/language/pom.xml index 4366bda..2959230 100644 --- a/extensions-jvm/language/pom.xml +++ b/extensions/language/pom.xml @@ -33,6 +33,5 @@ <modules> <module>deployment</module> <module>runtime</module> - <module>integration-test</module> </modules> </project> diff --git a/extensions-jvm/language/runtime/pom.xml b/extensions/language/runtime/pom.xml similarity index 98% rename from extensions-jvm/language/runtime/pom.xml rename to extensions/language/runtime/pom.xml index 49dd1fc..0afa8ba 100644 --- a/extensions-jvm/language/runtime/pom.xml +++ b/extensions/language/runtime/pom.xml @@ -32,6 +32,7 @@ <properties> <camel.quarkus.jvmSince>1.1.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>2.2.0</camel.quarkus.nativeSince> </properties> <dependencyManagement> diff --git a/extensions-jvm/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 97% rename from extensions-jvm/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 9d2e7f4..e2d1f55 100644 --- a/extensions-jvm/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/language/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -24,9 +24,8 @@ name: "Camel Language" description: "Execute scripts in any of the languages supported by Camel" metadata: - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/language.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index f393730..6976a69 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -150,6 +150,7 @@ <module>kotlin</module> <module>kubernetes</module> <module>kudu</module> + <module>language</module> <module>leveldb</module> <module>log</module> <module>lra</module> diff --git a/extensions-jvm/language/integration-test/pom.xml b/integration-test-groups/foundation/language/pom.xml similarity index 53% rename from extensions-jvm/language/integration-test/pom.xml rename to integration-test-groups/foundation/language/pom.xml index 40d8384..087133a 100644 --- a/extensions-jvm/language/integration-test/pom.xml +++ b/integration-test-groups/foundation/language/pom.xml @@ -21,33 +21,25 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-build-parent-it</artifactId> + <artifactId>camel-quarkus-integration-tests-foundation</artifactId> <version>2.2.0-SNAPSHOT</version> - <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> + <relativePath>../pom.xml</relativePath> </parent> - <artifactId>camel-quarkus-language-integration-test</artifactId> - <name>Camel Quarkus :: Language :: Integration Test</name> + <artifactId>camel-quarkus-integration-test-language</artifactId> + <name>Camel Quarkus :: Integration Tests :: Language</name> <description>Integration tests for Camel Quarkus Language extension</description> - <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-bom-test</artifactId> - <version>${project.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> - </dependencyManagement> - <dependencies> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-language</artifactId> </dependency> <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + </dependency> + <dependency> <groupId>io.quarkus</groupId> <artifactId>quarkus-resteasy</artifactId> </dependency> @@ -67,6 +59,32 @@ <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory --> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-direct-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-language-deployment</artifactId> <version>${project.version}</version> <type>pom</type> @@ -80,4 +98,34 @@ </dependency> </dependencies> + <profiles> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.package.type>native</quarkus.package.type> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/extensions-jvm/language/integration-test/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java b/integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java similarity index 60% rename from extensions-jvm/language/integration-test/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java rename to integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java index 4be44f4..87f5b7e 100644 --- a/extensions-jvm/language/integration-test/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java +++ b/integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageResource.java @@ -18,34 +18,27 @@ package org.apache.camel.quarkus.component.language.it; import javax.enterprise.context.ApplicationScoped; import javax.inject.Inject; -import javax.ws.rs.GET; +import javax.ws.rs.Consumes; +import javax.ws.rs.POST; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import org.apache.camel.CamelContext; -import org.jboss.logging.Logger; +import org.apache.camel.ProducerTemplate; @Path("/language") @ApplicationScoped public class LanguageResource { - private static final Logger LOG = Logger.getLogger(LanguageResource.class); - - private static final String COMPONENT_LANGUAGE = "language"; @Inject - CamelContext context; + ProducerTemplate template; - @Path("/load/component/language") - @GET + @Path("/route/{route}") + @POST + @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public Response loadComponentLanguage() throws Exception { - /* This is an autogenerated test */ - if (context.getComponent(COMPONENT_LANGUAGE) != null) { - return Response.ok().build(); - } - LOG.warnf("Could not load [%s] from the Camel context", COMPONENT_LANGUAGE); - return Response.status(500, COMPONENT_LANGUAGE + " could not be loaded from the Camel context").build(); + public String resource(String body, @PathParam("route") String route) { + return template.requestBody("direct:" + route, body, String.class); } } diff --git a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java b/integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java similarity index 68% copy from extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java copy to integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java index 4cf3425..7c9419a 100644 --- a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java +++ b/integration-test-groups/foundation/language/src/main/java/org/apache/camel/quarkus/component/language/it/LanguageRoutes.java @@ -16,19 +16,15 @@ */ package org.apache.camel.quarkus.component.language.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import org.apache.camel.builder.RouteBuilder; -@QuarkusTest -class LanguageTest { +public class LanguageRoutes extends RouteBuilder { - @Test - public void loadComponentLanguage() { - /* A simple autogenerated test */ - RestAssured.get("/language/load/component/language") - .then() - .statusCode(200); + @Override + public void configure() throws Exception { + from("direct:languageSimpleScript") + .to("language://simple:Hello ${body} from simple language script"); + from("direct:languageSimpleResource") + .to("language://simple:resource:hello.simple.txt"); } - } diff --git a/integration-test-groups/foundation/language/src/main/resources/application.properties b/integration-test-groups/foundation/language/src/main/resources/application.properties new file mode 100644 index 0000000..f727794 --- /dev/null +++ b/integration-test-groups/foundation/language/src/main/resources/application.properties @@ -0,0 +1,17 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +quarkus.native.resources.includes = hello.simple.txt diff --git a/integration-test-groups/foundation/language/src/main/resources/hello.simple.txt b/integration-test-groups/foundation/language/src/main/resources/hello.simple.txt new file mode 100644 index 0000000..eb84cdb --- /dev/null +++ b/integration-test-groups/foundation/language/src/main/resources/hello.simple.txt @@ -0,0 +1 @@ +Hello ${body} from simple language resource \ No newline at end of file diff --git a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java b/integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageIT.java similarity index 70% copy from extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java copy to integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageIT.java index 4cf3425..11c66fe 100644 --- a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java +++ b/integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageIT.java @@ -16,19 +16,9 @@ */ package org.apache.camel.quarkus.component.language.it; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import org.junit.jupiter.api.Test; +import io.quarkus.test.junit.NativeImageTest; -@QuarkusTest -class LanguageTest { - - @Test - public void loadComponentLanguage() { - /* A simple autogenerated test */ - RestAssured.get("/language/load/component/language") - .then() - .statusCode(200); - } +@NativeImageTest +class LanguageIT extends LanguageTest { } diff --git a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java b/integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java similarity index 58% rename from extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java rename to integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java index 4cf3425..245b70b 100644 --- a/extensions-jvm/language/integration-test/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java +++ b/integration-test-groups/foundation/language/src/test/java/org/apache/camel/quarkus/component/language/it/LanguageTest.java @@ -18,17 +18,33 @@ package org.apache.camel.quarkus.component.language.it; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; +import io.restassured.http.ContentType; +import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; @QuarkusTest class LanguageTest { @Test - public void loadComponentLanguage() { - /* A simple autogenerated test */ - RestAssured.get("/language/load/component/language") + public void languageSimpleScript() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("Dolly") + .post("/language/route/languageSimpleScript") .then() - .statusCode(200); + .statusCode(200) + .body(Matchers.is("Hello Dolly from simple language script")); + } + + @Test + public void languageSimpleResource() { + RestAssured.given() + .contentType(ContentType.TEXT) + .body("Molly") + .post("/language/route/languageSimpleResource") + .then() + .statusCode(200) + .body(Matchers.is("Hello Molly from simple language resource")); } } diff --git a/integration-test-groups/foundation/pom.xml b/integration-test-groups/foundation/pom.xml index 13420c8..3d46e7e 100644 --- a/integration-test-groups/foundation/pom.xml +++ b/integration-test-groups/foundation/pom.xml @@ -45,6 +45,7 @@ <module>customized-log-component</module> <module>direct</module> <module>eip</module> + <module>language</module> <module>log</module> <module>mock</module> <module>ref</module> diff --git a/integration-tests/foundation-grouped/pom.xml b/integration-tests/foundation-grouped/pom.xml index 5c3a46c..f0bbe6c 100644 --- a/integration-tests/foundation-grouped/pom.xml +++ b/integration-tests/foundation-grouped/pom.xml @@ -93,6 +93,10 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-language</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log</artifactId> </dependency> <dependency> @@ -221,6 +225,19 @@ </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-language-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-log-deployment</artifactId> <version>${project.version}</version> <type>pom</type> diff --git a/tooling/scripts/group-tests.groovy b/tooling/scripts/group-tests.groovy index 98e34ee..02eba77 100644 --- a/tooling/scripts/group-tests.groovy +++ b/tooling/scripts/group-tests.groovy @@ -34,9 +34,11 @@ import groovy.ant.AntBuilder final Path sourceDir = Paths.get(properties['group-tests.source.dir']) final String[] concatRelPaths = properties['group-tests.concat.rel.paths'].split('[\\s,]+') final Path destinationModuleDir = Paths.get(properties['group-tests.dest.module.dir']) +/* Property names whose values originating from distinct application.properties files can be concatenated using comma as a separator */ +final Set<String> commaConcatenatePropertyNames = ["quarkus.native.resources.includes", "quarkus.native.resources.excludes"] as Set; final Map<String, ResourceConcatenator> mergedFiles = new HashMap<>() -concatRelPaths.each {relPath -> mergedFiles.put(relPath, new ResourceConcatenator()) } +concatRelPaths.each {relPath -> mergedFiles.put(relPath, new ResourceConcatenator(commaConcatenatePropertyNames)) } Files.list(sourceDir) .filter { p -> Files.exists(p.resolve('pom.xml')) } @@ -69,7 +71,11 @@ class ResourceConcatenator { private final StringBuilder sb = new StringBuilder() private final Properties props = new Properties() private final List<Path> visitedPaths = new ArrayList<>() + private final Set<String> commaConcatenatePropertyNames; + public ResourceConcatenator(Set<String> commaConcatenatePropertyNames) { + this.commaConcatenatePropertyNames = commaConcatenatePropertyNames; + } public ResourceConcatenator append(Path path) { if (Files.exists(path)) { if (path.getFileName().toString().endsWith(".properties")) { @@ -79,10 +85,15 @@ class ResourceConcatenator { } newProps.each { key, val -> if (props.containsKey(key) && !props.get(key).equals(val)) { - throw new IllegalStateException("Conflicting property value "+ key +" = "+ val +": found in "+ path + " conflicting with some of " + visitedPaths); + if (commaConcatenatePropertyNames.contains(key)) { + props.put(key, props.get(key) + "," + val); + } else { + throw new IllegalStateException("Conflicting property value "+ key +" = "+ val +": found in "+ path + " conflicting with some of " + visitedPaths); + } + } else { + props.put(key, val); } } - props.putAll(newProps) } else { sb.append(path.getText('UTF-8') + '\n') }