mirror of
https://github.com/apple/pkl.git
synced 2026-04-27 10:47:12 +02:00
Initial commit
This commit is contained in:
58
buildSrc/src/main/kotlin/pklHtmlValidator.gradle.kts
Normal file
58
buildSrc/src/main/kotlin/pklHtmlValidator.gradle.kts
Normal file
@@ -0,0 +1,58 @@
|
||||
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") {
|
||||
@Suppress("UnstableApiUsage")
|
||||
useTarget(buildInfo.libs.findLibrary("log4j12Api").get())
|
||||
because("mitigate critical security vulnerabilities")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@Suppress("UnstableApiUsage")
|
||||
validatorConfiguration(buildInfo.libs.findLibrary("nuValidator").get()) {
|
||||
// we only want jetty-util and jetty-util-ajax (with the right version)
|
||||
// couldn't find a more robust way to express this
|
||||
exclude(group = "org.eclipse.jetty", module = "jetty-continuation")
|
||||
exclude(group = "org.eclipse.jetty", module = "jetty-http")
|
||||
exclude(group = "org.eclipse.jetty", module = "jetty-io")
|
||||
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 = "javax.servlet")
|
||||
exclude(group = "commons-fileupload")
|
||||
}
|
||||
}
|
||||
|
||||
val validateHtml by tasks.registering(JavaExec::class) {
|
||||
val resultFile = file("$buildDir/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.writeText("Success.") }
|
||||
}
|
||||
|
||||
tasks.check {
|
||||
dependsOn(validateHtml)
|
||||
}
|
||||
Reference in New Issue
Block a user