What is the `compile[sourceSetName]KotlinOutputCla...
# gradle
w
What is the
compile[sourceSetName]KotlinOutputClasses
property that gets added to the
compile[sourceSetName]Java
task?
in my project that creates custom java sourcesets that use the output of main and test, and has the kotlin plugin applied, i get errors like
Copy code
A problem was found with the configuration of task ':otherlang:compileArchRequiredTestJava' (type 'JavaCompile').
> Directory '/tmp/junit3394081754501078923/otherlang/build/classes/kotlin/archRequiredTest' specified for property 'compileArchRequiredTestKotlinOutputClasses' does not exist.
archRequiredTest
is my sourceSet name
even if i do
Copy code
project.plugins.withId("org.jetbrains.kotlin.jvm") {
                    project.logger.error("HACK")
                    project.buildDir.resolve("classes").resolve("kotlin").resolve("archRequiredTest").mkdirs()
                }
i see HACK in the configuration phase build output, but stillg et the same error
i tried
project.extensions.findByType<KotlinJvmProjectExtension>()?.sourceSets?.removeIf { it.name == "archTest" }
but then I get
Copy code
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':test:compileArchTestKotlin'.
	at org.gradle.api.internal.tasks.DefaultTaskContainer.taskCreationException(DefaultTaskContainer.java:719)
...
Caused by: org.gradle.api.UnknownDomainObjectException: KotlinSourceSet with name 'archTest' not found.
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.createNotFoundException(DefaultNamedDomainObjectCollection.java:504)
	at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:333)
so its still trying to create the compile task fo rit
i ended up solving it with:
Copy code
abstract class GenerateFakeKotlinClassesDirTask : DefaultTask() {
    companion object {
        @JvmStatic
        fun create(project: Project, sourceSet: SourceSet): GenerateFakeKotlinClassesDirTask {
            val task = project.tasks.create<GenerateFakeKotlinClassesDirTask>("GenerateFake${sourceSet.name}KotlinClassesDirTask") {
                this.dir.set(project.buildDir.resolve("classes").resolve("kotlin").resolve(sourceSet.name))
            }
            project.afterEvaluate {
                project.tasks.findByName(sourceSet.compileJavaTaskName)!!.dependsOn(task)
            }
            return task
        }
    }

    @get:OutputDirectory
    abstract val dir: DirectoryProperty

    @TaskAction
    fun createDir() {
        val file = dir.get().asFile
        <http://logger.info|logger.info>("creating fake kotlin class dir at ${file.absolutePath}")
        file.mkdirs()
    }
}
r
Since KotlinCompile no longer extends SourceTasks in kotlin 1.7.+ . Is there a equivalent way to do KotlinCompile.source(Source) in 1.7?