General way to set JVM args in pom.xml independent from plugin used

140 Views Asked by At

I have a Maven project which generates code with the help of the org.codehaus.mojo.xml-maven-plugin (version 1.0.2) by using XSLT transformation.

However, when run it exceeds the XPath operator limit of 100:

JAXP0801002: the compiler encountered an XPath expression containing '101' operators that exceeds the '100' limit set by 'FEATURE_SECURE_PROCESSING'.

I know I can get around this by setting -Djdk.xml.xpathExprOpLimit=500 on the command line. But is there a way to set this in a general place in the pom.xml?

I know that some plugins like surefire have this possibility. But what about plugins that don't? Is there a way to achieve this in the POM without having to specify it on the command line on each run?

Apache Maven 3.6.3
Java version: 11.0.19, vendor: Ubuntu, runtime: /usr/lib/jvm/java-11-openjdk-amd64

The full POM file could be found here: https://github.com/david-gibbs-ig/quickfixj/blob/9eff0b69f90ef205ace736bc7fa32784fe3185f3/quickfixj-base/pom.xml#L75

Relevant section:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xml-maven-plugin</artifactId>
    <executions>
        <execution>
        <id>extractRequiredFields</id>
        <phase>generate-sources</phase>
        <goals>
            <goal>transform</goal>
        </goals>
        <configuration>
            <transformationSets>
                <transformationSet>
                    <dir>${project.basedir}/../quickfixj-orchestration/target/generated-resources</dir>
                    <outputDir>${project.build.directory}/generated-resources/extracted</outputDir>
                    <includes>
                        <include>${orchestra.file}</include>
                    </includes>
                    <stylesheet>${project.basedir}/src/main/xsl/extractRequiredFields.xsl</stylesheet>
                </transformationSet>
            </transformationSets>
        </configuration>
    </execution>
</plugin>
1

There are 1 best solutions below

0
On

Not exactly what I was asking for in the original question, but I have now achieved a similar thing by setting the desired options in the .mvn/jvm.config file. The file is checked into the repo and retrieved on checkout so Maven considers the file without needing changes to the environment of the user.