@@ -59,9 +59,6 @@ inline fun <reified T : Named> AttributeContainer.attribute(attr: Attribute<T>,
5959 attribute(attr, objects.named<T >(value))
6060
6161// isCanBeConsumed = false ==> other modules must not use the configuration as a dependency
62- val buildDocs by configurations.creating {
63- isCanBeConsumed = false
64- }
6562val generatorJar by configurations.creating {
6663 isCanBeConsumed = false
6764}
@@ -109,12 +106,6 @@ dependencies {
109106 srcLicense(project(" :src:licenses" , " srcLicense" ))
110107 generatorJar(project(" :src:generator" , " archives" ))
111108 junitSampleJar(project(" :src:protocol:junit-sample" ))
112-
113- buildDocs(platform(projects.src.bomThirdparty))
114- buildDocs(" org.apache.velocity:velocity" )
115- buildDocs(" commons-lang:commons-lang" )
116- buildDocs(" org.apache.commons:commons-collections4" )
117- buildDocs(" org.jdom:jdom" )
118109}
119110
120111node {
@@ -338,89 +329,6 @@ val createDist by tasks.registering {
338329// source/binary artifacts with the appropriate eol/executable file flags
339330val gitProps by rootProject.tasks.existing(FindGitAttributes ::class )
340331
341- fun createAnakiaTask (
342- taskName : String ,
343- baseDir : Directory ,
344- extension : String = ".html",
345- style : String ,
346- velocityProperties : String ,
347- projectFile : String ,
348- excludes : Array <String >,
349- includes : Array <String >
350- ): TaskProvider <Task > {
351- val outputDir = layout.buildDirectory.dir(" docs/$taskName " ).get().asFile
352-
353- val prepareProps = tasks.register(" prepareProperties$taskName " ) {
354- // AnakiaTask can't use relative paths, and it forbids ../, so we create a dedicated
355- // velocity.properties file that contains absolute path
356- inputs.file(velocityProperties)
357- val outputProps = layout.buildDirectory.file(" docProps/$taskName /velocity.properties" ).get().asFile
358- outputs.file(outputProps)
359- doLast {
360- // Unfortunately, Velocity does not use Java properties format.
361- // For instance, Properties escape : as \:, however Velocity does not understand that.
362- // Thus it tries to use c\:\path\to\workspace which does not work
363- val p = `java.util`.Properties ()
364- file(velocityProperties).reader().use {
365- p.load(it)
366- }
367- p[" resource.loader" ] = " file"
368- p[" file.resource.loader.path" ] = baseDir.asFile.absolutePath
369- p[" file.resource.loader.class" ] = " org.apache.velocity.runtime.resource.loader.FileResourceLoader"
370- val specials = Regex (""" ([,\\])""" )
371- val lines = p.entries
372- .map { (it.key as String ) + " =" + ((it.value as String ).replace(specials, """ \\$1""" )) }
373- .sorted()
374- file(outputProps).apply {
375- parentFile.run { isDirectory || mkdirs() } || throw IllegalStateException (" Unable to create directory $parentFile " )
376-
377- writer().use {
378- it.appendLine(" # Auto-generated from $velocityProperties to pass absolute path to Velocity" )
379- for (line in lines) {
380- it.appendLine(line)
381- }
382- }
383- }
384- }
385- }
386-
387- return tasks.register(taskName) {
388- inputs.file(" $baseDir /$style " ).withPathSensitivity(PathSensitivity .RELATIVE ).withPropertyName(" styleDir" )
389- inputs.file(" $baseDir /$projectFile " ).withPathSensitivity(PathSensitivity .RELATIVE ).withPropertyName(" projectDir" )
390- inputs.files(
391- fileTree(baseDir) {
392- include(* includes)
393- exclude(* excludes)
394- }
395- ).withPathSensitivity(PathSensitivity .RELATIVE ).withPropertyName(" baseDir" )
396- inputs.property(" extension" , extension)
397- outputs.dir(outputDir)
398- outputs.cacheIf { true }
399- dependsOn(prepareProps)
400-
401- doLast {
402- ant.withGroovyBuilder {
403- " taskdef" (
404- " name" to " anakia" ,
405- " classname" to " org.apache.velocity.anakia.AnakiaTask" ,
406- " classpath" to buildDocs.asPath
407- )
408- " anakia" (
409- " basedir" to baseDir,
410- " destdir" to outputDir,
411- " extension" to extension,
412- " style" to style,
413- " projectFile" to projectFile,
414- " excludes" to excludes.joinToString(" " ),
415- " includes" to includes.joinToString(" " ),
416- " lastModifiedCheck" to " true" ,
417- " velocityPropertiesFile" to prepareProps.get().outputs.files.singleFile
418- )
419- }
420- }
421- }
422- }
423-
424332val xdocs = rootProject.layout.projectDirectory.dir(" xdocs" )
425333
426334fun CopySpec.docCssAndImages () {
@@ -439,13 +347,34 @@ fun CopySpec.manuals() {
439347 }
440348}
441349
442- fun CopySpec.printableDocumentation () {
443- into(" docs" ) {
444- docCssAndImages()
350+ fun CopySpec.docFontsAndCss () {
351+ into(" fonts" ) {
352+ from(
353+ fileTree(xdocs.dir(" node_modules/@fontsource/merriweather/files" )) {
354+ builtBy(yarn_install)
355+ }
356+ ) {
357+ include(" *400*normal*.woff2" )
358+ }
359+ from(xdocs.dir(" node_modules/@fortawesome/fontawesome-free/webfonts" )) {
360+ include(" fa-brands*.woff2" )
361+ }
445362 }
446- into(" printable_docs" ) {
447- from(buildPrintableDoc)
448- manuals()
363+ into(" css" ) {
364+ from(xdocs.dir(" node_modules/@fontsource/merriweather" )) {
365+ include(" 400.css" )
366+ rename { " merriweather.css" }
367+ filter {
368+ it.replace(" ./files" , " ../fonts" )
369+ }
370+ }
371+ from(xdocs.dir(" node_modules/@fortawesome/fontawesome-free/css" )) {
372+ include(" fontawesome.min.css" )
373+ include(" brands.min.css" )
374+ filter {
375+ it.replace(" ../webfonts" , " ../fonts" )
376+ }
377+ }
449378 }
450379}
451380
@@ -465,25 +394,6 @@ val yarn_install = tasks.named<YarnTask>("yarn_install") {
465394 outputs.dir(xdocs.dir(" node_modules" )).withPropertyName(" node_modules" )
466395}
467396
468- val buildPrintableDoc = createAnakiaTask(
469- " buildPrintableDoc" , baseDir = xdocs,
470- style = " stylesheets/site_printable.vsl" ,
471- velocityProperties = " $xdocs /velocity.properties" ,
472- projectFile = " stylesheets/printable_project.xml" ,
473- excludes = arrayOf(" **/stylesheets/**" , " extending.xml" , " extending/*.xml" , " node_modules" , " package.json" , " package-lock.json" , " yarn.lock" ),
474- includes = arrayOf(" **/*.xml" )
475- )
476-
477- val previewPrintableDocs by tasks.registering(Copy ::class ) {
478- group = JavaBasePlugin .DOCUMENTATION_GROUP
479- description = " Creates preview of a printable documentation to build/docs/printable_preview"
480- into(layout.buildDirectory.dir(" docs/printable_preview" ))
481- CrLfSpec ().run {
482- gitattributes(gitProps)
483- printableDocumentation()
484- }
485- }
486-
487397val lastEditYear: String by rootProject.extra
488398
489399fun xslt (
@@ -542,34 +452,7 @@ fun CopySpec.siteLayout() {
542452 from(processSiteXslt)
543453 docCssAndImages()
544454 manuals()
545- into(" fonts" ) {
546- from(
547- fileTree(xdocs.dir(" node_modules/@fontsource/merriweather/files" )) {
548- builtBy(yarn_install)
549- }
550- ) {
551- include(" *400*normal*.woff2" )
552- }
553- from(xdocs.dir(" node_modules/@fortawesome/fontawesome-free/webfonts" )) {
554- include(" fa-brands*.woff2" )
555- }
556- }
557- into(" css" ) {
558- from(xdocs.dir(" node_modules/@fontsource/merriweather" )) {
559- include(" 400.css" )
560- rename { " merriweather.css" }
561- filter {
562- it.replace(" ./files" , " ../fonts" )
563- }
564- }
565- from(xdocs.dir(" node_modules/@fortawesome/fontawesome-free/css" )) {
566- include(" fontawesome.min.css" )
567- include(" brands.min.css" )
568- filter {
569- it.replace(" ../webfonts" , " ../fonts" )
570- }
571- }
572- }
455+ docFontsAndCss()
573456}
574457
575458// See https://github.com/gradle/gradle/issues/10960
@@ -628,7 +511,12 @@ fun CrLfSpec.binaryLayout() = copySpec {
628511 with (libsExt)
629512 }
630513 }
631- printableDocumentation()
514+ into(" docs" ) {
515+ from(processSiteXslt)
516+ docCssAndImages()
517+ manuals()
518+ docFontsAndCss()
519+ }
632520 into(" docs/api" ) {
633521 javadocs()
634522 }
0 commit comments