2020-04-30 04:21:53 -04:00
|
|
|
/*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership.
|
|
|
|
* The ASF licenses this file to You 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
|
|
|
|
*
|
|
|
|
* http://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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
configure(subprojects.findAll { it.path == ':lucene' || it.path == ':solr' }) {
|
|
|
|
task changesToHtml(type: ChangesToHtmlTask)
|
|
|
|
}
|
|
|
|
|
|
|
|
// compile changes.txt into an html file
|
|
|
|
class ChangesToHtmlTask extends DefaultTask {
|
|
|
|
|
|
|
|
@Input
|
|
|
|
File changesFile = project.file("CHANGES.txt")
|
|
|
|
|
|
|
|
@Input
|
|
|
|
File changesDoapFile = project.rootProject.file("dev-tools/doap/${project.name}.rdf")
|
|
|
|
|
|
|
|
@InputDirectory
|
|
|
|
File siteDir = project.rootProject.file("lucene/site/changes")
|
|
|
|
|
|
|
|
@OutputDirectory
|
2020-05-19 08:26:38 -04:00
|
|
|
final DirectoryProperty targetDir = project.objects.directoryProperty()
|
|
|
|
.fileProvider(project.providers.provider { project.file("${project.docroot}/changes") })
|
2020-04-30 04:21:53 -04:00
|
|
|
|
2020-05-18 03:03:25 -04:00
|
|
|
@Input
|
|
|
|
def luceneDocUrl = "${->project.luceneDocUrl}"
|
|
|
|
|
2020-05-19 08:26:38 -04:00
|
|
|
@InputFile
|
|
|
|
def script = project.rootProject.file("${siteDir}/changes2html.pl")
|
|
|
|
|
2020-04-30 04:21:53 -04:00
|
|
|
def loadVersions(File outfile) {
|
|
|
|
// load version properties from DOAP RDF
|
|
|
|
def prefix = "doap.${project.name}".toString()
|
|
|
|
ant.xmlproperty(keeproot: false, file: changesDoapFile, collapseAttributes: false, prefix: "${prefix}")
|
|
|
|
outfile.withWriter("UTF-8") { writer ->
|
|
|
|
writer.println(ant.properties["${prefix}.Project.release.Version.revision"])
|
|
|
|
writer.println(ant.properties["${prefix}.Project.release.Version.created"])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def toHtml(File versionsFile) {
|
|
|
|
def output = new ByteArrayOutputStream()
|
|
|
|
def result = project.exec {
|
2020-08-30 11:10:18 -04:00
|
|
|
executable project.externalTool("perl")
|
2020-04-30 04:21:53 -04:00
|
|
|
standardInput changesFile.newInputStream()
|
2020-05-19 08:26:38 -04:00
|
|
|
standardOutput project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()
|
2020-04-30 04:21:53 -04:00
|
|
|
errorOutput = output
|
|
|
|
ignoreExitValue = true
|
|
|
|
|
|
|
|
args += [
|
|
|
|
"-CSD",
|
2020-05-19 08:26:38 -04:00
|
|
|
script,
|
2020-04-30 04:21:53 -04:00
|
|
|
"${project.name}",
|
|
|
|
versionsFile.toString(),
|
2020-05-18 03:03:25 -04:00
|
|
|
luceneDocUrl.concat('/') // slash required at end by perl script
|
2020-04-30 04:21:53 -04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
if (result.getExitValue() != 0) {
|
|
|
|
throw new GradleException("Changes generation failed:\n${output}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@TaskAction
|
|
|
|
def convert() {
|
|
|
|
project.mkdir targetDir
|
|
|
|
if (changesFile.exists() && changesDoapFile.exists()) {
|
|
|
|
File versionsFile = project.file("${project.buildDir}/doap.${project.name}.changes.version.dates.csv")
|
|
|
|
loadVersions(versionsFile)
|
|
|
|
toHtml(versionsFile)
|
|
|
|
project.copy {
|
|
|
|
from siteDir
|
|
|
|
into targetDir
|
|
|
|
include "*.css"
|
|
|
|
}
|
|
|
|
versionsFile.delete()
|
|
|
|
} else {
|
|
|
|
throw new GradleException("Changes file ${changesFile} or Doap file ${changesDoapFile} not found.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|