Skip to content

Commit b06b18d

Browse files
Set destination to null when module is set in JPS
This fixes the warning "The '-d' option with a directory destination is ignored because '-module' is specified", when a project imported from Gradle is built with JPS. #KT-17665 fixed
1 parent 5fbb41b commit b06b18d

File tree

5 files changed

+54
-0
lines changed

5 files changed

+54
-0
lines changed

jps-plugin/jps-tests/test/org/jetbrains/kotlin/jps/build/KotlinJpsBuildTest.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,20 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
915915
buildAllModules().assertSuccessful()
916916
}
917917

918+
fun testCustomDestination() {
919+
loadProject(workDir.absolutePath + File.separator + PROJECT_NAME + ".ipr")
920+
addKotlinRuntimeDependency()
921+
buildAllModules().apply {
922+
assertSuccessful()
923+
924+
val aClass = File(workDir, "customOut/A.class")
925+
assert(aClass.exists()) { "$aClass does not exist!" }
926+
927+
val warnings = getMessages(BuildMessage.Kind.WARNING)
928+
assert(warnings.isEmpty()) { "Unexpected warnings: \n${warnings.joinToString("\n")}" }
929+
}
930+
}
931+
918932
private fun BuildResult.checkErrors() {
919933
val actualErrors = getMessages(BuildMessage.Kind.ERROR)
920934
.map { it as CompilerMessage }

jps-plugin/src/org/jetbrains/kotlin/compilerRunner/JpsKotlinCompilerRunner.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ class JpsKotlinCompilerRunner : KotlinCompilerRunner<JpsCompilerEnvironment>() {
198198
private fun setupK2JvmArguments(moduleFile: File, settings: K2JVMCompilerArguments) {
199199
with(settings) {
200200
module = moduleFile.absolutePath
201+
destination = null
201202
noStdlib = true
202203
noReflect = true
203204
noJdk = true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="kotlin-language" name="Kotlin">
5+
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
6+
<compilerSettings />
7+
<compilerArguments>
8+
<option name="destination" value="$MODULE_DIR$/customOut/" />
9+
</compilerArguments>
10+
</configuration>
11+
</facet>
12+
</component>
13+
<component name="NewModuleRootManager">
14+
<output url="$MODULE_DIR$/customOut/"/>
15+
16+
<exclude-output />
17+
<content url="file://$MODULE_DIR$">
18+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
19+
</content>
20+
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
21+
<orderEntry type="sourceFolder" forTests="false" />
22+
<orderEntry type="module" module-name="kotlinProject" />
23+
</component>
24+
</module>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project version="4">
3+
<component name="CompilerConfiguration">
4+
<option name="DEFAULT_COMPILER" value="Javac" />
5+
</component>
6+
<component name="ProjectModuleManager">
7+
<modules>
8+
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
9+
</modules>
10+
</component>
11+
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
12+
<output url="file://$PROJECT_DIR$/out" />
13+
</component>
14+
</project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class A

0 commit comments

Comments
 (0)