Skip to content

Wrapper for IBM Record Generator to provide a simple API for Java source code generation. Including a Maven Plugin to automation generation at build time

License

Notifications You must be signed in to change notification settings

provinzial/ibm-copybook-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IBM-Copybook-Generator Maven Plugin

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)

Usage

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>
  1. Path to your ADATA File

  2. Specify the generate goal to be executed

  3. Add the IBM Record Generator dependency

  4. Add the ibmjzos depencency

Usage with multiple copybooks in ADATA File

<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>
  1. Path to your ADATA File

  2. Name of the Record in your Cobol data devision

  3. Specify the generate goal to be executed

  4. Path to your ADATA File

  5. Name of the Record in your Cobol data devision

  6. Specify the generate goal to be executed

  7. Add the IBM Record Generator dependency

  8. Add the ibmjzos depencency

Configuration

The following configuration parameters are available:

adataFile

Used to specify the input ADATA file that is generated by the IBM Enterprise COBOL for z/OS® compiler from the COBOL copybook.

outputDir

Specifies the output directory path where the generated Java class is created. DEFAULT: ${project.build.directory}/generated-sources/copybook

symbol

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.

packageName

Used to specify the Java package name that is used in the generated output source.

className

Used to specify the Java class name for the generated output source.

generateSetters

Used to toggle setter generation. DEFAULT: true

generateCache

Used to toggle generation of instance variables and code to cache the value of fields. DEFAULT: true

useBufferOffset

Used to toggle generate code that allows the Java record to be mapped to a non-zero offset in a byte array. DEFAULT: false

stringTrim

Used to toggle enerate code that trims spaces from the end of String fields as they are accessed. DEFAULT: false

stringEncoding

Set to an alternative single-byte EBCDIC code page that is used for String fields. DEFAULT: IBM-1047

preInitialize

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

generateAccessorJavadoc

Used to toggle Javadoc comments to be generated for field getter and setter methods. DEFAULT: false

generateProtectedFields

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

ignoreOccurs1

Used to toggle ignore OCCURS 1 clauses so that indexed accessors are not generated for these degenerate cases. DEFAULT: false

nameGenerator

Specifies the namegenerator to use. DAFAULT: com.ibm.recordgen.cobol.JavaNameGenerator

removeIncrementOffset

Used to toggle removale of factory.incrementOffset blocks from generated java class. DEFAULT: true

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.

About

Wrapper for IBM Record Generator to provide a simple API for Java source code generation. Including a Maven Plugin to automation generation at build time

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages