Fix resources processing configuration
* Add resources processing to the K/N compilations * Use a proper resources output path (composed from target + compilation rather than just compilation name) * Fix incorrect reassignment of the resources directory
This commit is contained in:
+17
@@ -163,6 +163,23 @@ class NewMultiplatformIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testResourceProcessing() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||||
|
val targetsWithResources = listOf("jvm6", "wasm32", nativeHostTargetName)
|
||||||
|
val processResourcesTasks =
|
||||||
|
targetsWithResources.map { ":${it}ProcessResources" }
|
||||||
|
|
||||||
|
build(*processResourcesTasks.toTypedArray()) {
|
||||||
|
assertSuccessful()
|
||||||
|
assertTasksExecuted(*processResourcesTasks.toTypedArray())
|
||||||
|
|
||||||
|
targetsWithResources.forEach {
|
||||||
|
assertFileExists("build/processedResources/$it/main/commonMainResource.txt")
|
||||||
|
assertFileExists("build/processedResources/$it/main/${it}MainResource.txt")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testSourceSetCyclicDependencyDetection() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
fun testSourceSetCyclicDependencyDetection() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
resource
|
||||||
-5
@@ -125,11 +125,6 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
|||||||
) {
|
) {
|
||||||
val project = compilation.target.project
|
val project = compilation.target.project
|
||||||
|
|
||||||
compilation.output.setResourcesDir(Callable {
|
|
||||||
val classesDirName = "resources/" + compilation.compilationName
|
|
||||||
File(project.buildDir, classesDirName)
|
|
||||||
})
|
|
||||||
|
|
||||||
val resourcesTask = project.tasks.maybeCreate(compilation.processResourcesTaskName, ProcessResources::class.java)
|
val resourcesTask = project.tasks.maybeCreate(compilation.processResourcesTaskName, ProcessResources::class.java)
|
||||||
resourcesTask.description = "Processes $resourceSet."
|
resourcesTask.description = "Processes $resourceSet."
|
||||||
DslObject(resourcesTask).conventionMapping.map("destinationDir") { compilation.output.resourcesDir }
|
DslObject(resourcesTask).conventionMapping.map("destinationDir") { compilation.output.resourcesDir }
|
||||||
|
|||||||
+2
-1
@@ -10,13 +10,14 @@ import org.gradle.api.NamedDomainObjectFactory
|
|||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
|
||||||
|
import java.util.concurrent.Callable
|
||||||
|
|
||||||
interface KotlinCompilationFactory<T: KotlinCompilation> : NamedDomainObjectFactory<T> {
|
interface KotlinCompilationFactory<T: KotlinCompilation> : NamedDomainObjectFactory<T> {
|
||||||
val itemClass: Class<T>
|
val itemClass: Class<T>
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinTarget.createCompilationOutput(name: String) =
|
private fun KotlinTarget.createCompilationOutput(name: String) =
|
||||||
KotlinCompilationOutput(project, project.buildDir.resolve("processedResources/$name"))
|
KotlinCompilationOutput(project, Callable { project.buildDir.resolve("processedResources/$targetName/$name") })
|
||||||
|
|
||||||
class KotlinCommonCompilationFactory(
|
class KotlinCommonCompilationFactory(
|
||||||
val target: KotlinOnlyTarget<KotlinCommonCompilation>
|
val target: KotlinOnlyTarget<KotlinCommonCompilation>
|
||||||
|
|||||||
+3
-1
@@ -269,7 +269,7 @@ class KotlinNativeCompilation(
|
|||||||
override val target: KotlinNativeTarget,
|
override val target: KotlinNativeTarget,
|
||||||
name: String,
|
name: String,
|
||||||
override val output: SourceSetOutput
|
override val output: SourceSetOutput
|
||||||
) : AbstractKotlinCompilation(target, name) {
|
) : AbstractKotlinCompilation(target, name), KotlinCompilationWithResources {
|
||||||
|
|
||||||
private val project: Project
|
private val project: Project
|
||||||
get() = target.project
|
get() = target.project
|
||||||
@@ -369,6 +369,8 @@ class KotlinNativeCompilation(
|
|||||||
getBinary(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
getBinary(NativeOutputKind.valueOf(kind.toUpperCase()), NativeBuildType.valueOf(buildType.toUpperCase()))
|
||||||
|
|
||||||
// Naming
|
// Naming
|
||||||
|
override val processResourcesTaskName: String
|
||||||
|
get() = disambiguateName("processResources")
|
||||||
|
|
||||||
val linkAllTaskName: String
|
val linkAllTaskName: String
|
||||||
get() = lowerCamelCaseName(
|
get() = lowerCamelCaseName(
|
||||||
|
|||||||
Reference in New Issue
Block a user