Use Gradle typed project accessors

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/pkl#204
Signed-off-by: Sam Gammon <sam@elide.ventures>
This commit is contained in:
Sam Gammon
2024-02-20 10:46:42 -08:00
committed by Philip K.F. Hölzenspies
parent cb33a7cdb0
commit 1e50200969
16 changed files with 49 additions and 47 deletions

View File

@@ -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)

View File

@@ -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)
}

View File

@@ -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"))

View File

@@ -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:

View File

@@ -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)

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -62,7 +62,7 @@ sourceSets.getByName("test") {
dependencies {
// "api" because ConfigEvaluator extends Evaluator
api(project(":pkl-core"))
api(projects.pklCore)
implementation(libs.geantyref)
@@ -70,7 +70,7 @@ dependencies {
firstPartySourcesJars(project(":pkl-core", "sourcesJar"))
pklCodegenJava(project(":pkl-codegen-java"))
pklCodegenJava(projects.pklCodegenJava)
}
tasks.shadowJar {

View File

@@ -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)

View File

@@ -45,7 +45,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)
@@ -57,7 +57,7 @@ dependencies {
implementation(libs.snakeYaml)
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
add("generatorImplementation", libs.javaPoet)
add("generatorImplementation", libs.truffleApi)

View File

@@ -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)
@@ -24,7 +24,7 @@ dependencies {
exclude(group = "org.jetbrains.kotlin")
}
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
testImplementation(libs.jimfs)
// Graal.JS

View File

@@ -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)
}

View File

@@ -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
@@ -31,7 +31,7 @@ dependencies {
runtimeOnly(project(":pkl-tools", "fatJar"))
}
testImplementation(project(":pkl-commons-test"))
testImplementation(projects.pklCommonsTest)
}
publishing {

View File

@@ -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 {

View File

@@ -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"))

View File

@@ -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")