X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=utils%2Fdebian%2Fdebian_build.gradle;h=ce7f13634b966e570da6e044d4b0eae13a4db745;hb=b33b0a310733cc02690cc30ee513747afb2bf520;hp=998645af0586afc701c1742ca2149dc676f9e875;hpb=6fa882584a8e33a1c9975391dfe34520940ba8c6;p=jalview.git diff --git a/utils/debian/debian_build.gradle b/utils/debian/debian_build.gradle index 998645a..ce7f136 100644 --- a/utils/debian/debian_build.gradle +++ b/utils/debian/debian_build.gradle @@ -2,27 +2,10 @@ * For properties set within build.gradle, use camelCaseNoSpace. */ import org.apache.tools.ant.filters.ReplaceTokens -import com.vladsch.flexmark.util.ast.Node -import com.vladsch.flexmark.html.HtmlRenderer -import com.vladsch.flexmark.parser.Parser -import com.vladsch.flexmark.util.data.MutableDataSet -import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension -import com.vladsch.flexmark.ext.tables.TablesExtension -import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension -import com.vladsch.flexmark.ext.autolink.AutolinkExtension -import com.vladsch.flexmark.ext.anchorlink.AnchorLinkExtension -import com.vladsch.flexmark.ext.toc.TocExtension - -buildscript { - dependencies { - classpath "com.vladsch.flexmark:flexmark-all:0.62.0" - } -} plugins { id 'java' id 'application' - id 'com.palantir.git-version' version '0.12.3' } // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use @@ -65,7 +48,7 @@ def overrideProperties(String propsFileName, boolean output = false) { } } -ext { +project.ext { jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath() jalviewDirRelativePath = jalviewDir @@ -115,10 +98,6 @@ ext { install4jApplicationName = "${jalview_name}" - def details = versionDetails() - gitHash = details.gitHash - gitBranch = details.branchName - println("Using a ${CHANNEL} profile.") additional_compiler_args = [] @@ -257,85 +236,6 @@ def getDate(format) { } -def convertMdToHtml (FileTree mdFiles, File cssFile) { - MutableDataSet options = new MutableDataSet() - - def extensions = new ArrayList<>() - extensions.add(AnchorLinkExtension.create()) - extensions.add(AutolinkExtension.create()) - extensions.add(StrikethroughExtension.create()) - extensions.add(TaskListExtension.create()) - extensions.add(TablesExtension.create()) - extensions.add(TocExtension.create()) - - options.set(Parser.EXTENSIONS, extensions) - - // set GFM table parsing options - options.set(TablesExtension.WITH_CAPTION, false) - options.set(TablesExtension.COLUMN_SPANS, false) - options.set(TablesExtension.MIN_HEADER_ROWS, 1) - options.set(TablesExtension.MAX_HEADER_ROWS, 1) - options.set(TablesExtension.APPEND_MISSING_COLUMNS, true) - options.set(TablesExtension.DISCARD_EXTRA_COLUMNS, true) - options.set(TablesExtension.HEADER_SEPARATOR_COLUMN_MATCH, true) - // GFM anchor links - options.set(AnchorLinkExtension.ANCHORLINKS_SET_ID, false) - options.set(AnchorLinkExtension.ANCHORLINKS_ANCHOR_CLASS, "anchor") - options.set(AnchorLinkExtension.ANCHORLINKS_SET_NAME, true) - options.set(AnchorLinkExtension.ANCHORLINKS_TEXT_PREFIX, "") - - Parser parser = Parser.builder(options).build() - HtmlRenderer renderer = HtmlRenderer.builder(options).build() - - mdFiles.each { mdFile -> - // add table of contents - def mdText = "[TOC]\n"+mdFile.text - - // grab the first top-level title - def title = null - def titleRegex = /(?m)^#(\s+|([^#]))(.*)/ - def matcher = mdText =~ titleRegex - if (matcher.size() > 0) { - // matcher[0][2] is the first character of the title if there wasn't any whitespace after the # - title = (matcher[0][2] != null ? matcher[0][2] : "")+matcher[0][3] - } - // or use the filename if none found - if (title == null) { - title = mdFile.getName() - } - - Node document = parser.parse(mdText) - String htmlBody = renderer.render(document) - def htmlText = ''' - - - - - - -''' - htmlText += ((title != null) ? " ${title}" : '' ) - htmlText += ''' - -''' - htmlText += ((cssFile != null) ? cssFile.text : '') - htmlText += ''' - -''' - htmlText += htmlBody - htmlText += ''' - - -''' - - def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html") - def htmlFile = file(htmlFilePath) - println("Creating ${htmlFilePath}") - htmlFile.text = htmlText - } -} - - task copyDocs(type: Copy) { def inputDir = "${jalviewDir}/${doc_dir}" def outputDir = "${docBuildDir}/${doc_dir}" @@ -366,27 +266,6 @@ task copyDocs(type: Copy) { } -task convertMdFiles { - dependsOn copyDocs - def mdFiles = fileTree(dir: docBuildDir, include: "**/*.md") - def cssFile = file("${jalviewDir}/${flexmark_css}") - - doLast { - convertMdToHtml(mdFiles, cssFile) - } - - inputs.files(mdFiles) - inputs.file(cssFile) - - def htmlFiles = [] - mdFiles.each { mdFile -> - def htmlFilePath = mdFile.getPath().replaceAll(/\..*?$/, ".html") - htmlFiles.add(file(htmlFilePath)) - } - outputs.files(htmlFiles) -} - - task copyHelp(type: Copy) { def inputDir = helpSourceDir def outputDir = "${helpBuildDir}/${help_dir}" @@ -421,6 +300,59 @@ task copyHelp(type: Copy) { outputs.dir(outputDir) } +task releasesTemplates { + group "help" + description "Recreate whatsNew.html and releases.html from markdown files and templates in help" + + dependsOn copyHelp + + def releasesTemplateFile = file("${jalviewDir}/${releases_template}") + def whatsnewTemplateFile = file("${jalviewDir}/${whatsnew_template}") + def releasesHtmlFile = file("${helpBuildDir}/${help_dir}/${releases_html}") + def whatsnewHtmlFile = file("${helpBuildDir}/${help_dir}/${whatsnew_html}") + def releasesMdDir = "${jalviewDir}/${releases_dir}" + def whatsnewMdDir = "${jalviewDir}/${whatsnew_dir}" + + doFirst { + def JALVIEW_VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_") + def releaseMdFile = file("${releasesMdDir}/release-${JALVIEW_VERSION_UNDERSCORES}.md") + def whatsnewMdFile = file("${whatsnewMdDir}/whatsnew-${JALVIEW_VERSION_UNDERSCORES}.md") + + if (CHANNEL == "RELEASE") { + if (!releaseMdFile.exists()) { + throw new GradleException("File ${releaseMdFile} must be created for RELEASE") + } + if (!whatsnewMdFile.exists()) { + throw new GradleException("File ${whatsnewMdFile} must be created for RELEASE") + } + } + + def releaseFiles = fileTree(dir: releasesMdDir, include: "release-*.md") + def releaseFilesDates = releaseFiles.collectEntries { + [(it): getDate("")] + } + releaseFiles = releaseFiles.sort { a,b -> releaseFilesDates[a].compareTo(releaseFilesDates[b]) } + + def releasesTemplate = releasesTemplateFile.text + def m = releasesTemplate =~ /(?s)__VERSION_LOOP_START__(.*)__VERSION_LOOP_END__/ + def versionTemplate = m[0][1] + + def versionsHtml = "" + def linkedVersions = [] + + releasesTemplate = releasesTemplate.replaceAll("(?s)__VERSION_LOOP_START__.*__VERSION_LOOP_END__", versionsHtml) + releasesHtmlFile.text = releasesTemplate + + whatsnewHtmlFile.text = "Debian build " + getDate("yyyy-MM-dd HH:mm:ss") + } + + inputs.file(releasesTemplateFile) + inputs.file(whatsnewTemplateFile) + inputs.dir(releasesMdDir) + inputs.dir(whatsnewMdDir) + outputs.file(releasesHtmlFile) + outputs.file(whatsnewHtmlFile) +} task copyResources(type: Copy) { group = "build" @@ -468,24 +400,15 @@ task copyChannelResources(type: Copy) { outputs.dir(outputDir) } -task createBuildProperties(type: WriteProperties) { - dependsOn copyResources - group = "build" - description = "Create the ${buildProperties} file" - - inputs.dir(sourceDir) - inputs.dir(resourcesBuildDir) - outputFile (buildProperties) - // taking time specific comment out to allow better incremental builds - comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss") - //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd") - property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy") - property "VERSION", JALVIEW_VERSION - property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]" - if (getdownSetAppBaseProperty) { - property "GETDOWNAPPBASE", getdownAppBase - property "GETDOWNAPPDISTDIR", getdownAppDistDir - } +task createBuildProperties(type: Copy) { + // using the build_properties already included in the source tarball + def inputFile = "build_properties" + def outputFile = buildProperties + from inputFile + into file(outputFile).getParent() + rename(file(inputFile).getName(), file(outputFile).getName()) + + inputs.file(inputFile) outputs.file(outputFile) } @@ -519,7 +442,7 @@ task prepare { dependsOn buildResources dependsOn copyDocs dependsOn copyHelp - dependsOn convertMdFiles + dependsOn releasesTemplates dependsOn buildIndices } @@ -584,7 +507,7 @@ task linkCheck(type: JavaExec) { def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out") classpath = files("${jalviewDir}/${utils_dir}") main = "HelpLinksChecker" - workingDir = jalviewDir + workingDir = "${helpBuildDir}" args = [ "${helpBuildDir}/${help_dir}", "-nointernet" ] def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append