Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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: 72 additions & 1 deletion 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 @@ -350,7 +362,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 Expand Up @@ -419,7 +431,13 @@
<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 All @@ -430,6 +448,59 @@
</execution>
</executions>
</plugin>
<!-- Check if code generation can be skipped by comparing input/output timestamps -->

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the build generates a warning:

Some problems were encountered while building the effective model for org.quickfixj:quickfixj-messages-all:jar:3.0.0-SNAPSHOT
'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin org.apache.maven.plugins:maven-antrun-plugin @ line 452, column 12

Please correct that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in commit 78b7121. Consolidated the two maven-antrun-plugin declarations into a single plugin with three executions, eliminating the duplicate declaration warning.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin-version}</version>
<executions>
<!-- 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.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
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
Loading