Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
<maven-deploy-plugin-version>3.1.4</maven-deploy-plugin-version>
<nexus-staging-maven-plugin-version>1.7.0</nexus-staging-maven-plugin-version>
<build-helper-maven-plugin-version>3.6.1</build-helper-maven-plugin-version>
<maven-antrun-plugin-version>3.2.0</maven-antrun-plugin-version>
<maven-shared-utils.version>3.4.2</maven-shared-utils.version>
<file-management.version>3.2.0</file-management.version>
<maven-plugin-annotations.version>3.15.2</maven-plugin-annotations.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ public class GenerateMojo extends AbstractMojo {
@Parameter(defaultValue = "true")
private boolean overwrite = true;

/**
* Skip the code generation if true.
* Useful for incremental builds when source files haven't changed.
*/
@Parameter(property = "codegen.skip", defaultValue = "false")
private boolean skip = false;

/**
* The Maven project to act upon.
*/
Expand All @@ -111,6 +118,11 @@ public class GenerateMojo extends AbstractMojo {
*/
public void execute() throws MojoExecutionException {

if (skip) {
getLog().info("Skipping code generation (codegen.skip = true)");
return;
}

if (!outputDirectory.exists()) {
FileUtils.mkdir(outputDirectory.getAbsolutePath());
}
Expand Down
73 changes: 71 additions & 2 deletions quickfixj-messages/quickfixj-messages-all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<excludeSession>true</excludeSession><!-- fixt11 has already been generated -->
<generateFixt11Package>false</generateFixt11Package>
<!-- Skip if codegen is up-to-date (same property as quickfixj-codegenerator) -->
<skip>${codegen.uptodate}</skip>
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -110,6 +112,8 @@
<outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
<excludeSession>true</excludeSession><!-- fixt11 has already been generated -->
<generateFixt11Package>false</generateFixt11Package>
<!-- Skip if codegen is up-to-date (same property as quickfixj-codegenerator) -->
<skip>${codegen.uptodate}</skip>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -247,6 +251,14 @@
<groupId>org.quickfixj</groupId>
<artifactId>quickfixj-codegenerator</artifactId>
<version>${project.version}</version>
<!--
Skip code generation if 'codegen.uptodate' is true.
This property is set by the build-helper-maven-plugin above based on
comparing timestamps of FIX XML inputs vs. generated Java sources.
-->
<configuration>
<skip>${codegen.uptodate}</skip>
</configuration>
<executions>
<execution>
<id>fix40</id>
Expand Down Expand Up @@ -346,13 +358,19 @@
</execution>
</executions>
</plugin>
<!-- exclude classes that are provided by the quickfixj-base dependency -->
<!--
Maven Ant Run Plugin - consolidates all Ant-based tasks:
1. Exclude classes provided by quickfixj-base dependency (process-sources phase)
2. Check if code generation can be skipped by comparing timestamps (initialize phase)
3. Create marker file after successful code generation (generate-sources phase)
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.2.0</version>
<version>${maven-antrun-plugin-version}</version>
<executions>
<execution>
<id>delete-base-classes</id>
<phase>process-sources</phase>
<goals>
<goal>run</goal>
Expand Down Expand Up @@ -413,13 +431,64 @@
</target>
</configuration>
</execution>
<!-- Check if inputs are newer than marker file -->
<execution>
<id>check-codegen-uptodate</id>
<phase>initialize</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<!-- Check if marker file exists and is newer than all input XMLs -->
<uptodate property="codegen.uptodate"
targetfile="${project.build.directory}/codegen-marker.txt">
<srcfiles dir="${project.basedir}/.." includes="
quickfixj-messages-fix40/src/main/resources/FIX40.xml,
quickfixj-messages-fix41/src/main/resources/FIX41.xml,
quickfixj-messages-fix42/src/main/resources/FIX42.xml,
quickfixj-messages-fix43/src/main/resources/FIX43.xml,
quickfixj-messages-fix44/src/main/resources/FIX44.modified.xml,
quickfixj-messages-fix50/src/main/resources/FIX50.xml,
quickfixj-messages-fix50sp1/src/main/resources/FIX50SP1.modified.xml,
quickfixj-messages-fix50sp2/src/main/resources/FIX50SP2.modified.xml"/>
</uptodate>
<condition property="codegen.skip.message" value="Skipping code generation - inputs unchanged" else="">
<isset property="codegen.uptodate"/>
</condition>
<echo message="${codegen.skip.message}"/>
</target>
</configuration>
</execution>
<!-- Create marker file after successful code generation -->
<execution>
<id>create-codegen-marker-file</id>
<phase>generate-sources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<mkdir dir="${project.build.directory}"/>
<touch file="${project.build.directory}/codegen-marker.txt"/>
<echo message="Code generation completed - marker file updated"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<!--
Check if FIX specification XML files have changed since last code generation.
Uses Ant's uptodate task to compare timestamps of source XML files against
a marker file. Sets 'codegen.uptodate' property to true if marker is newer.
-->
<execution>
<id>add-source</id>
<phase>process-sources</phase>
<goals><goal>add-source</goal></goals>
<configuration>
Expand Down
2 changes: 1 addition & 1 deletion quickfixj-messages/quickfixj-messages-fixt11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.2.0</version>
<version>${maven-antrun-plugin-version}</version>
<executions>
<execution>
<phase>process-sources</phase>
Expand Down