Skip to content

Commit 4dd6aee

Browse files
committed
Simplify Gradle cleanup
1 parent 86954b4 commit 4dd6aee

5 files changed

Lines changed: 35 additions & 54 deletions

File tree

build-logic/src/main/kotlin/com/sourcegraph/buildlogic/ScipCompile.kt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import java.io.File
44
import org.gradle.api.Task
55
import org.gradle.api.artifacts.Configuration
66
import org.gradle.api.file.Directory
7+
import org.gradle.api.file.FileSystemLocation
78
import org.gradle.api.provider.Provider
89
import org.gradle.api.tasks.compile.JavaCompile
910

@@ -26,6 +27,29 @@ fun JavaCompile.useScipJavac(
2627
(options.forkOptions.jvmArgs ?: emptyList()) + JavacInternals.jvmOptions(rootDir)
2728
}
2829

30+
/**
31+
* Builds the `kotlinc` arguments that load the scip-kotlinc compiler plugin from [pluginClasspath]
32+
* (the resolved shaded jar) and point it at [sourceroot]/[targetroot].
33+
*
34+
* The mapping lives here, in compiled build logic, rather than in a build script: a `.map {}`
35+
* lambda declared in a `.gradle.kts` file captures a hidden reference to the script object, which
36+
* the configuration cache cannot serialize.
37+
*/
38+
fun scipKotlincPluginArgs(
39+
pluginClasspath: Provider<Set<FileSystemLocation>>,
40+
sourceroot: String,
41+
targetroot: String,
42+
): Provider<List<String>> =
43+
pluginClasspath.map { locations ->
44+
listOf(
45+
"-Xplugin=${locations.single().asFile.absolutePath}",
46+
"-P",
47+
"plugin:scip-kotlinc:sourceroot=$sourceroot",
48+
"-P",
49+
"plugin:scip-kotlinc:targetroot=$targetroot",
50+
)
51+
}
52+
2953
/**
3054
* Registers a `doFirst` action that empties [dir] (deletes then recreates it) before the task runs.
3155
*

build-logic/src/main/kotlin/com/sourcegraph/buildlogic/SharedArtifacts.kt

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.sourcegraph.buildlogic
33
import org.gradle.api.Project
44
import org.gradle.api.artifacts.Configuration
55
import org.gradle.api.file.Directory
6-
import org.gradle.api.file.FileSystemLocation
76
import org.gradle.api.provider.Provider
87

98
/**
@@ -43,26 +42,3 @@ fun Project.publishDirectoryArtifact(
4342
val elements = configurations.consumable(name).get()
4443
artifacts.add(elements.name, directory) { builtBy(producedBy) }
4544
}
46-
47-
/**
48-
* Builds the `kotlinc` arguments that load the scip-kotlinc compiler plugin from [pluginClasspath]
49-
* (the resolved shaded jar) and point it at [sourceroot]/[targetroot].
50-
*
51-
* The mapping lives here, in compiled build logic, rather than in a build script: a `.map {}`
52-
* lambda declared in a `.gradle.kts` file captures a hidden reference to the script object, which
53-
* the configuration cache cannot serialize.
54-
*/
55-
fun scipKotlincPluginArgs(
56-
pluginClasspath: Provider<Set<FileSystemLocation>>,
57-
sourceroot: String,
58-
targetroot: String,
59-
): Provider<List<String>> =
60-
pluginClasspath.map { locations ->
61-
listOf(
62-
"-Xplugin=${locations.single().asFile.absolutePath}",
63-
"-P",
64-
"plugin:scip-kotlinc:sourceroot=$sourceroot",
65-
"-P",
66-
"plugin:scip-kotlinc:targetroot=$targetroot",
67-
)
68-
}

scip-aggregator/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import com.google.protobuf.gradle.ProtobufExtension
21
import com.google.protobuf.gradle.proto
32

43
plugins {

scip-snapshots/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ tasks.named<Test>("test") {
3333
tasks.register<JavaExec>("saveSnapshots") {
3434
group = "verification"
3535
description = "Regenerates Java and Kotlin SCIP snapshot goldens."
36-
dependsOn(tasks.named("classes"))
3736
inputs.files(javaTargetroot, kotlinTargetroot)
3837
val sourceSets = project.extensions.getByType<SourceSetContainer>()
3938
classpath = sourceSets.named("main").get().runtimeClasspath

scip-snapshots/src/main/java/tests/MinimizedSnapshotScipGenerator.java

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import java.util.Arrays;
1212
import java.util.Comparator;
1313
import java.util.List;
14-
import java.util.stream.Collectors;
1514
import java.util.stream.Stream;
1615
import org.scip_code.scip.Document;
1716
import org.scip_code.scip.Index;
@@ -115,35 +114,19 @@ public void onTargetroot(
115114
* target-root (as {@code -Dsnapshot.case.<id>.targetroot}) and the source root, which are
116115
* build-time paths.
117116
*/
118-
private static final List<CaseSpec> CASE_SPECS =
119-
Arrays.asList(
120-
new CaseSpec("java-common", "scip-snapshots/expected/java/common", false),
121-
new CaseSpec("kotlin-common", "scip-snapshots/expected/kotlin/common", true));
122-
123-
private static final class CaseSpec {
124-
final String id;
125-
final String relativeExpectDirectory;
126-
final boolean aggregateNoEmitInverseRelationships;
127-
128-
CaseSpec(
129-
String id, String relativeExpectDirectory, boolean aggregateNoEmitInverseRelationships) {
130-
this.id = id;
131-
this.relativeExpectDirectory = relativeExpectDirectory;
132-
this.aggregateNoEmitInverseRelationships = aggregateNoEmitInverseRelationships;
133-
}
134-
}
135-
136117
public static List<SnapshotCase> snapshotCases() {
137118
Path sourceroot = requiredPathProperty("snapshot.sourceroot");
138-
return CASE_SPECS.stream()
139-
.map(
140-
spec ->
141-
new SnapshotCase(
142-
spec.id,
143-
sourceroot.resolve(spec.relativeExpectDirectory),
144-
requiredPathProperty("snapshot.case." + spec.id + ".targetroot"),
145-
spec.aggregateNoEmitInverseRelationships))
146-
.collect(Collectors.toList());
119+
return Arrays.asList(
120+
new SnapshotCase(
121+
"java-common",
122+
sourceroot.resolve("scip-snapshots/expected/java/common"),
123+
requiredPathProperty("snapshot.case.java-common.targetroot"),
124+
false),
125+
new SnapshotCase(
126+
"kotlin-common",
127+
sourceroot.resolve("scip-snapshots/expected/kotlin/common"),
128+
requiredPathProperty("snapshot.case.kotlin-common.targetroot"),
129+
true));
147130
}
148131

149132
public static Path requiredPathProperty(String name) {

0 commit comments

Comments
 (0)