Maven compiler plugin question

The maven guide in the official documentation says to configure the maven compiler plugin definition as follows when using kotlin:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
    <!-- Replacing default-compile as it is treated specially by maven -->
    <execution>
        <id>default-compile</id>
        <phase>none</phase>
    </execution>
    <!-- Replacing default-testCompile as it is treated specially by maven -->
    <execution>
        <id>default-testCompile</id>
        <phase>none</phase>
    </execution>
    <execution>
        <id>java-compile</id>
        <phase>compile</phase>
        <goals> <goal>compile</goal> </goals>
    </execution>
    <execution>
        <id>java-test-compile</id>
        <phase>test-compile</phase>
        <goals> <goal>testCompile</goal> </goals>
    </execution>
 </executions>

However, the Maven quick start at ktor.io doesn’t seem to have this.

I don’t know Maven too well, can someone explain what is the purpose of the above plugin xml and if it really is needed for using kotlin?

The maven guide offers two ways configuring Kotlin in a project: for compiling Kotlin-only codebase and for compiling mixed Kotlin-Java codebase where Kotlin code can call Java code and vice versa.

You have quoted the second one, while Ktor quick start suggests the first one, assuming your Ktor based project will start as Kotlin only.

i see.
could you please also explain what exactly is the plugin configuration doing here.

Eg:

<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
    <id>default-testCompile</id>
    <phase>none</phase>
</execution>

what does treated specially stand for here and what is it being replaced by?

Also:

<execution>
        <id>java-compile</id>
        <phase>compile</phase>
        <goals> <goal>compile</goal> </goals>
    </execution>
    <execution>
        <id>java-test-compile</id>
        <phase>test-compile</phase>
        <goals> <goal>testCompile</goal> </goals>
    </execution>

this seems like it is calling the goal that the plugin would call by default. does it still need to be specified? or am i wrong?

Also is it possible to replace the version string of the plugin with a generic maven property to denote the current version of maven?

The idea is to disable default compile execution and introduce our own to get control over the order in which goals are executed, so that we could run kotlin compiler before java compiler.

See this PR Add maven example without using process-sources by ansell · Pull Request #458 · JetBrains/kotlin-web-site · GitHub for details.

Also is it possible to replace the version string of the plugin with a generic maven property to denote the current version of maven?

I’m not sure which plugin do you mean, but usually each plugin in maven gets its own versioning which isn’t aligned with the versioning of maven itself.