# Maven compiler plugin question

**URL:** <https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260>\
**Category:** Web Development\
**Created:** [November 4, 2017, 12:30am UTC](https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260 "2017-11-04T00:30:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeva](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@pdeva](https://discuss.kotlinlang.org/u/pdeva)\
**Post date:** [November 4, 2017, 12:30am UTC](https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260/1 "2017-11-04T00:30:23Z")

</div>

The [maven guide in the official documentation](http://kotlinlang.org/docs/reference/using-maven.html) 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](http://ktor.io/quickstart/maven.html) 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?

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [November 4, 2017, 2:46am UTC](https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260/2 "2017-11-04T02:46:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![pdeva](https://avatars.discourse-cdn.com/v4/letter/p/e47c2d/32.png) [@pdeva](https://discuss.kotlinlang.org/u/pdeva)\
**Post date:** [November 4, 2017, 3:17am UTC](https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260/3 "2017-11-04T03:17:21Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![ilya.gorbunov](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/ilya.gorbunov/32/1645_2.png) [@ilya.gorbunov](https://discuss.kotlinlang.org/u/ilya.gorbunov)\
**Post date:** [November 4, 2017, 3:45am UTC](https://discuss.kotlinlang.org/t/maven-compiler-plugin-question/5260/4 "2017-11-04T03:45:38Z")

</div>

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](https://github.com/JetBrains/kotlin-web-site/pull/458) 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.
