(Translated by https://www.hiragana.jp/)
Run spotless apply · luuvish/pkl@8c1c105 · GitHub
Skip to content

Commit

Permalink
Run spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
bioball committed Jul 1, 2024
1 parent 7a9b571 commit 8c1c105
Show file tree
Hide file tree
Showing 127 changed files with 5,353 additions and 3,478 deletions.
37 changes: 25 additions & 12 deletions bench/bench.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
pklAllProjects
pklJavaLibrary
Expand All @@ -18,31 +33,29 @@ dependencies {
}

jmh {
//include = ["fib_class_java"]
//include = ["fib_class_constrained1", "fib_class_constrained2"]
// include = ["fib_class_java"]
// include = ["fib_class_constrained1", "fib_class_constrained2"]
jmhVersion.set(libs.versions.jmh)
// jvmArgsAppend = "-Dgraal.TruffleCompilationExceptionsAreFatal=true " +
// "-Dgraal.Dump=Truffle,TruffleTree -Dgraal.TraceTruffleCompilation=true " +
// "-Dgraal.TruffleFunctionInlining=false"
jvm.set("${buildInfo.graalVmAmd64.baseDir}/bin/java")
// see: https://docs.oracle.com/en/graalvm/enterprise/20/docs/graalvm-as-a-platform/implement-language/#disable-class-path-separation
// see:
// https://docs.oracle.com/en/graalvm/enterprise/20/docs/graalvm-as-a-platform/implement-language/#disable-class-path-separation
jvmArgs.set(
listOf(
// one JVM arg per list element doesn't work, but the following does
"-Dgraalvm.locatorDisabled=true --module-path=${truffle.asPath} --upgrade-module-path=${graal.asPath}"
)
)
includeTests.set(false)
//threads = Runtime.runtime.availableProcessors() / 2 + 1
//synchronizeIterations = false
// threads = Runtime.runtime.availableProcessors() / 2 + 1
// synchronizeIterations = false
}

tasks.named("jmh") {
dependsOn(":installGraalVmAmd64")
}
tasks.named("jmh") { dependsOn(":installGraalVmAmd64") }

// Prevent this error which occurs when building in IntelliJ:
// "Entry org/pkl/core/fib_class_typed.pkl is a duplicate but no duplicate handling strategy has been set."
tasks.processJmhResources {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// "Entry org/pkl/core/fib_class_typed.pkl is a duplicate but no duplicate handling strategy has
// been set."
tasks.processJmhResources { duplicatesStrategy = DuplicatesStrategy.EXCLUDE }
32 changes: 23 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// https://youtrack.jetbrains.com/issue/KTIJ-19369
@file:Suppress("DSL_SCOPE_VIOLATION")
@file:Suppress("DSL_SCOPE_VIOLATION")

import org.jetbrains.gradle.ext.ActionDelegationConfig
import org.jetbrains.gradle.ext.ActionDelegationConfig.TestRunner.PLATFORM
Expand Down Expand Up @@ -40,15 +55,12 @@ idea {
}
}

val clean by tasks.existing {
delete(layout.buildDirectory)
}
val clean by tasks.existing { delete(layout.buildDirectory) }

val printVersion by tasks.registering {
doFirst { println(buildInfo.pklVersion) }
}
val printVersion by tasks.registering { doFirst { println(buildInfo.pklVersion) } }

val message = """
val message =
"""
====
Gradle version : ${gradle.gradleVersion}
Java version : ${System.getProperty("java.version")}
Expand All @@ -63,5 +75,7 @@ Git Commit ID : ${buildInfo.commitId}
====
"""

val formattedMessage = message.replace("\n====", "\n" + "=".repeat(message.lines().maxByOrNull { it.length }!!.length))
val formattedMessage =
message.replace("\n====", "\n" + "=".repeat(message.lines().maxByOrNull { it.length }!!.length))

logger.info(formattedMessage)
4 changes: 1 addition & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
`kotlin-dsl`
}
plugins { `kotlin-dsl` }

dependencies {
implementation(libs.downloadTaskPlugin)
Expand Down
21 changes: 16 additions & 5 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("UnstableApiUsage")

rootProject.name = "buildSrc"
Expand All @@ -12,11 +27,7 @@ pluginManagement {
// makes ~/.gradle/init.gradle unnecessary and ~/.gradle/gradle.properties optional
dependencyResolutionManagement {
// use same version catalog as main build
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
versionCatalogs { register("libs") { from(files("../gradle/libs.versions.toml")) } }

repositories {
repositoriesMode.set(RepositoriesMode.PREFER_SETTINGS)
Expand Down
56 changes: 28 additions & 28 deletions buildSrc/src/main/kotlin/BuildInfo.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("MemberVisibilityCanBePrivate")

import java.io.File
Expand All @@ -14,13 +29,9 @@ open class BuildInfo(project: Project) {
System.getenv("GRAALVM_HOME") ?: "${System.getProperty("user.home")}/.graalvm"
}

val version: String by lazy {
libs.findVersion("graalVm").get().toString()
}
val version: String by lazy { libs.findVersion("graalVm").get().toString() }

val graalVmJdkVersion: String by lazy {
libs.findVersion("graalVmJdkVersion").get().toString()
}
val graalVmJdkVersion: String by lazy { libs.findVersion("graalVmJdkVersion").get().toString() }

val osName: String by lazy {
when {
Expand All @@ -31,28 +42,22 @@ open class BuildInfo(project: Project) {
}
}

val baseName: String by lazy {
"graalvm-jdk-${graalVmJdkVersion}_${osName}-${arch}_bin"
}
val baseName: String by lazy { "graalvm-jdk-${graalVmJdkVersion}_${osName}-${arch}_bin" }

val downloadUrl: String by lazy {
val jdkMajor = graalVmJdkVersion.takeWhile { it != '.' }
val extension = if (os.isWindows) "zip" else "tar.gz"
"https://download.oracle.com/graalvm/$jdkMajor/archive/$baseName.$extension"
}

val installDir: File by lazy {
File(homeDir, baseName)
}
val installDir: File by lazy { File(homeDir, baseName) }

val baseDir: String by lazy {
if (os.isMacOsX) "$installDir/Contents/Home" else installDir.toString()
}
}

/**
* Same logic as [org.gradle.internal.os.OperatingSystem#arch], which is protected.
*/
/** Same logic as [org.gradle.internal.os.OperatingSystem#arch], which is protected. */
val arch: String by lazy {
when (val arch = System.getProperty("os.arch")) {
"x86" -> "i386"
Expand All @@ -66,13 +71,9 @@ open class BuildInfo(project: Project) {

val graalVmAmd64: GraalVm = GraalVm("x64")

val isCiBuild: Boolean by lazy {
System.getenv("CI") != null
}
val isCiBuild: Boolean by lazy { System.getenv("CI") != null }

val isReleaseBuild: Boolean by lazy {
java.lang.Boolean.getBoolean("releaseBuild")
}
val isReleaseBuild: Boolean by lazy { java.lang.Boolean.getBoolean("releaseBuild") }

val hasMuslToolchain: Boolean by lazy {
// see "install musl" in .circleci/jobs/BuildNativeJob.pkl
Expand All @@ -87,10 +88,11 @@ open class BuildInfo(project: Project) {
val commitId: String by lazy {
// only run command once per build invocation
if (project === project.rootProject) {
val process = ProcessBuilder()
.command("git", "rev-parse", "--short", "HEAD")
.directory(project.rootDir)
.start()
val process =
ProcessBuilder()
.command("git", "rev-parse", "--short", "HEAD")
.directory(project.rootDir)
.start()
process.waitFor().also { exitCode ->
if (exitCode == -1) throw RuntimeException(process.errorStream.reader().readText())
}
Expand All @@ -100,9 +102,7 @@ open class BuildInfo(project: Project) {
}
}

val commitish: String by lazy {
if (isReleaseBuild) project.version.toString() else commitId
}
val commitish: String by lazy { if (isReleaseBuild) project.version.toString() else commitId }

val pklVersion: String by lazy {
if (isReleaseBuild) {
Expand Down
35 changes: 24 additions & 11 deletions buildSrc/src/main/kotlin/ExecutableJar.kt
Original file line number Diff line number Diff line change
@@ -1,39 +1,52 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.api.DefaultTask
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputFile
import org.gradle.api.tasks.TaskAction

/**
* Builds a self-contained Pkl CLI Jar that is directly executable on *nix
* and executable with `java -jar` on Windows.
* Builds a self-contained Pkl CLI Jar that is directly executable on *nix and executable with `java
* -jar` on Windows.
*
* For direct execution, the `java` command must be on the PATH.
*
* https://skife.org/java/unix/2011/06/20/really_executable_jars.html
*/
abstract class ExecutableJar : DefaultTask() {
@get:InputFile
abstract val inJar: RegularFileProperty
@get:InputFile abstract val inJar: RegularFileProperty

@get:OutputFile
abstract val outJar: RegularFileProperty
@get:OutputFile abstract val outJar: RegularFileProperty

@get:Input
abstract val jvmArgs: ListProperty<String>
@get:Input abstract val jvmArgs: ListProperty<String>

@TaskAction
fun buildJar() {
val inFile = inJar.get().asFile
val outFile = outJar.get().asFile
val escapedJvmArgs = jvmArgs.get().joinToString(separator = " ") { "\"$it\"" }
val startScript = """
val startScript =
"""
#!/bin/sh
exec java $escapedJvmArgs -jar $0 "$@"
""".trimIndent() + "\n\n\n"
"""
.trimIndent() + "\n\n\n"
outFile.outputStream().use { outStream ->
startScript.byteInputStream().use { it.copyTo(outStream) }
inFile.inputStream().use { it.copyTo(outStream) }
Expand Down
17 changes: 16 additions & 1 deletion buildSrc/src/main/kotlin/GradlePluginTests.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
/**
* Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import org.gradle.util.GradleVersion

open class GradlePluginTests {
lateinit var minGradleVersion: GradleVersion
lateinit var maxGradleVersion: GradleVersion
var skippedGradleVersions: List<GradleVersion> = listOf()
}
}
Loading

0 comments on commit 8c1c105

Please sign in to comment.