Skip to content

Commit d7cbffc

Browse files
mipo256koshachy
authored andcommitted
Clarified documentation for kotlin compilation with maven plugin
(cherry picked from commit 308a66c)
1 parent b8c8e9e commit d7cbffc

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

docs/topics/maven.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,10 @@ making sure that the `kotlin` plugin comes before the `maven-compiler-plugin` in
182182
<artifactId>maven-compiler-plugin</artifactId>
183183
<version>3.5.1</version>
184184
<executions>
185-
<!-- Replacing default-compile as it is treated specially by Maven -->
186185
<execution>
187186
<id>default-compile</id>
188187
<phase>none</phase>
189188
</execution>
190-
<!-- Replacing default-testCompile as it is treated specially by Maven -->
191189
<execution>
192190
<id>default-testCompile</id>
193191
<phase>none</phase>
@@ -212,6 +210,29 @@ making sure that the `kotlin` plugin comes before the `maven-compiler-plugin` in
212210
</build>
213211
```
214212

213+
There are a couple of notes to make here. First, since Maven 3.0.3, the plugins that bound to the same phase have specific execution order.
214+
In particular, if plugin `A` is bind to phase `compile` and plugin `B` is bind to phase `compile`, then whoever is executed first is resolved by
215+
their declaration order in the `pom.xml`. It simply means if `A` is declared before `B` in `pom.xml`, the `A` will be executed prior to `B`. However,
216+
the built-in plugins native executions, like for plugins `maven-compiler-plugin`, `maven-jar-plugin` e.t.c are executed first regardless of their
217+
order in `pom.xml`. Their execution ids are typically named `default-_someting_`.
218+
219+
Therefore, by specifying the following execution for `maven-compiler-plugin`:
220+
221+
```
222+
<execution>
223+
<id>default-compile</id>
224+
<phase>none</phase>
225+
</execution>
226+
<execution>
227+
<id>default-testCompile</id>
228+
<phase>none</phase>
229+
</execution>
230+
```
231+
232+
we're effectively disabling the default executions of `maven-compiler-plugin`. Please, note, that usage of phase 'none' is just a well-known workaround for
233+
disabling the particualr execution of plugin in Maven. By disabling `default-compile` and `default-testCompile` executions, the new executions `java-compile`
234+
and not treated as predefined, therefore, and hence the `kotlin-maven-plugin`, as it is declared first, takes precedence.
235+
215236
## Enable incremental compilation
216237

217238
To make your builds faster, you can enable incremental compilation by adding the `kotlin.compiler.incremental` property:

0 commit comments

Comments
 (0)