logo

Using CTC++ with Maven

12 April 2021

Using Testwell CTC++ with Maven

To use Testwell CTC++ you have to supply a small wrapper script and point Maven to that external compiler

The wrapper

As we can't prepend (only append) options to the compiler call, we pass them for simplicity in the script directly.

Following as mvnctc executable in $PATH
#!/bin/sh
exec javactc -i m javac $*

Or following as mvnctc.bat in your %PATH%
call javactc -i m javac %*

Integrate in pom.xml

At the beginning where the maven-compiler-plugin is stored.

Add inside configuration

<fork>true</fork>>
<executable>mvnctc</executable>

More complete example here

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <verbose>true</verbose>
                    <fork>true</fork>
                    <executable>mvnctc</executable>
                </configuration>
            </plugin>

Building

Build your project as usual. You can set fork to false to disable Testwell CTC++ usage.
This is applicable to Maven 2 and higher (currently Maven 3)