Search code examples
javamavenjaxbmaven-plugin

Add jvm options to maven plugin execution


Is it possible to force any maven plugin to execute with VM arguments when I do mvn clean install?

More context
I have an old project that I try to mirgate to java 11. During this migration I had trouble with wadl-client-plugin and JAXB showing this error.

schema_reference: Failed to read schema document '...', because 'file' access is not allowed due to restriction set by the accessExternalSchema property.

When I run it like mvn clean install -Djavax.xml.accessExternalSchema=all it works. I need to include somehow -Djavax.xml.accessExternalSchema=all to the plugin execution when I run mvn clean install. I've checked wadl-client-plugin's docs and don't see anything about it. Is it possible to do it somehow in general way? Configuring local JVM is not an option neither as I cannot do it at all machines.


Solution

  • I finally found an answer here

    properties-maven-plugin inside my pom did the trick.

    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0.0</version>
        <executions>
            <execution>
                <id>set-additional-system-properties</id>
                <goals>
                    <goal>set-system-properties</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <properties>
               <property>
                    <name>javax.xml.accessExternalSchema</name>
                    <value>all</value>
                </property>
            </properties>
            <outputFile/>
        </configuration>
    </plugin>