@@ -44,221 +44,16 @@ Before you start, make sure you have:
4444 <tab title="Maven" group-key="maven">
4545
4646 ```xml
47- <?xml version="1.0" encoding="UTF-8"?>
48- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
49- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
50- <modelVersion>4.0.0</modelVersion>
51-
52- <groupId>org.jetbrains.kotlin</groupId>
53- <artifactId>kotlin-junit-complete</artifactId>
54- <version>1.0-SNAPSHOT</version>
55-
56- <name>kotlin-junit-complete</name>
57- <url>https://kotlinlang.org/docs/jvm-test-using-junit.htm</url>
58-
59- <properties>
60- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
61- <maven.compiler.release>17</maven.compiler.release>
62- <jexer.version>1.6.0</jexer.version>
63- <kotlin.version>%kotlinVersion%</kotlin.version>
64- </properties>
65-
66- <dependencyManagement>
67- <dependencies>
68- <dependency>
69- <groupId>org.junit</groupId>
70- <artifactId>junit-bom</artifactId>
71- <version>5.11.0</version>
72- <type>pom</type>
73- <scope>import</scope>
74- </dependency>
75- </dependencies>
76- </dependencyManagement>
77-
78- <dependencies>
79- <dependency>
80- <groupId>org.junit.jupiter</groupId>
81- <artifactId>junit-jupiter-api</artifactId>
82- <scope>test</scope>
83- </dependency>
84- <!-- JUnit Jupiter engine is required at test runtime -->
85- <dependency>
86- <groupId>org.junit.jupiter</groupId>
87- <artifactId>junit-jupiter-engine</artifactId>
88- <scope>test</scope>
89- </dependency>
90- <!-- Optionally: parameterized tests support -->
91- <dependency>
92- <groupId>org.junit.jupiter</groupId>
93- <artifactId>junit-jupiter-params</artifactId>
94- <scope>test</scope>
95- </dependency>
96- <!-- Kotlin standard library needed to compile/run Kotlin tests -->
97- <dependency>
98- <groupId>org.jetbrains.kotlin</groupId>
99- <artifactId>kotlin-stdlib</artifactId>
100- <version>${kotlin.version}</version>
101- <scope>test</scope>
102- </dependency>
103- <dependency>
104- <groupId>com.gitlab.klamonte</groupId>
105- <artifactId>jexer</artifactId>
106- <version>${jexer.version}</version>
107- </dependency>
108- </dependencies>
109-
110- <build>
111- <pluginManagement><!-- lock down plugin versions to avoid using Maven defaults (can be moved to a parent pom file) -->
112- <plugins>
113- <!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
114- <plugin>
115- <artifactId>maven-clean-plugin</artifactId>
116- <version>3.4.0</version>
117- </plugin>
118- <!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
119- <plugin>
120- <artifactId>maven-resources-plugin</artifactId>
121- <version>3.3.1</version>
122- </plugin>
123- <plugin>
124- <artifactId>maven-surefire-plugin</artifactId>
125- <version>3.3.0</version>
126- </plugin>
127- <plugin>
128- <artifactId>maven-jar-plugin</artifactId>
129- <version>3.4.2</version>
130- </plugin>
131- <plugin>
132- <artifactId>maven-install-plugin</artifactId>
133- <version>3.1.2</version>
134- </plugin>
135- <plugin>
136- <artifactId>maven-deploy-plugin</artifactId>
137- <version>3.1.2</version>
138- </plugin>
139- <!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
140- <plugin>
141- <artifactId>maven-site-plugin</artifactId>
142- <version>3.12.1</version>
143- </plugin>
144- <plugin>
145- <artifactId>maven-project-info-reports-plugin</artifactId>
146- <version>3.6.1</version>
147- </plugin>
148-
149- <!-- KOTLIN -->
150- <plugin>
151- <groupId>org.jetbrains.kotlin</groupId>
152- <artifactId>kotlin-maven-plugin</artifactId>
153- <version>${kotlin.version}</version>
154- <extensions>true
155- </extensions> <!-- You can set this option to automatically take information about lifecycles -->
156- <executions>
157- <execution>
158- <id>compile</id>
159- <goals>
160- <goal>compile</goal> <!-- You can skip the <goals> element if you enable extensions for the plugin -->
161- </goals>
162- <configuration>
163- <sourceDirs>
164- <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
165- <sourceDir>${project.basedir}/src/main/java</sourceDir>
166- </sourceDirs>
167- </configuration>
168- </execution>
169- <execution>
170- <id>test-compile</id>
171- <goals>
172- <goal>test-compile</goal> <!-- You can skip the <goals> element if you enable extensions for the plugin -->
173- </goals>
174- <configuration>
175- <sourceDirs>
176- <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
177- <sourceDir>${project.basedir}/src/test/java</sourceDir>
178- </sourceDirs>
179- </configuration>
180- </execution>
181- </executions>
182- </plugin>
183- <plugin>
184- <groupId>org.apache.maven.plugins</groupId>
185- <artifactId>maven-compiler-plugin</artifactId>
186- <version>3.14.0</version>
187- <executions>
188- <!-- Replacing default-compile as it's treated specifically by Maven -->
189- <execution>
190- <id>default-compile</id>
191- <phase>none</phase>
192- </execution>
193- <!-- Replacing default-testCompile as it's treated specifically by Maven -->
194- <execution>
195- <id>default-testCompile</id>
196- <phase>none</phase>
197- </execution>
198- <execution>
199- <id>java-compile</id>
200- <phase>compile</phase>
201- <goals>
202- <goal>compile</goal>
203- </goals>
204- </execution>
205- <execution>
206- <id>java-test-compile</id>
207- <phase>test-compile</phase>
208- <goals>
209- <goal>testCompile</goal>
210- </goals>
211- </execution>
212- </executions>
213- </plugin>
214- </plugins>
215- </pluginManagement>
216- <plugins>
217- <!-- Activate Kotlin compiler for main and test sources -->
218- <plugin>
219- <groupId>org.jetbrains.kotlin</groupId>
220- <artifactId>kotlin-maven-plugin</artifactId>
221- <version>${kotlin.version}</version>
222- <extensions>true</extensions>
223- <executions>
224- <execution>
225- <id>compile</id>
226- <goals>
227- <goal>compile</goal>
228- </goals>
229- <configuration>
230- <sourceDirs>
231- <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
232- <sourceDir>${project.basedir}/src/main/java</sourceDir>
233- </sourceDirs>
234- </configuration>
235- </execution>
236- <execution>
237- <id>test-compile</id>
238- <goals>
239- <goal>test-compile</goal>
240- </goals>
241- <configuration>
242- <sourceDirs>
243- <sourceDir>${project.basedir}/src/test/kotlin</sourceDir>
244- <sourceDir>${project.basedir}/src/test/java</sourceDir>
245- </sourceDirs>
246- </configuration>
247- </execution>
248- </executions>
249- </plugin>
250- </plugins>
251- </build>
252- </project>
25347 ```
254- { initial-collapse-state="collapsed" collapsible="true" collapsed-title="pom.xml file"}
48+ {src="jvm-test-tutorial/pom.xml" initial-collapse-state="collapsed" collapsible="true" collapsed-title="pom.xml file"}
25549
25650 * In the `<properties>` section, set the Kotlin version.
257- * In the `<dependencies>` section, add the `kotlin-stdlib` dependency to compile and run Kotlin tests.
258- * In the `<pluginManagement>` section, add and configure the `kotlin-maven-plugin` plugin.
259- * In the `<pluginManagement>` section, configure the `maven-compiler-plugin` plugin to disable default compile phases,
260- and compile Java after Kotlin.
261- * In the `<plugins>` section, add the `kotlin-maven-plugin`.
51+ * In the `<dependencies>` section, add JUnit Jupiter dependencies and the `kotlin-stdlib` (test scope) to compile and
52+ run Kotlin tests.
53+ * In the `<build><plugins>` section, apply `kotlin-maven-plugin` with `extensions` enabled and configure `compile`
54+ and `test-compile` executions with `sourceDirs` for both Kotlin and Java.
55+ * You don't need to add `maven-compiler-plugin` to the `<build><pluginManagement>` section when using the Kotlin
56+ Maven plugin with extensions.
26257
26358 </tab>
26459 <tab title="Gradle" group-key="gradle">
0 commit comments