mirror of
https://github.com/apple/pkl.git
synced 2026-07-09 06:25:16 +02:00
1cc20b611f
This reverts the commits that enabled Gradle's configuration cache feature. IMO: this feature is too hard to use. We don't know if a task is valid for the configuration cache until it runs, and it's very hard to tell if something is safe when authoring Gradle code. For example, our publish tasks are currently failing; I don't know how I would fix this without running the publish task again on my dev machine. Also, some of our build scripts become more brittle because of this; for example, see https://github.com/apple/pkl/blob/bb07589eae0b3195a589559a3245cbc12c29b394/build-logic/src/main/kotlin/BuildInfo.kt#L291-L296
76 lines
3.1 KiB
Kotlin
76 lines
3.1 KiB
Kotlin
/*
|
|
* Copyright © 2024-2026 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 { base }
|
|
|
|
val htmlValidator = extensions.create<HtmlValidator>("htmlValidator", project)
|
|
|
|
val buildInfo = project.extensions.getByType<BuildInfo>()
|
|
|
|
val validatorConfiguration: Configuration =
|
|
configurations.create("validator") {
|
|
resolutionStrategy.eachDependency {
|
|
if (requested.group == "log4j" && requested.name == "log4j") {
|
|
useTarget(buildInfo.libs.findLibrary("log4j12Api").get())
|
|
because("mitigate critical security vulnerabilities")
|
|
}
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
validatorConfiguration(buildInfo.libs.findLibrary("nuValidator").get()) {
|
|
// remove unnecessary dependencies
|
|
// (some of the requested versions don't even exist on Maven Central)
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-alpn-client")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-continuation")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-http")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-security")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-server")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-servlets")
|
|
exclude(group = "org.eclipse.jetty", module = "jetty-jakarta-servlet-api")
|
|
exclude(group = "org.eclipse.jetty.toolchain")
|
|
exclude(group = "javax.servlet")
|
|
exclude(group = "org.apache.commons", module = "commons-fileupload2-core")
|
|
exclude(group = "org.apache.commons", module = "commons-fileupload2-jakarta-servlet5")
|
|
}
|
|
}
|
|
|
|
val validateHtml by
|
|
tasks.registering(JavaExec::class) {
|
|
val resultFile = layout.buildDirectory.file("validateHtml/result.txt")
|
|
inputs.files(htmlValidator.sources)
|
|
outputs.file(resultFile)
|
|
|
|
classpath = validatorConfiguration
|
|
mainClass.set("nu.validator.client.SimpleCommandLineValidator")
|
|
args(
|
|
"--skip-non-html"
|
|
) // --also-check-css doesn't work (still checks css as html), so limit to html files
|
|
args("--filterpattern", "(.*)Consider adding “lang=(.*)")
|
|
args("--filterpattern", "(.*)Consider adding a “lang” attribute(.*)")
|
|
args("--filterpattern", "(.*)unrecognized media “amzn-kf8”(.*)") // kindle
|
|
// for debugging
|
|
// args "--verbose"
|
|
args(htmlValidator.sources)
|
|
|
|
// write a basic result file s.t. gradle can consider task up-to-date
|
|
// writing a result file in case validation fails is not easily possible with JavaExec, but also
|
|
// not strictly necessary
|
|
doFirst { project.delete(resultFile) }
|
|
doLast { resultFile.get().asFile.writeText("Success.") }
|
|
}
|
|
|
|
tasks.check { dependsOn(validateHtml) }
|