This is a maven-plugin that automates the java codegeneration from COBOL Copybooks.
It uses the IBM Record Generator to generate java source code.
Additionally to the IBM Record Generator this plugin removes all static {factory.incrementOffset(<int>)}
blocks from the generated code,
because these blocks prevent the generated class from reading and writing the underlaying byte[] properly. The offset will always be 0
if these blocks don´t get removed. (I don´t know if this is a known problem but it happens on several jdk distributions)
This is a minimal example how to use the plugin:
<build>
<plugins>
...
<plugin>
<groupId>com.provinzial</groupId>
<artifactId>ibm-copybook-generator-maven-plugin</artifactId>
<version>1.0.1</version>
<configuration>
<adataFile>${project.basedir}/src/main/resources/adata/example.adata</adataFile> <!--(1)-->
</configuration>
<executions>
<execution>
<goals>
<goal>generate</goal> <!--(2)-->
</goals>
</execution>
</executions>
<dependencies>
<dependency> <!--(3)-->
<groupId>com.ibm</groupId>
<artifactId>recgen</artifactId>
<version>3.0.1</version>
</dependency>
<dependency> <!--(4)-->
<groupId>com.ibm</groupId>
<artifactId>ibmjzos</artifactId>
<version>2.4.8</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>
-
Path to your ADATA File
-
Specify the
generate
goal to be executed -
Add the IBM Record Generator dependency
-
Add the ibmjzos depencency
<build>
<plugins>
...
<plugin>
<groupId>com.provinzial</groupId>
<artifactId>ibm-copybook-generator-maven-plugin</artifactId>
<version>1.0.1</version>
<executions>
<execution>
<id>generate-record1</id>
<configuration>
<adataFile>${project.basedir}/src/main/resources/adata/example.adata</adataFile> <!--(1)-->
<symbol>RECORD1-G</symbol> <!--(2)-->
</configuration>
<goals>
<goal>generate</goal> <!--(3)-->
</goals>
</execution>
<execution>
<id>generate-record2</id>
<configuration>
<adataFile>${project.basedir}/src/main/resources/adata/example.adata</adataFile> <!--(4)-->
<symbol>RECORD2-G</symbol> <!--(5)-->
</configuration>
<goals>
<goal>generate</goal> <!--(6)-->
</goals>
</execution>
</executions>
<dependencies>
<dependency> <!--(7)-->
<groupId>com.ibm</groupId>
<artifactId>recgen</artifactId>
<version>3.0.1</version>
</dependency>
<dependency> <!--(8)-->
<groupId>com.ibm</groupId>
<artifactId>ibmjzos</artifactId>
<version>2.4.8</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
</build>
-
Path to your ADATA File
-
Name of the Record in your Cobol data devision
-
Specify the
generate
goal to be executed -
Path to your ADATA File
-
Name of the Record in your Cobol data devision
-
Specify the
generate
goal to be executed -
Add the IBM Record Generator dependency
-
Add the ibmjzos depencency
The following configuration parameters are available:
Used to specify the input ADATA file that is generated by the IBM Enterprise COBOL for z/OS® compiler from the COBOL copybook.
Specifies the output directory path where the generated Java class is created.
DEFAULT: ${project.build.directory}/generated-sources/copybook
Used to specify the name of the first COBOL level 01 that is selected for generation. If not specified, the default is the first level 01 name found.
Used to toggle generation of instance variables and code to cache the value of fields. DEFAULT: true
Used to toggle generate code that allows the Java record to be mapped to a non-zero offset in a byte array. DEFAULT: false
Used to toggle enerate code that trims spaces from the end of String fields as they are accessed. DEFAULT: false
Set to an alternative single-byte EBCDIC code page that is used for String fields. DEFAULT: IBM-1047
Used to toggle generate code in the setInitalValues() method to initialize fields with a fixed location and length that are not arrays to blanks or zero. DEFAULT: false
Used to toggle Javadoc comments to be generated for field getter and setter methods. DEFAULT: false
Used to toggle static field variables to be generated with public access, rather than protected access. This is useful for dynamic modification of field behavior or testing. DEFAULT: true
Used to toggle ignore OCCURS 1 clauses so that indexed accessors are not generated for these degenerate cases. DEFAULT: false
Specifies the namegenerator to use. DAFAULT: com.ibm.recordgen.cobol.JavaNameGenerator
This projects uses the IBM Record Generator(license information) and IBM SDK for z/OS Java Technology Edition(license information) which are Property of IBM Corporation. To use this Plugin you need a proper Licence for the IBM Record Generator and IBM SDK for z/OS Java Technology Edition. Because of this the dependencies for recgen and ibmjzos are not distributed with this plugin and you need to provide this dependencies by yourself.
Everything else is under MIT Licence.