Skip to content

Latest commit

 

History

History
172 lines (140 loc) · 5.65 KB

README.md

File metadata and controls

172 lines (140 loc) · 5.65 KB

Quick start

  1. Add to your pom.xml:

        <build>
            <plugins>
                <!-- other plugins... -->
                
                <plugin>
                    <groupId>io.timeandspace</groupId>
                    <artifactId>jpsg-maven-plugin</artifactId>
                    <version>1.4</version>
                    <executions>
                        <execution>
                            <id>jpsg</id>
                            <goals>
                                <goal>jpsg</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
  2. Create file CharIterator.java in src/main/javaTemplates/mypackage directory:

    package mypackage;
    
    import java.util.Iterator;
    
    public interface CharIterator extends Iterator<Character> {
    
        char nextChar();
    }
  3. Run mvn compile

  4. [For IntelliJ users] Right click on pom.xml in project explorer → Maven → Reimport

  5. Open target/generated-sources/jpsg/mypackage directory in project explorer and enjoy ByteIterator..DoubleIterator specializations!

See the JPSG repository for more info about how to use the generator.

Configuration

defaultTypes

For all template files without /* with */ blocks in the beginning JPSG attempts to deduce dimensions from the name of the template file, taking possible options from this defaultTypes configuration. See more details in the section about /* with */ blocks in JPSG tutorial.

Type: String.
Format: <javaTypeOptions>.
Default value: byte|char|short|int|long|float|double.

Example:

<configuration>
  <defaultTypes>int|long|float|double</defaultTypes>
</configuration>
sourceDirectory

The source directory which JPSG traverses and considers all files in it as template files.

Type: File.
Default value: ${basedir}/src/main/javaTemplates.

You can generate test sources by using multiple plugin executions and build-helper-maven-plugin, see an example in jpsg-maven-plugin-test/pom.xml.

targetDirectory

The target directory where JPSG puts specialized sources.

Type: File.
Default value: ${project.build.directory}/generated-sources/jpsg.

jpsg-maven-plugin-test/pom.xml includes an example of setting a different target directory for a JPSG execution.

never

For all dimensions defined in the beginnings of template files in /* with */ blocks, or deduced automatically by JPSG (see defaultTypes configuration above), or defined inside template files at any level of nesting, JPSG will skip generating code for the specified options.

Type: List<String>.
Format: <options>.
Default value: none (empty list).

Examples:

<configuration>
  <never>
    <never>byte|short|char</never>
    <never>Assert</never>
  </never>
</configuration>

Alternative:

<configuration>
  <never>byte|short|char|Assert</never>
</configuration>
excludes

JPSG doesn't generate specialization files for dimension contexts (either determined by /* with */ blocks in the beginnings of the template files, or deduced using defaultTypes) that match any of the conditions configured via excludes. See more details in the description of the equivalent method JpsgTask.exclude() for the JPSG Gradle plugin.

Type: List<String>.
Format: <simple-condition>.
Default value: none (empty list).

Example:

<configuration>
  <excludes>
    <exclude>object key byte|short|char|object value</exclude>
    <exclude>byte key short|char value</exclude>
    <exclude>Disabled extraChecks Enabled advancedStatistics</exclude>
  </excludes>
</configuration>
with

JPSG adds the provided dimensions to the generation contexts in each template file. Each dimension must have a single option. See more details in the description of the equivalent method JpsgTask.with() for the JPSG Gradle plugin.

Type: List<String>.
Format: <dimensions>. Every dimension must have only a single option.
Default value: none (empty list).

Examples:

<configuration>
  <with>
    <with>Enabled extraChecks Disabled advancedStatistics</with>
    <with>Assert extraCheckStyle</with>
    <with>java8 minSupportedJavaVersion</with>
  </with>
</configuration>

Alternative:

<configuration>
  <with>Enabled extraChecks Disabled advancedStatistics Assert extraCheckStyle java8 minSupportedJavaVersion</with>
</configuration>

Requirements

Maven 3.0 or newer, OpenJDK 1.8 or newer as the Maven's runtime