Skip to content

Commit f934e95

Browse files
Fix gradle-plugin compile on clean CI builds with shadow enabled.
Wire processor classes directly into compile classpaths instead of a project dependency that resolves to an unavailable shadow artifact, and run check before publish in the Test job. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 3b79546 commit f934e95

3 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎.github/workflows/build.yml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,11 @@ jobs:
6262
distribution: temurin
6363
java-version: 17
6464

65+
- name: Build lightsaber modules
66+
run: ./gradlew -p lightsaber check -Plightsaber.shadow.enabled=true -Pdevelopment=false -Dkotlin.incremental=false
67+
6568
- name: Publish bootstrap artifacts
66-
run: ./gradlew -p lightsaber publishToMavenLocal -Plightsaber.shadow.enabled=true -Pdevelopment=false
69+
run: ./gradlew -p lightsaber publishToMavenLocal -Plightsaber.shadow.enabled=true -Pdevelopment=false -Dkotlin.incremental=false
6770

6871
- name: Run integration tests
6972
uses: reactivecircus/android-emulator-runner@v2

‎lightsaber/gradle-plugin/build.gradle‎

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ shadow {
3131
}
3232

3333
dependencies {
34-
implementation project(':processor')
3534
implementation "org.jetbrains.kotlin:kotlin-stdlib$kotlinRuntimeVariant:$kotlinVersion"
3635

3736
compileOnly gradleApi()
@@ -77,6 +76,24 @@ sourceSets {
7776
}
7877
}
7978

79+
def processorCompileClasses = {
80+
def processor = project(':processor')
81+
[processor, processor.layout.buildDirectory.dir('classes/kotlin/main'), processor.tasks.named('classes')]
82+
}
83+
84+
// Shadow packaging replaces the processor project dependency, but compile tasks still need its classes.
85+
tasks.named('compileKotlin', KotlinCompile).configure { compileTask ->
86+
def (processor, processorClasses, processorClassesTask) = processorCompileClasses()
87+
compileTask.dependsOn(processorClassesTask)
88+
compileTask.libraries.from(processorClasses)
89+
}
90+
91+
tasks.named('compileJava').configure { compileTask ->
92+
def (processor, processorClasses, processorClassesTask) = processorCompileClasses()
93+
compileTask.dependsOn(processorClassesTask)
94+
compileTask.classpath += processor.files(processorClasses)
95+
}
96+
8097
tasks.matching { it instanceof AbstractCompile || it instanceof KotlinCompile }.configureEach {
8198
dependsOn tasks.generateBuildClass
8299
}

‎lightsaber/gradle-plugin/src/main/java/com/joom/lightsaber/plugin/LightsaberTransform.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class LightsaberTransform(
7373
classpath = invocation.referencedInputs.flatMap {
7474
it.jarInputs.map { it.file.toPath() } + it.directoryInputs.map { it.file.toPath() }
7575
},
76-
modulesClasspath = emptyList(),
76+
modulesClasspath = emptyList<Path>(),
7777
bootClasspath = extension.bootClasspath.map { it.toPath() },
7878
projectName = invocation.context.path.replace(":transformClassesWithLightsaberFor", ":").replace(':', '$'),
7979
validateUsage = extension.validateUsage ?: validateUsageByDefault,

0 commit comments

Comments
 (0)