Skip to content

Commit

Permalink
Use Gradle typed project accessors
Browse files Browse the repository at this point in the history
This change activates the `TYPESAFE_PROJECT_ACCESSORS` feature
preview in Gradle, and switches to such accessors instead of
string-based project references, where possible

Relates-To: apple#204
Signed-off-by: Sam Gammon <[email protected]>
  • Loading branch information
sgammon committed Feb 20, 2024
1 parent 3b2feb4 commit 5d02696
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 47 deletions.
2 changes: 1 addition & 1 deletion bench/bench.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ val graal: Configuration by configurations.creating

@Suppress("UnstableApiUsage")
dependencies {
jmh(project(":pkl-core"))
jmh(projects.pklCore)
// necessary because antlr4-runtime is declared as implementation dependency in pkl-core.gradle
jmh(libs.antlrRuntime)
truffle(libs.truffleApi)
Expand Down
8 changes: 4 additions & 4 deletions docs/docs.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ sourceSets {
}

dependencies {
testImplementation(project(":pkl-core"))
testImplementation(project(":pkl-config-java"))
testImplementation(project(":pkl-config-kotlin"))
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCore)
testImplementation(projects.pklConfigJava)
testImplementation(projects.pklConfigKotlin)
testImplementation(projects.pklCommonsTest)
testImplementation(libs.junitEngine)
testImplementation(libs.antlrRuntime)
}
Expand Down
10 changes: 5 additions & 5 deletions pkl-cli/pkl-cli.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ dependencies {
compileOnly(libs.svm)

// CliEvaluator exposes PClass
api(project(":pkl-core"))
api(projects.pklCore)
// CliEvaluatorOptions exposes CliBaseOptions
api(project(":pkl-commons-cli"))
api(projects.pklCommonsCli)

implementation(project(":pkl-commons"))
implementation(projects.pklCommons)
implementation(libs.jansi)
implementation(libs.jlineReader)
implementation(libs.jlineTerminal)
implementation(libs.jlineTerminalJansi)
implementation(project(":pkl-server"))
implementation(projects.pklServer)
implementation(libs.clikt) {
// force clikt to use our version of the kotlin stdlib
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
}

testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)

stagedMacAmd64Executable(files("$buildDir/executable/pkl-macos-amd64"))
stagedMacAarch64Executable(files("$buildDir/executable/pkl-macos-aarch64"))
Expand Down
10 changes: 5 additions & 5 deletions pkl-codegen-java/pkl-codegen-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ plugins {

dependencies {
// CliJavaCodeGeneratorOptions exposes CliBaseOptions
api(project(":pkl-commons-cli"))
api(projects.pklCommonsCli)

implementation(project(":pkl-commons"))
implementation(project(":pkl-core"))
implementation(projects.pklCommons)
implementation(projects.pklCore)
implementation(libs.javaPoet)

testImplementation(project(":pkl-config-java"))
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklConfigJava)
testImplementation(projects.pklCommonsTest)
}

// with `org.gradle.parallel=true` and without the line below, `test` strangely runs into:
Expand Down
10 changes: 5 additions & 5 deletions pkl-codegen-kotlin/pkl-codegen-kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ tasks.jar {
}

dependencies {
implementation(project(":pkl-commons"))
api(project(":pkl-commons-cli"))
api(project(":pkl-core"))
implementation(projects.pklCommons)
api(projects.pklCommonsCli)
api(projects.pklCore)

implementation(libs.kotlinPoet)
implementation(libs.kotlinReflect)

testImplementation(project(":pkl-config-kotlin"))
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklConfigKotlin)
testImplementation(projects.pklCommonsTest)
testImplementation(libs.kotlinCompilerEmbeddable)
testRuntimeOnly(libs.kotlinScriptingCompilerEmbeddable)
testRuntimeOnly(libs.kotlinScriptUtil)
Expand Down
6 changes: 3 additions & 3 deletions pkl-commons-cli/pkl-commons-cli.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ plugins {
}

dependencies {
api(project(":pkl-core"))
api(projects.pklCore)
api(libs.clikt) {
// force clikt to use our version of the kotlin stdlib
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-jdk8")
exclude(group = "org.jetbrains.kotlin", module = "kotlin-stdlib-common")
}

implementation(project(":pkl-commons"))
testImplementation(project(":pkl-commons-test"))
implementation(projects.pklCommons)
testImplementation(projects.pklCommonsTest)
}

