Skip to content

Commit

Permalink
Merge pull request #153 from sophiegreen/master
Browse files Browse the repository at this point in the history
Allow bundle parts directory to be configurable and add integration test
  • Loading branch information
sophiegreen authored Jul 21, 2020
2 parents be21e93 + b08ff71 commit ea6cb13
Show file tree
Hide file tree
Showing 14 changed files with 196 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<define>` 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 `<define>` element added to the CICS bundle's `cics.xml`.
The location of the bundle parts directory can be configured by using the `<bundlePartsDirectory>` property. The configured directory is relative to `src/main/`.

## Create a CICS bundle (from an existing Java module) using `cics-bundle-maven-plugin`

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!--
#%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%
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.ibm.cics.test-reactor-bundlePartDirectory</groupId>
<artifactId>test-reactor-bundlePartDirectory</artifactId>
<version>0.0.1-SNAPSHOT</version>

<packaging>pom</packaging>

<modules>
<module>test-bundle</module>
</modules>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.ibm.cics.cbmp.PostBuildBundlePartDirectory.assertOutput(basedir);
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!--
#%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%
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.ibm.cics.test-reactor-bundlePartDirectory</groupId>
<artifactId>test-reactor-bundlePartDirectory</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>test-bundle</artifactId>
<packaging>cics-bundle</packaging>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<extensions>true</extensions>
<configuration>
<defaultjvmserver>EYUCMCIJ</defaultjvmserver>
<bundlePartsDirectory>differentDirectory</bundlePartsDirectory>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:eventBinding CICSEPSchemaVersion="2" CICSEPSchemaRelease="0" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding CicsEventBinding.xsd " xmlns:ns2="http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description></description>
<userTag></userTag>
<eventAdapterName></eventAdapterName>
</ns2:eventBinding>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><cicsdefinitionprogram jvm="NO" name="PROG1WrongDir" xmlns="http://www.ibm.com/xmlns/prod/CICS/smw2int"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<cicsdefinitionurimap xmlns="http://www.ibm.com/xmlns/prod/CICS/smw2int"
hfsfile="/u/niced/blah"
host="winmvs28.hursley.ibm.com"
mediatype="text/html"
name="mymap"
path="my/path/"
usage="SERVER" />
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this file should have no file extension.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns2:eventBinding CICSEPSchemaVersion="2" CICSEPSchemaRelease="0" xsi:schemaLocation="http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding CicsEventBinding.xsd " xmlns:ns2="http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<description></description>
<userTag></userTag>
<eventAdapterName></eventAdapterName>
</ns2:eventBinding>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><cicsdefinitionprogram jvm="NO" name="PROG1" xmlns="http://www.ibm.com/xmlns/prod/CICS/smw2int"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<cicsdefinitionurimap xmlns="http://www.ibm.com/xmlns/prod/CICS/smw2int"
hfsfile="/u/niced/blah"
host="winmvs28.hursley.ibm.com"
mediatype="text/html"
name="mymap"
path="my/path/"
usage="SERVER" />
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
this file should have no file extension.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public abstract class AbstractAutoConfigureBundlePublisherMojo extends AbstractB
*/
@Parameter(required = false)
protected List<BundlePartBinding> 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() {
Expand All @@ -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)) {
Expand Down Expand Up @@ -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");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n" +
"<manifest xmlns=\"http://www.ibm.com/xmlns/prod/cics/bundle\" bundleMajorVer=\"0\" bundleMicroVer=\"1\" bundleMinorVer=\"0\" bundleRelease=\"0\" bundleVersion=\"1\" id=\"test-bundle\">\n" +
" <meta_directives>\n" +
" <timestamp>2019-09-11T21:12:17.023Z</timestamp>\n" +
" </meta_directives>\n" +
" <define name=\"PROG1\" path=\"PROG1.program\" type=\"http://www.ibm.com/xmlns/prod/cics/bundle/PROGRAM\"/>\n" +
" <define name=\"EventBinding\" path=\"EventBinding.evbind\" type=\"http://www.ibm.com/xmlns/prod/cics/bundle/EVENTBINDING\"/>\n" +
" <define name=\"mymap\" path=\"mymap.urimap\" type=\"http://www.ibm.com/xmlns/prod/cics/bundle/URIMAP\"/>\n" +
"</manifest>"
),
bfv(
EVBIND_BUNDLEPART,
is -> assertThat(
is,
CompareMatcher.isIdenticalTo(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n" +
"<ns2:eventBinding CICSEPSchemaVersion=\"2\" CICSEPSchemaRelease=\"0\" " +
"xsi:schemaLocation=\"http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding CicsEventBinding.xsd \" " +
"xmlns:ns2=\"http://www.ibm.com/xmlns/prod/cics/eventprocessing/eventbinding\" " +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
" <description></description>\n" +
" <userTag></userTag>\n" +
" <eventAdapterName></eventAdapterName>\n" +
"</ns2:eventBinding>"
)
)
),
bfv(
URIMAP_BUNDLEPART,
is -> {}
),
bfv(
PROGRAM_BUNDLEPART,
is -> {}
),
bfv(
NOEXTENSION_FILE,
is -> {}
)
);

}


}

0 comments on commit ea6cb13

Please sign in to comment.