Le 2024-07-23 à 05 h 20, Olivier Lamy a écrit :

How to use ecj with those changes? Or any other external tool by using the executable configuration?

The compiler needs to implement the following interface (I think it is the case of the Eclipse compiler, but didn't verified carefully):

   javax.tools.JavaCompiler

That interface inherits a name() method, which returns a String. That method needs to return a unique identifier. For the standard Java compiler, that identifier is "javac". The javax.tools specification recommends to use an identifier which is the same as the command invoked on the command-line.

Then, the following file must be present in the JAR file and shall contain the fully-qualified name of the JavaCompiler implementation (in the future, we should allow to replace that requirement by a module-info file).

   META-INF/services/javax.tools.Tool

Finally, in the maven-compiler-plugin configuration declared in the pom.xml file, the <compilerId> element shall contain the above-cited identifier. The maven-compiler-plugin iterates over the tools using java.util.ServiceLoader until it find a tool with a name matching the compilerId. This mechanism is tested in the JUnit tests with two `CompilerStub` implementations.

    Martin

Reply via email to