publishing {
Expand Down
2 changes: 1 addition & 1 deletion pkl-commons-test/pkl-commons-test.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies {
api(libs.junitApi)
api(libs.junitEngine)
api(libs.junitParams)
api(project(":pkl-commons")) // for convenience
api(projects.pklCommons) // for convenience
implementation(libs.assertj)
}

Expand Down
4 changes: 2 additions & 2 deletions pkl-config-java/pkl-config-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ sourceSets.getByName("test") {

dependencies {
// "api" because ConfigEvaluator extends Evaluator
api(project(":pkl-core"))
api(projects.pklCore)

implementation(libs.geantyref)

testImplementation(libs.javaxInject)

firstPartySourcesJars(project(":pkl-core", "sourcesJar"))

pklCodegenJava(project(":pkl-codegen-java"))
pklCodegenJava(projects.pklCodegenJava)
}

tasks.shadowJar {
Expand Down
4 changes: 2 additions & 2 deletions pkl-config-kotlin/pkl-config-kotlin.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ val pklCodegenKotlin: Configuration by configurations.creating
configurations.api.get().extendsFrom(pklConfigJava)

dependencies {
pklConfigJava(project(":pkl-config-java"))
pklConfigJava(projects.pklConfigJava)

pklConfigJavaAll(project(":pkl-config-java", "fatJar"))

pklCodegenKotlin(project(":pkl-codegen-kotlin"))
pklCodegenKotlin(projects.pklCodegenKotlin)

implementation(libs.kotlinReflect)

Expand Down
4 changes: 2 additions & 2 deletions pkl-core/pkl-core.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ dependencies {

compileOnly(libs.jsr305)
// pkl-core implements pkl-executor's ExecutorSpi, but the SPI doesn't ship with pkl-core
compileOnly(project(":pkl-executor"))
compileOnly(projects.pklExecutor)

implementation(libs.antlrRuntime)
implementation(libs.truffleApi)
Expand All @@ -56,7 +56,7 @@ dependencies {

implementation(libs.snakeYaml)

testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)

add("generatorImplementation", libs.javaPoet)
add("generatorImplementation", libs.truffleApi)
Expand Down
8 changes: 4 additions & 4 deletions pkl-doc/pkl-doc.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ plugins {
val graalVmBaseDir = buildInfo.graalVm.baseDir

dependencies {
implementation(project(":pkl-core"))
implementation(project(":pkl-commons-cli"))
implementation(project(":pkl-commons"))
implementation(projects.pklCore)
implementation(projects.pklCommonsCli)
implementation(projects.pklCommons)
implementation(libs.commonMark)
implementation(libs.commonMarkTables)
implementation(libs.kotlinxHtml)
Expand All @@ -24,7 +24,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin")
}

testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
testImplementation(libs.jimfs)

// Graal.JS
Expand Down
4 changes: 2 additions & 2 deletions pkl-executor/pkl-executor.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ dependencies {

implementation(libs.slf4jApi)

testImplementation(project(":pkl-commons-test"))
testImplementation(project(":pkl-core"))
testImplementation(projects.pklCommonsTest)
testImplementation(projects.pklCore)
testImplementation(libs.slf4jSimple)
}

Expand Down
6 changes: 3 additions & 3 deletions pkl-gradle/pkl-gradle.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ plugins {
}

dependencies {
// Declare a `compileOnly` dependency on `project(":pkl-tools")`
// Declare a `compileOnly` dependency on `projects.pklTools`
// to ensure correct code navigation in IntelliJ.
compileOnly(project(":pkl-tools"))
compileOnly(projects.pklTools)

// Declare a `runtimeOnly` dependency on `project(":pkl-tools", "fatJar")`
// to ensure that the published plugin
Expand All @@ -31,7 +31,7 @@ dependencies {
runtimeOnly(project(":pkl-tools", "fatJar"))
}

testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
}

publishing {
Expand Down
4 changes: 2 additions & 2 deletions pkl-server/pkl-server.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ plugins {
}

dependencies {
implementation(project(":pkl-core"))
implementation(projects.pklCore)
implementation(libs.msgpack)
implementation(libs.truffleApi)
implementation(libs.antlrRuntime)

testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
}

tasks.test {
Expand Down
12 changes: 6 additions & 6 deletions pkl-tools/pkl-tools.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ dependencies {
// can declare a normal project dependency on this project,
// which is desirable for IntelliJ integration.
// The published fat JAR doesn't declare any dependencies.
api(project(":pkl-cli"))
api(project(":pkl-codegen-java"))
api(project(":pkl-codegen-kotlin"))
api(project(":pkl-config-java"))
api(project(":pkl-core"))
api(project(":pkl-doc"))
api(projects.pklCli)
api(projects.pklCodegenJava)
api(projects.pklCodegenKotlin)
api(projects.pklConfigJava)
api(projects.pklCore)
api(projects.pklDoc)

// used by `pklFatJar` plugin (ideally this would be inferred automatically)
firstPartySourcesJars(project(":pkl-cli", "sourcesJar"))
Expand Down
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ if (gradle.startParameter.taskNames.contains("updateDependencyLocks") ||
for (prj in rootProject.children) {
prj.buildFileName = "${prj.name}.gradle.kts"
}

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

0 comments on commit 5d02696

Please sign in to comment.