[JPS] Ignore classpath from facets to exclude jars from gradle build
Reimport after `./gradlew build` adds jars from gradle's `build/libs` to facet's classpath. That causes problems with JPS build, because it doesn't see changes in out folder, but see unchanged jar, so changes don't apply. #KT-51873 Fixed Merge-request: KT-MR-6018 Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
This commit is contained in:
committed by
Space
parent
e0029b14ee
commit
bdf229bc5c
@@ -175,6 +175,7 @@ class KotlinFacetSettings {
|
||||
if (compilerSettings != null) {
|
||||
parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this)
|
||||
}
|
||||
if (this is K2JVMCompilerArguments) this.classpath = ""
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
@@ -71,6 +71,8 @@ import java.io.FileNotFoundException
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.net.URLClassLoader
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.*
|
||||
import java.util.zip.ZipOutputStream
|
||||
|
||||
@@ -986,6 +988,31 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() {
|
||||
checkWhen(emptyArray(), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt"))
|
||||
}
|
||||
|
||||
fun testBuildAfterGdwBuild() {
|
||||
initProject(JVM_FULL_RUNTIME)
|
||||
findModule("module2").let {
|
||||
val facet = KotlinFacetSettings()
|
||||
facet.useProjectSettings = false
|
||||
facet.compilerArguments = K2JVMCompilerArguments()
|
||||
|
||||
val libraryName = "module1-1.0-SNAPSHOT"
|
||||
val libraryJar = MockLibraryUtilExt.compileJvmLibraryToJar(workDir.resolve("module1AsLib").absolutePath, libraryName)
|
||||
val module1Lib = this.workDir.resolve("module1").resolve("build").resolve("libs").resolve("$libraryName.jar")
|
||||
Files.createDirectories(module1Lib.parentFile.toPath())
|
||||
Files.copy(libraryJar.toPath(), module1Lib.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||
|
||||
assert(module1Lib.exists())
|
||||
(facet.compilerArguments as K2JVMCompilerArguments).classpath = module1Lib.path
|
||||
|
||||
it.container.setChild(
|
||||
JpsKotlinFacetModuleExtension.KIND,
|
||||
JpsKotlinFacetModuleExtension(facet)
|
||||
)
|
||||
}
|
||||
|
||||
buildAllModules().assertSuccessful()
|
||||
}
|
||||
|
||||
private fun BuildResult.checkErrors() {
|
||||
val actualErrors = getMessages(BuildMessage.Kind.ERROR)
|
||||
.map { it as CompilerMessage }
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
<resourceExtensions />
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="CopyrightManager" default="">
|
||||
<module2copyright />
|
||||
</component>
|
||||
<component name="DependencyValidationManager">
|
||||
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
|
||||
</component>
|
||||
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/module1/module1.iml" filepath="$PROJECT_DIR$/module1/module1.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/module2/module2.iml" filepath="$PROJECT_DIR$/module2/module2.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
abstract class Base {
|
||||
abstract fun doSmth()
|
||||
abstract fun doSmthElse()
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
abstract class Base {
|
||||
abstract fun doSmth()
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="module1" />
|
||||
</component>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class Derived: Base() {
|
||||
override fun doSmth() {
|
||||
println("doSmth")
|
||||
}
|
||||
|
||||
override fun doSmthElse() {
|
||||
println("doSmthElse")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user