Skip to content

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

Open

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.

The second one probably fits better, since we already configure default-testCompile (useModulePath=false, with a TODO for 15.0.0) and the java17-tests profile adds its own java17-test-compile execution. Both have to keep working, along with module-info.java and the release profile's source and javadoc jars.

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