Skip to content

Use Kotlin's documented Maven setup to compile Kotlin before Java #881

Closed

Description

@oryan-block

We get Kotlin compiled before javac by binding the Kotlin executions to earlier phases: compile runs at process-sources, and since #879 test-compile runs at process-test-sources. #879 needed that so ResolverMethodsTest.java could call the Kotlin assertEveryFieldResolves helper. Without it, javac compiled the Java tests before any Kotlin test class existed.

It works, but it isn't how Kotlin's docs say to do it. The Maven guide has two options:

  • <extensions>true</extensions> on kotlin-maven-plugin, declared before maven-compiler-plugin. It adds the Kotlin executions itself, and the docs say not to configure the compiler plugin's executions with it.
  • Keep the Kotlin executions at compile / test-compile, set default-compile and default-testCompile to <phase>none</phase>, and add java-compile / java-test-compile executions after Kotlin.

Do this after the Java 17 bump in 15.0.0 (Jackson 3 needs it, #810). The bump removes the two things that made the second option look like the better fit:

  • The java17-tests profile and its java17-test-compile execution go away, since src/test/java17 can move into the regular test sources.
  • The useModulePath=false override on default-testCompile should go too. Its comment blames javac before Java 16 ignoring the module descriptors of multi-release jars, which doesn't apply with release 17. Not verified yet though.

So the first option is probably the simplest one at that point. Either way module-info.java and the release profile's source and javadoc jars have to keep working.

No behaviour change, it's build cleanup only.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions