From 3072515cf0a1d9ae58b48a07fe9af4abe9ee798f Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Sun, 20 Sep 2020 20:33:16 +0100 Subject: [PATCH] JAL-3753 put resources in gradle run and test path --- .gitignore | 1 - build.gradle | 139 +++++++++++++++++++++++++++++++--------------------------- 2 files changed, 75 insertions(+), 65 deletions(-) diff --git a/.gitignore b/.gitignore index 389b981..7ca0f00 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,3 @@ TESTNG /jalviewjsTest.html /site1 /site2 -/resources/.build_properties diff --git a/build.gradle b/build.gradle index 48c83a3..72baea1 100644 --- a/build.gradle +++ b/build.gradle @@ -444,16 +444,16 @@ ext { install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1) } - resourceBuildDir = string("${buildDir}/resource") - resourcesBuildDir = string("${resourceBuildDir}/resources") - helpBuildDir = string("${resourceBuildDir}/${help_dir}") - docBuildDir = string("${resourceBuildDir}/${doc_dir}") + resourceBuildDir = string("${buildDir}/resources") + resourcesBuildDir = string("${resourceBuildDir}/resources_build") + helpBuildDir = string("${resourceBuildDir}/help_build") + docBuildDir = string("${resourceBuildDir}/doc_build") buildProperties = string("${resourcesBuildDir}/${build_properties_file}") buildingHTML = string("${jalviewDir}/${doc_dir}/building.html") helpParentDir = string("${jalviewDir}/${help_parent_dir}") helpSourceDir = string("${helpParentDir}/${help_dir}") - helpFile = string("${helpBuildDir}/help.jhm") + helpFile = string("${helpBuildDir}/${help_dir}/help.jhm") relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath()) @@ -491,13 +491,14 @@ sourceSets { } resources { - srcDirs resourcesBuildDir + srcDirs = [ resourcesBuildDir, docBuildDir, helpBuildDir ] } compileClasspath = files(sourceSets.main.java.outputDir) compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"]) runtimeClasspath = compileClasspath + runtimeClasspath += files(sourceSets.main.resources.srcDirs) } clover { @@ -534,6 +535,7 @@ sourceSets { compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"]) runtimeClasspath = compileClasspath + runtimeClasspath += files(sourceSets.test.resources.srcDirs) } } @@ -1009,20 +1011,6 @@ def getDate(format) { } -clean { - doFirst { - delete buildProperties - } -} - - -task cleanBuildingHTML(type: Delete) { - doFirst { - delete buildingHTML - } -} - - def convertMdToHtml (FileTree mdFiles, File cssFile) { MutableDataSet options = new MutableDataSet() @@ -1101,9 +1089,38 @@ def convertMdToHtml (FileTree mdFiles, File cssFile) { } +task copyDocs(type: Copy) { + def inputDir = "${jalviewDir}/${doc_dir}" + def outputDir = "${docBuildDir}/${doc_dir}" + from(inputDir) { + exclude '**/*.gif' + exclude '**/*.jpg' + exclude '**/*.png' + filter(ReplaceTokens, + beginToken: '$$', + endToken: '$$', + tokens: [ + 'Version-Rel': JALVIEW_VERSION, + 'Year-Rel': getDate("yyyy") + ] + ) + } + from(inputDir) { + include '**/*.gif' + include '**/*.jpg' + include '**/*.png' + } + into outputDir + + inputs.dir(inputDir) + outputs.files(helpFile) + outputs.dir(outputDir) +} + + task convertMdFiles { - dependsOn cleanBuildingHTML - def mdFiles = fileTree(dir: "${jalviewDir}/${doc_dir}", include: "*.md") + dependsOn copyDocs + def mdFiles = fileTree(dir: docBuildDir, include: "*.md") def cssFile = file("${jalviewDir}/${flexmark_css}") doLast { @@ -1122,29 +1139,9 @@ task convertMdFiles { } -task copyDocs(type: Copy) { - dependsOn convertMdFiles - def syncDir = "${docBuildDir}" - from ("${jalviewDir}/${doc_dir}") { - exclude '**/*.gif' - exclude '**/*.jpg' - exclude '**/*.png' - filter(ReplaceTokens, - beginToken: '$$', - endToken: '$$', - tokens: [ - 'Version-Rel': JALVIEW_VERSION, - 'Year-Rel': getDate("yyyy") - ] - ) - } - into syncDir -} - - task copyHelp(type: Copy) { def inputDir = helpSourceDir - def outputDir = "${helpBuildDir}" + def outputDir = "${helpBuildDir}/${help_dir}" from(inputDir) { exclude '**/*.gif' exclude '**/*.jpg' @@ -1172,7 +1169,12 @@ task copyHelp(type: Copy) { task copyResources(type: Copy) { - from(resourceDir) { + def inputDir = resourceDir + def outputDir = resourcesBuildDir + from(inputDir) { + exclude '**/*.gif' + exclude '**/*.jpg' + exclude '**/*.png' filter(ReplaceTokens, beginToken: '$$', endToken: '$$', @@ -1182,11 +1184,15 @@ task copyResources(type: Copy) { ] ) } - include "**/*.*" - into "${resourcesBuildDir}" - //preserve { - // include "**" - //} + from(inputDir) { + include '**/*.gif' + include '**/*.jpg' + include '**/*.png' + } + into outputDir + + inputs.dir(inputDir) + outputs.dir(outputDir) } @@ -1197,10 +1203,6 @@ task createBuildProperties(type: WriteProperties) { inputs.dir(sourceDir) inputs.dir(resourcesBuildDir) -//println("MKDIRS "+file(buildProperties).getParentFile().toString()) -// doFirst { -// file(buildProperties).getParentFile().mkdirs() -// } outputFile (buildProperties) // taking time specific comment out to allow better incremental builds comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss") @@ -1216,19 +1218,24 @@ task prepare { dependsOn copyResources dependsOn copyDocs dependsOn copyHelp + dependsOn createBuildProperties + dependsOn convertMdFiles } -jar.dependsOn prepare + + +compileJava.dependsOn prepare +run.dependsOn compileJava +//run.dependsOn prepare //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir test { dependsOn prepare - //dependsOn compileJava ////? DELETE if (useClover) { dependsOn cloverClasses } else { //? - dependsOn compileJava //? + dependsOn compileJava //? } useTestNG() { @@ -1241,7 +1248,6 @@ test { maxHeapSize = "1024m" workingDir = jalviewDir - //systemProperties 'clover.jar' System.properties.clover.jar def testLaf = project.findProperty("test_laf") if (testLaf != null) { println("Setting Test LaF to '${testLaf}'") @@ -1263,7 +1269,7 @@ task buildIndices(type: JavaExec) { dependsOn copyHelp classpath = sourceSets.main.compileClasspath main = "com.sun.java.help.search.Indexer" - workingDir = "${helpBuildDir}" + workingDir = "${helpBuildDir}/${help_dir}" def argDir = "html" args = [ argDir ] inputs.dir("${workingDir}/${argDir}") @@ -1299,8 +1305,7 @@ task linkCheck(type: JavaExec) { classpath = files("${jalviewDir}/${utils_dir}") main = "HelpLinksChecker" workingDir = jalviewDir - def helpBuildDir = "${helpBuildDir}" - args = [ helpBuildDir, "-nointernet" ] + args = [ "${helpBuildDir}/${help_dir}", "-nointernet" ] def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append def errFOS = outFOS @@ -1315,9 +1320,10 @@ task linkCheck(type: JavaExec) { outputs.file(helpLinksCheckerOutFile) } + // import the pubhtmlhelp target ant.properties.basedir = "${jalviewDir}" -ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${helpBuildDir}" +ant.properties.helpBuildDir = "${helpBuildDir}/${help_dir}" ant.importBuild "${utils_dir}/publishHelp.xml" @@ -1332,6 +1338,7 @@ jar { dependsOn linkCheck dependsOn buildIndices dependsOn createBuildProperties + dependsOn prepare manifest { attributes "Main-Class": main_class, @@ -1350,8 +1357,11 @@ jar { exclude "**/*.jar" exclude "**/*.jar.*" - inputs.dir(classesDir) - outputs.file("${jalviewDir}/${package_dir}/${archiveFileName}") + inputs.dir(sourceSets.main.java.outputDir) + sourceSets.main.resources.srcDirs.each{ dir -> + inputs.dir(dir) + } + outputs.file("${destinationDirectory}/${archiveFileName}") } @@ -1391,6 +1401,7 @@ task cleanDist { dependsOn clean } + shadowJar { group = "distribution" description = "Create a single jar file with all dependency libraries merged. Can be run with java -jar" @@ -1965,7 +1976,7 @@ task helppages { dependsOn copyHelp dependsOn pubhtmlhelp - inputs.dir("${helpBuildDir}") + inputs.dir("${helpBuildDir}/${help_dir}") outputs.dir("${buildDir}/distributions/${help_dir}") } -- 1.7.10.2