From b08ff7191fefe983b129203a159363cbc1179b03 Mon Sep 17 00:00:00 2001 From: Sophie Green Date: Tue, 21 Jul 2020 17:35:23 +0100 Subject: [PATCH] Allow bundle parts directory to be configurable and add integration test Signed-off-by: Sophie Green --- README.md | 3 +- .../test-reactor-bundlePartDirectory/pom.xml | 27 ++++++ .../postbuild.bsh | 1 + .../test-bundle/pom.xml | 40 +++++++++ .../bundleParts/EventBindingWrongDir.evbind | 6 ++ .../main/bundleParts/PROG1WrongDir.program | 1 + .../src/main/bundleParts/mymapWrongDir.urimap | 8 ++ .../src/main/bundleParts/noextensionWrongDir | 1 + .../differentDirectory/EventBinding.evbind | 6 ++ .../src/main/differentDirectory/PROG1.program | 1 + .../src/main/differentDirectory/mymap.urimap | 8 ++ .../src/main/differentDirectory/noextension | 1 + ...tractAutoConfigureBundlePublisherMojo.java | 11 ++- .../cbmp/PostBuildBundlePartDirectory.java | 84 +++++++++++++++++++ 14 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/pom.xml create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/postbuild.bsh create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/pom.xml create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/EventBindingWrongDir.evbind create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/PROG1WrongDir.program create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/mymapWrongDir.urimap create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/noextensionWrongDir create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/EventBinding.evbind create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/PROG1.program create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/mymap.urimap create mode 100644 cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/noextension create mode 100644 cics-bundle-maven-plugin/src/test/java/com/ibm/cics/cbmp/PostBuildBundlePartDirectory.java diff --git a/README.md b/README.md index 86b0c87d..109ef159 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,8 @@ To create a CICS bundle in this way: The generated CICS bundle takes its bundle ID from the Maven module's `artifactId` and its version from the Maven module's `version`. -1. To include CICS bundleparts like FILE or URIMAP, put the bundlepart files in your bundle Maven module's bundleParts directory, for instance `src/main/bundleParts`. Files in your Maven module's bundleParts directory will be included within the output CICS bundle, and supported types will have a `` element added to the CICS bundle's `cics.xml`. +1. To include CICS bundleparts like FILE or URIMAP, put the bundlepart files in your bundle Maven module's bundle parts directory, for instance `src/main/bundleParts`. Files in your Maven module's bundle parts directory will be included within the output CICS bundle, and supported types will have a `` element added to the CICS bundle's `cics.xml`. +The location of the bundle parts directory can be configured by using the `` property. The configured directory is relative to `src/main/`. ## Create a CICS bundle (from an existing Java module) using `cics-bundle-maven-plugin` diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/pom.xml b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/pom.xml new file mode 100644 index 00000000..5dc262b5 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/pom.xml @@ -0,0 +1,27 @@ + + + 4.0.0 + + com.ibm.cics.test-reactor-bundlePartDirectory + test-reactor-bundlePartDirectory + 0.0.1-SNAPSHOT + + pom + + + test-bundle + + + diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/postbuild.bsh b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/postbuild.bsh new file mode 100644 index 00000000..325bf415 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/postbuild.bsh @@ -0,0 +1 @@ +com.ibm.cics.cbmp.PostBuildBundlePartDirectory.assertOutput(basedir); diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/pom.xml b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/pom.xml new file mode 100644 index 00000000..c86877bd --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/pom.xml @@ -0,0 +1,40 @@ + + + 4.0.0 + + com.ibm.cics.test-reactor-bundlePartDirectory + test-reactor-bundlePartDirectory + 0.0.1-SNAPSHOT + + + test-bundle + cics-bundle + + + + + @project.groupId@ + @project.artifactId@ + @project.version@ + true + + EYUCMCIJ + differentDirectory + + + + + + diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/EventBindingWrongDir.evbind b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/EventBindingWrongDir.evbind new file mode 100644 index 00000000..74efafc9 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/EventBindingWrongDir.evbind @@ -0,0 +1,6 @@ + + + + + + diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/PROG1WrongDir.program b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/PROG1WrongDir.program new file mode 100644 index 00000000..13d9e37a --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/PROG1WrongDir.program @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/mymapWrongDir.urimap b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/mymapWrongDir.urimap new file mode 100644 index 00000000..b6cbc006 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/mymapWrongDir.urimap @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/noextensionWrongDir b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/noextensionWrongDir new file mode 100644 index 00000000..327e6dbd --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/bundleParts/noextensionWrongDir @@ -0,0 +1 @@ +this file should have no file extension. \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/EventBinding.evbind b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/EventBinding.evbind new file mode 100644 index 00000000..74efafc9 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/EventBinding.evbind @@ -0,0 +1,6 @@ + + + + + + diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/PROG1.program b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/PROG1.program new file mode 100644 index 00000000..1d69dc18 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/PROG1.program @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/mymap.urimap b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/mymap.urimap new file mode 100644 index 00000000..b6cbc006 --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/mymap.urimap @@ -0,0 +1,8 @@ + + \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/noextension b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/noextension new file mode 100644 index 00000000..327e6dbd --- /dev/null +++ b/cics-bundle-maven-plugin/src/it/test-reactor-bundlePartDirectory/test-bundle/src/main/differentDirectory/noextension @@ -0,0 +1 @@ +this file should have no file extension. \ No newline at end of file diff --git a/cics-bundle-maven-plugin/src/main/java/com/ibm/cics/cbmp/AbstractAutoConfigureBundlePublisherMojo.java b/cics-bundle-maven-plugin/src/main/java/com/ibm/cics/cbmp/AbstractAutoConfigureBundlePublisherMojo.java index 06c838c4..09440e3a 100644 --- a/cics-bundle-maven-plugin/src/main/java/com/ibm/cics/cbmp/AbstractAutoConfigureBundlePublisherMojo.java +++ b/cics-bundle-maven-plugin/src/main/java/com/ibm/cics/cbmp/AbstractAutoConfigureBundlePublisherMojo.java @@ -48,6 +48,14 @@ public abstract class AbstractAutoConfigureBundlePublisherMojo extends AbstractB */ @Parameter(required = false) protected List bundleParts = Collections.emptyList(); + + /** + * The directory containing bundle parts to be included in the CICS bundle. + * This path is relative to `src/main/` + * Specifying this parameter overrides the default path of `bundleParts`. + */ + @Parameter(property = "cicsbundle.bundlePartsDirectory", defaultValue = "bundleParts", required = false) + private String bundlePartsDirectory; @Override public String getJVMServer() { @@ -65,7 +73,7 @@ protected void initBundlePublisher(BundlePublisher bundlePublisher) throws MojoE private void addStaticBundleResources(BundlePublisher bundlePublisher) throws MojoExecutionException { //Add bundle parts for any resources Path basePath = baseDir.toPath(); - Path bundlePartSource = basePath.resolve("src/main/bundleParts"); + Path bundlePartSource = basePath.resolve("src/main/" + bundlePartsDirectory); getLog().info("Gathering bundle parts from " + basePath.relativize(bundlePartSource)); if (Files.exists(bundlePartSource)) { @@ -94,6 +102,7 @@ private void addStaticBundleResources(BundlePublisher bundlePublisher) throws Mo } } else { //Ignore if it doesn't exist + getLog().info("No non-Java-based bundle parts to add, because bundle parts directory '" + bundlePartsDirectory + "' does not exist"); } } diff --git a/cics-bundle-maven-plugin/src/test/java/com/ibm/cics/cbmp/PostBuildBundlePartDirectory.java b/cics-bundle-maven-plugin/src/test/java/com/ibm/cics/cbmp/PostBuildBundlePartDirectory.java new file mode 100644 index 00000000..4a5d0a36 --- /dev/null +++ b/cics-bundle-maven-plugin/src/test/java/com/ibm/cics/cbmp/PostBuildBundlePartDirectory.java @@ -0,0 +1,84 @@ +package com.ibm.cics.cbmp; +/*- + * #%L + * CICS Bundle Maven Plugin + * %% + * Copyright (C) 2020 IBM Corp. + * %% + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * #L% + */ + +import static com.ibm.cics.cbmp.BundleValidator.assertBundleContents; +import static com.ibm.cics.cbmp.BundleValidator.bfv; +import static com.ibm.cics.cbmp.BundleValidator.manifestValidator; +import static org.junit.Assert.assertThat; + +import java.io.File; +import java.nio.file.Path; + +import org.xmlunit.matchers.CompareMatcher; + +public class PostBuildBundlePartDirectory { + + private static final String EVBIND_BUNDLEPART = "/EventBinding.evbind"; + private static final String URIMAP_BUNDLEPART = "/mymap.urimap"; + private static final String PROGRAM_BUNDLEPART = "/PROG1.program"; + private static final String NOEXTENSION_FILE = "/noextension"; + + static void assertOutput(File root) throws Exception { + + Path cicsBundle = root.toPath().resolve("test-bundle/target/test-bundle-0.0.1-SNAPSHOT.zip"); + + assertBundleContents( + cicsBundle, + manifestValidator( + "\n" + + "\n" + + " \n" + + " 2019-09-11T21:12:17.023Z\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "" + ), + bfv( + EVBIND_BUNDLEPART, + is -> assertThat( + is, + CompareMatcher.isIdenticalTo( + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "" + ) + ) + ), + bfv( + URIMAP_BUNDLEPART, + is -> {} + ), + bfv( + PROGRAM_BUNDLEPART, + is -> {} + ), + bfv( + NOEXTENSION_FILE, + is -> {} + ) + ); + + } + + +}