Skip to content

Commit 8125fdd

Browse files
authored
Select projects to include via spotlight and/or ArtifactSwapModuleSelector (#82)
This completes the integration of the `ArtifactSwapModuleSelector` code that lived in setupIdeModules (internal tool) previously into the settings plugin. Users would now indicate via spotlight (`ide-projects.txt`) what they want to work on, and the other required projects are automatically computed at the start of each sync instead of via some helper tool like `./setupIdeModules`.
1 parent af05b47 commit 8125fdd

File tree

23 files changed

+927
-301
lines changed

23 files changed

+927
-301
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121

2222
steps:
2323
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
24-
- name: Set up JDK 17
24+
- name: Set up JDK 21
2525
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5
2626
with:
27-
java-version: '17'
27+
java-version: '21'
2828
distribution: 'temurin'
2929

3030
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.

.github/workflows/publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ jobs:
1818
contents: read
1919
steps:
2020
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5
21-
- name: Set up JDK 17
21+
- name: Set up JDK 21
2222
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5
2323
with:
24-
java-version: '17'
24+
java-version: '21'
2525
distribution: 'temurin'
2626

2727
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.

build-logic/conventions/build.gradle.kts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ gradlePlugin {
2626

2727
dependencies {
2828
implementation(gradleApi())
29-
3029
implementation(libs.android.gradle)
31-
implementation(libs.ktfmt.gradle)
32-
implementation(libs.vanniktech.gradle)
33-
implementation(libs.kotlin.gradle)
3430
implementation(libs.dagp.gradle)
3531
implementation(libs.develocity.gradle)
32+
implementation(libs.kotlin.gradle)
33+
implementation(libs.ktfmt.gradle)
34+
implementation(libs.vanniktech.gradle)
3635
}

cli/build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
plugins {
2-
application
3-
id("com.gradleup.shadow")
2+
application
3+
id("com.gradleup.shadow")
44
}
55

66
application {
7-
mainClass = "xyz.block.artifactswap.cli.MainKt"
8-
applicationName = "artifactswap"
7+
mainClass = "xyz.block.artifactswap.cli.MainKt"
8+
applicationName = "artifactswap"
99
}
1010

1111
dependencies {
@@ -22,23 +22,23 @@ dependencies {
2222
implementation(libs.okhttp)
2323
implementation(libs.okhttp.logging)
2424
implementation(libs.picocli.core)
25-
implementation(libs.retrofit.core)
2625
implementation(libs.retrofit.converter.jackson)
26+
implementation(libs.retrofit.core)
2727
implementation(libs.retrofit.wire)
2828
implementation(libs.slf4j.api)
2929

3030
runtimeOnly(libs.log4j.slf4j2.impl) {
3131
because("JGit uses SLF4J for logging")
3232
}
3333

34-
// Test dependencies
3534
testImplementation(platform(libs.junit.bom))
35+
testImplementation(testFixtures(project(":core")))
3636
testImplementation(libs.junit.jupiter.api)
3737
testImplementation(libs.kotlin.test)
3838
testImplementation(libs.kotlinx.coroutines.test)
3939
testImplementation(libs.mockito.core)
4040
testImplementation(libs.mockito.kotlin)
41-
testImplementation(testFixtures(project(":core")))
41+
4242
testRuntimeOnly(libs.junit.launcher)
4343
}
4444

core/build.gradle.kts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ plugins {
44
}
55

66
dependencies {
7-
// API - exposed to consumers
87
api(libs.jackson.databind)
98
api(libs.jackson.dataformat.xml)
109
api(libs.jgit.core)
@@ -15,15 +14,12 @@ dependencies {
1514
api(libs.slf4j.api)
1615
api(libs.spotlight.buildscriptUtils)
1716

18-
// Implementation
1917
implementation(libs.jackson.core)
2018
implementation(libs.jackson.module.kotlin)
2119
implementation(libs.log4j.kotlin)
22-
implementation(libs.okhttp)
2320
implementation(libs.okio)
2421
implementation(libs.wire.runtime)
2522

26-
// Runtime only
2723
runtimeOnly(libs.log4j.api)
2824
runtimeOnly(libs.log4j.core)
2925

core/src/main/kotlin/xyz/block/artifactswap/core/config/ArtifactSwapConfig.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package xyz.block.artifactswap.core.config
22

3+
import java.io.Serializable
4+
35
/**
46
* Central configuration for all artifact swap operations.
57
*
@@ -115,6 +117,6 @@ data class ArtifactSwapConfig(
115117
// Artifactory
116118
// ============================================================================
117119
val artifactoryBaseUrl: String = "https://artifactory.example.com",
118-
) {
120+
) : Serializable {
119121
val primaryArtifactsMavenGroupArtifactoryPath = primaryArtifactsMavenGroup.replace('.', '/')
120122
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
package xyz.block.artifactswap.core.module_selector
2+
3+
import com.fueledbycaffeine.spotlight.buildscript.GradlePath
4+
import java.nio.file.Files
5+
import java.nio.file.Path
6+
import kotlin.io.path.exists
7+
import kotlin.io.path.isRegularFile
8+
9+
/**
10+
* Manages the list of projects that must always be included in the build, even if they have
11+
* available artifacts.
12+
*
13+
* This is useful for cases where:
14+
* - A project is a SQLDelight schema dependency (SQLDelight cannot use binary artifacts as schema
15+
* dependencies)
16+
* - A project has special build-time requirements that prevent artifact substitution
17+
*
18+
* The list is stored in `gradle/artifact-swap-always-keep.txt` with one project path per line. The
19+
* file format is the same as Spotlight project list files:
20+
* - One project path per line (e.g., `:common:schema`)
21+
* - Lines starting with `#` are comments
22+
* - Empty lines are ignored
23+
*/
24+
object AlwaysKeepProjectsList {
25+
private const val ALWAYS_KEEP_FILE = "gradle/artifact-swap-always-keep.txt"
26+
27+
/**
28+
* Reads the list of projects that should always be kept from the configuration file.
29+
*
30+
* Uses the same file format as SpotlightProjectList for consistency.
31+
*
32+
* @param rootDir The root directory of the Gradle project
33+
* @return Set of GradlePath objects that must always be included (e.g., ":common:schema")
34+
*/
35+
fun read(rootDir: Path): Set<GradlePath> {
36+
val file = rootDir.resolve(ALWAYS_KEEP_FILE)
37+
if (!file.exists() || !file.isRegularFile()) {
38+
return emptySet()
39+
}
40+
41+
return Files.readAllLines(file)
42+
.asSequence()
43+
.map { it.trim() }
44+
.filter { it.isNotEmpty() && !it.startsWith("#") } // Support comments like Spotlight
45+
.map { GradlePath(rootDir, it) } // Convert string paths to GradlePath objects
46+
.toSet()
47+
}
48+
}

0 commit comments

Comments
 (0)