GitXplorerGitXplorer
X

jcpp-maven-plugin

public
3 stars
0 forks
11 issues

Commits

List of commits on branch master.
Verified
1a3221a9ee02f00c24c38450b654759d7bd3cbf0

Merge pull request #112 from XenoAmess/dependabot/github_actions/master/actions/setup-java-4.1.0

ddependabot[bot] committed a year ago
Verified
c1c762e613de4e32ca501b49d2bddd40efad621f

Bump actions/setup-java from 4.0.0 to 4.1.0

ddependabot[bot] committed a year ago
Verified
1b5afa4c29365d67b9aff0ea686509a32056c13a

Merge pull request #111 from XenoAmess/dependabot/github_actions/master/actions/cache-4

XXenoAmess committed a year ago
Verified
fe4746fe53a924ec17190d752328e3284a6b2a04

Bump actions/cache from 3 to 4

ddependabot[bot] committed a year ago
Verified
73ebb569a1bcd1b1e5454d84acbb843d0c323166

Merge pull request #110 from XenoAmess/dependabot/maven/master/org.apache.maven.plugins-maven-plugin-plugin-3.11.0

ddependabot[bot] committed a year ago
Verified
3b744c741fda41f3fcf142cb5e219b3e24f34caf

Merge pull request #109 from XenoAmess/dependabot/maven/master/org.apache.maven.plugin-tools-maven-plugin-annotations-3.11.0

ddependabot[bot] committed a year ago

README

The README file for this repository.

jcpp-maven-plugin

Maven Central

jcpp-maven-plugin, A plugin for C pre processing in maven project.

Goal:

Use a c pre processor (org.anarres.jcpp) to process your java templates in a specified folder before build.

Usage:

  1. include it in your <build>
<build>
     <plugins>
         <plugin>
             <groupId>com.xenoamess</groupId>
             <artifactId>jcpp-maven-plugin</artifactId>
             <version>0.2.0</version>
             <executions>
                 <execution>
                     <id>preprocess-sources</id>
                     <phase>generate-sources</phase>
                     <goals>
                         <goal>preprocess-sources</goal>
                     </goals>
                     <configuration>
                         <sourceDirectory>
                             ${basedir}/src/main/java-templates
                         </sourceDirectory>
                         <outputDirectory>
                             ${project.build.directory}/generated-sources/src/main/java
                         </outputDirectory>
                         <libPaths>
                             <param>${basedir}/src/main/resources/templates
                             </param>
                         </libPaths>
                     </configuration>
                 </execution>
                 <execution>
                     <id>preprocess-test-sources</id>
                     <phase>generate-test-sources</phase>
                     <goals>
                         <goal>preprocess-test-sources</goal>
                     </goals>
                     <configuration>
                         <sourceDirectory>
                             ${basedir}/src/test/java-templates
                         </sourceDirectory>
                         <outputDirectory>
                             ${project.build.directory}/generated-test-sources/src/test/java
                         </outputDirectory>
                     </configuration>
                 </execution>
             </executions>
         </plugin>
     </plugins>
</build>
  1. write your code template. put source template code into <sourceDirectory> put additional libPaths for your template codes into <libPaths>

  2. mvn compile and get the result.

Params:

All params and their default value are listed here.

    @Parameter(defaultValue = "${basedir}/src/main/java-templates", property = "sourceDir", required = true)
    private File sourceDirectory;

    @Parameter(defaultValue = "${project.build.directory}/generated-sources/src/main/java", property = "outputDir",
            required = true)
    private File outputDirectory;

    @Parameter(property = "args")
    private String[] args;

    @Parameter(defaultValue = "${project.build.sourceEncoding}", property = "encoding")
    private String encoding;

    @Parameter(property = "libPaths")
    private String[] libPaths;
    
    @Parameter(defaultValue = "${project}")
    private MavenProject project;

sourceDirectory means a directory which contains your templates.

outputDirectory means a directory to put preprocessed outputDirectory.

args means additional args for org.anarres.jcpp.Main

encoding means encoding of your source files.

libPaths means additional libraries paths for preprocessing your templates. libPaths will be uniqued before the plugin use libPaths, so don't worry if you have duplicated strings in libPaths. sourceDirectory will always be added to libPaths automatically before the plugin use libPaths.

project means your project. I don't think it shall be changed but if you insisted, then you are free to do what you want.

Live Demo:

Projects using this: https://github.com/XenoAmess/commonx