Class "org.eclipse.jdt.internal.compiler.tool.EclipseCompiler" does
implement this interface (although I don't know if this is the exact class
that is used for compilation within Maven builds):
https://github.com/eclipse-jdt/eclipse.jdt.core/blob/8e630b6c235edaf7d6e757442b1ee2c5761b6021/org.eclipse.jdt.core.compiler.batch/src/org/eclipse/jdt/internal/compiler/tool/EclipseCompiler.java#L49

name() is a default method on javax.tools.Tool and this implementation
leaves it as-is, so it will return an empty String.

On Tue, Jul 23, 2024 at 10:40 AM Martin Desruisseaux <
martin.desruisse...@geomatys.com> wrote:

> 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
>
>
-- 
András

Reply via email to