Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

groovy-eclipse-compiler should implement javax.tools.JavaCompiler #1592

Open
kwin opened this issue Aug 7, 2024 · 4 comments
Open

groovy-eclipse-compiler should implement javax.tools.JavaCompiler #1592

kwin opened this issue Aug 7, 2024 · 4 comments
Assignees
Labels

Comments

@kwin
Copy link

kwin commented Aug 7, 2024

The upcoming m-compiler-p will get rid of the Plexus Compiler layer but instead directly call javax.tools.JavaCompiler. Further information in https://lists.apache.org/thread/qvrmzmd10plsssrgj4s3f27ytfjxkwfr. In order to use the groovy-eclipse-compiler with the new m-compiler-p it needs to implement javax.tools.JavaCompiler instead of Plexus Compiler classes.
The latter should be considered deprecated nowadays.

This in addition has the advantage of getting rid of a third party abstraction and being usable also outside the m-compiler-p.

@eric-milles
Copy link
Member

Is there a guide for moving from org.codehaus.plexus.compiler.AbstractCompiler to javax.tools.JavaCompiler.

I was looking through your post and github site but didn't find anything about how the new API works. I tried to have maven-plugin-api as the only dependency (dropping maven-core). But I could not see how to do something simple like adding a source folder.

Is this possible via API:

@Mojo(name = "add-groovy-build-paths", defaultPhase = LifecyclePhase.INITIALIZE, requiresProject = true, threadSafe = true)
public class AddGroovySourceFolders extends AbstractMojo {

    @Parameter(defaultValue = "${project}", readonly = true, required = true)
    private org.apache.maven.project.MavenProject project;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        var logger = org.slf4j.LoggerFactory.getLogger(getClass());
        logger.info("Adding /src/main/groovy to the list of source folders");
        project.addCompileSourceRoot(project.getBasedir() + "/src/main/groovy");
        logger.info("Adding /src/test/groovy to the list of test source folders");
        project.addTestCompileSourceRoot(project.getBasedir() + "/src/test/groovy");
    }
}

@eric-milles eric-milles self-assigned this Aug 9, 2024
@kwin
Copy link
Author

kwin commented Aug 10, 2024

@eric-milles
Copy link
Member

Thanks for the links. In order to test, can I use maven-compiler-plugin 4.0.0-beta-1 or do I need something more recent?

@kwin
Copy link
Author

kwin commented Aug 10, 2024

For now you need to build https://github.com/Geomatys/maven-compiler-plugin on your own. The changes are not yet merged upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants