JS: Use the same output paths for JPS and Maven-based builds
#KT-22586 Fixed
Original commit: ae37cc30a1
This commit is contained in:
@@ -262,6 +262,13 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
return list.toTypedArray()
|
||||
}
|
||||
|
||||
fun testKotlinJavaScriptProjectWithCustomOutputPaths() {
|
||||
initProject(JS_STDLIB)
|
||||
buildAllModules().assertSuccessful()
|
||||
|
||||
checkOutputFilesList(File(workDir, "target"))
|
||||
}
|
||||
|
||||
fun testKotlinJavaScriptProjectWithSourceMap() {
|
||||
initProject(JS_STDLIB)
|
||||
buildAllModules().assertSuccessful()
|
||||
@@ -686,7 +693,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
|
||||
}
|
||||
|
||||
private fun checkOutputFilesList() {
|
||||
private fun checkOutputFilesList(outputDir: File = productionOutputDir) {
|
||||
if (!expectedOutputFile.exists()) {
|
||||
expectedOutputFile.writeText("")
|
||||
throw IllegalStateException("$expectedOutputFile did not exist. Created empty file.")
|
||||
@@ -694,7 +701,7 @@ open class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
|
||||
val sb = StringBuilder()
|
||||
val p = Printer(sb, " ")
|
||||
productionOutputDir.printFilesRecursively(p)
|
||||
outputDir.printFilesRecursively(p)
|
||||
|
||||
UsefulTestCase.assertSameLinesWithFile(expectedOutputFile.canonicalPath, sb.toString(), true)
|
||||
}
|
||||
|
||||
@@ -115,4 +115,18 @@ class JpsKotlinCompilerSettings : JpsElementBase<JpsKotlinCompilerSettings>() {
|
||||
}
|
||||
|
||||
val JpsModule.targetPlatform: TargetPlatformKind<*>?
|
||||
get() = kotlinFacetExtension?.settings?.targetPlatformKind
|
||||
get() = kotlinFacetExtension?.settings?.targetPlatformKind
|
||||
|
||||
val JpsModule.productionOutputFilePath: String?
|
||||
get() {
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return null
|
||||
if (facetSettings.useProjectSettings) return null
|
||||
return facetSettings.productionOutputPath
|
||||
}
|
||||
|
||||
val JpsModule.testOutputFilePath: String?
|
||||
get() {
|
||||
val facetSettings = kotlinFacetExtension?.settings ?: return null
|
||||
if (facetSettings.useProjectSettings) return null
|
||||
return facetSettings.testOutputPath
|
||||
}
|
||||
@@ -56,6 +56,8 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.jps.JpsKotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.jps.build.JpsJsModuleUtils.getOutputMetaFile
|
||||
import org.jetbrains.kotlin.jps.incremental.*
|
||||
import org.jetbrains.kotlin.jps.productionOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.testOutputFilePath
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCache
|
||||
import org.jetbrains.kotlin.load.kotlin.incremental.components.IncrementalCompilationComponents
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
@@ -681,7 +683,9 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
|
||||
|
||||
val representativeModule = representativeTarget.module
|
||||
val moduleName = representativeModule.name
|
||||
val outputFile = JpsJsModuleUtils.getOutputFile(outputDir, moduleName, representativeTarget.isTests)
|
||||
val isTests = representativeTarget.isTests
|
||||
val explicitOutputPath = if (isTests) representativeModule.testOutputFilePath else representativeModule.productionOutputFilePath
|
||||
val outputFile = explicitOutputPath?.let { File(it) } ?: JpsJsModuleUtils.getOutputFile(outputDir, moduleName, isTests)
|
||||
val libraries = JpsJsModuleUtils.getLibraryFilesAndDependencies(representativeTarget)
|
||||
val compilerSettings = JpsKotlinCompilerSettings.getCompilerSettings(representativeModule)
|
||||
val k2JsArguments = JpsKotlinCompilerSettings.getK2JsCompilerArguments(representativeModule)
|
||||
|
||||
+7
-2
@@ -34,6 +34,8 @@ import org.jetbrains.jps.model.module.JpsSdkDependency
|
||||
import org.jetbrains.kotlin.build.JvmSourceRoot
|
||||
import org.jetbrains.kotlin.config.IncrementalCompilation
|
||||
import org.jetbrains.kotlin.jps.build.JpsUtils.getAllDependencies
|
||||
import org.jetbrains.kotlin.jps.productionOutputFilePath
|
||||
import org.jetbrains.kotlin.jps.testOutputFilePath
|
||||
import org.jetbrains.kotlin.modules.KotlinModuleXmlBuilder
|
||||
import org.jetbrains.kotlin.modules.TargetId
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
@@ -161,8 +163,11 @@ object KotlinBuilderModuleScriptGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
fun getOutputDirSafe(target: ModuleBuildTarget): File =
|
||||
target.outputDir ?: throw ProjectBuildException("No output directory found for " + target)
|
||||
fun getOutputDirSafe(target: ModuleBuildTarget): File {
|
||||
val explicitOutputPath = if (target.isTests) target.module.testOutputFilePath else target.module.productionOutputFilePath
|
||||
val explicitOutputDir = explicitOutputPath?.let { File(it).absoluteFile.parentFile }
|
||||
return explicitOutputDir ?: target.outputDir ?: throw ProjectBuildException("No output directory found for " + target)
|
||||
}
|
||||
|
||||
fun getProductionModulesWhichInternalsAreVisible(from: ModuleBuildTarget): List<JpsModule> {
|
||||
if (!from.isTests) return emptyList()
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
my_js/
|
||||
lib/
|
||||
kotlin.js
|
||||
kotlin.meta.js
|
||||
myproject/
|
||||
root-package.kjsm
|
||||
myproject.js
|
||||
myproject.meta.js
|
||||
my_test-js/
|
||||
lib/
|
||||
kotlin.js
|
||||
kotlin.meta.js
|
||||
myproject-tests/
|
||||
root-package.kjsm
|
||||
myproject-tests.js
|
||||
myproject-tests.meta.js
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JavaScript " useProjectSettings="false">
|
||||
<productionOutputPath>$MODULE_DIR$/target/my_js/myproject.js</productionOutputPath>
|
||||
<testOutputPath>$MODULE_DIR$/target/my_test-js/myproject-tests.js</testOutputPath>
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="sourceMapPrefix" value="" />
|
||||
<option name="sourceMapEmbedSources" value="inlining" />
|
||||
<option name="pluginOptions">
|
||||
<array />
|
||||
</option>
|
||||
<option name="pluginClasspaths">
|
||||
<array />
|
||||
</option>
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="kotlinProject" />
|
||||
</component>
|
||||
</module>
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<option name="DEFAULT_COMPILER" value="Javac" />
|
||||
</component>
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.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>
|
||||
</project>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun main(args: Array<String>) {
|
||||
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun test() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user