Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ abstract class AbstractKotlinSymbolProcessingExtension(
}
processor?.also { deferredSymbols[it] = mutableListOf() }
}
/* Kotlin compiler expects a source dir to exist, but processors might not generate Kotlin source.
Create it during initialization just in case. */
options.kotlinOutputDir.mkdirs()
initialized = true
}
if (!logger.hasError()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.google.devtools.ksp.test

import org.gradle.testkit.runner.GradleRunner
import org.junit.Rule
import org.junit.Test

class OnlyResourcesFileIT {
@Rule
@JvmField
val project: TemporaryTestProject = TemporaryTestProject("only-resources-file")

@Test
fun test() {
val gradleRunner = GradleRunner.create().withProjectDir(project.root)

gradleRunner.withArguments(
"--configuration-cache-problems=warn",
"jvmJar",
).build()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
kotlin("multiplatform") apply false
}

val testRepo: String by project
subprojects {
repositories {
maven(testRepo)
mavenCentral()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap/")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
pluginManagement {
val kotlinVersion: String by settings
val kspVersion: String by settings
val testRepo: String by settings
plugins {
id("com.google.devtools.ksp") version kspVersion apply false
kotlin("multiplatform") version kotlinVersion apply false
}
repositories {
maven(testRepo)
gradlePluginPortal()
maven("https://maven.pkg.jetbrains.space/kotlin/p/kotlin/bootstrap/")
}
}

rootProject.name = "playground"

include(":workload")
include(":test-processor")
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
val kspVersion: String by project

plugins {
kotlin("jvm")
}

group = "com.example"
version = "1.0-SNAPSHOT"

dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:$kspVersion")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.*

class TestProcessor(val codeGenerator: CodeGenerator) : SymbolProcessor {

var invoked = false

override fun process(resolver: Resolver): List<KSAnnotated> {
if (invoked) {
return emptyList()
}

codeGenerator.createNewFile(Dependencies(false), "", "HelloSwift", "swift")

invoked = true
return emptyList()
}

class Provider : SymbolProcessorProvider {
override fun create(
environment: SymbolProcessorEnvironment
): SymbolProcessor = TestProcessor(environment.codeGenerator)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TestProcessor$Provider
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
plugins {
kotlin("multiplatform")
id("com.google.devtools.ksp")
}

version = "1.0-SNAPSHOT"

kotlin {
jvm {
withJava()
}
}

dependencies {
add("kspCommonMainMetadata", project(":test-processor"))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class MyStub