1 import org.apache.tools.ant.filters.ReplaceTokens
2 //import org.apache.tools.ant.filters.ReplaceRegexp
3 import org.gradle.internal.os.OperatingSystem
4 import org.gradle.plugins.ide.eclipse.model.*
7 import groovy.transform.ExternalizeMethods
11 classpath 'org.openclover:clover:4.3.1'
12 classpath 'org.apache.commons:commons-compress:1.18'
20 id 'com.github.johnrengelman.shadow' version '4.0.3'
21 id 'com.install4j.gradle' version '7.0.9'
33 mainClassName = launcherClass
34 def cloverInstrDir = file("$buildDir/$cloverSourcesInstrDir")
35 def classes = "$jalviewDir/$classesDir"
37 if (clover.equals("true")) {
39 classes = "$buildDir/$cloverClassesDir"
42 classes = "$jalviewDir/$classesDir"
45 // configure classpath/args for j8/j11 compilation
47 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
50 def compile_source_compatibility
51 def compile_target_compatibility
54 getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION
56 reportRsyncCmd = false
58 buildProperties = buildPropertiesFile
62 // TODO: get bamboo build artifact URL for getdown artifacts
63 getdown_app_dir = getdown_app_dir_alt
64 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
68 getdown_channel_name = CHANNEL.toLowerCase()
69 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
70 getdown_app_base = getdown_channel_base + "/" + getdownDir
71 getdown_app_dir = getdown_app_dir_release
72 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
73 reportRsyncCommand = true
77 getdown_channel_name = CHANNEL.toLowerCase()+"/"+JALVIEW_VERSION
78 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
79 getdown_app_base = getdown_channel_base + "/" + getdownDir
80 getdown_app_dir = getdown_app_dir_alt
81 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
82 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
85 packageDir = ARCHIVEDIR + "/" + packageDir
86 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
89 reportRsyncCommand = true
93 getdown_channel_name = "archive" + "/" + JALVIEW_VERSION
94 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
95 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
96 getdown_app_dir = getdown_app_dir_alt
97 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
98 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
101 packageDir = ARCHIVEDIR + "/" + packageDir
102 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
105 reportRsyncCommand = true
109 getdown_channel_name = CHANNEL.toLowerCase()
110 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
111 getdown_app_base = getdown_channel_base + "/" + getdownDir
112 getdown_app_dir = getdown_app_dir_alt
113 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
114 reportRsyncCommand = true
118 getdown_channel_name = CHANNEL.toLowerCase()
119 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
120 getdown_app_base = getdown_channel_base + "/" + getdownDir
121 getdown_app_dir = getdown_app_dir_alt
122 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
123 reportRsyncCommand = true
126 case ~/^SCRATCH(|-\w*)$/:
127 getdown_channel_name = CHANNEL
128 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
129 getdown_app_base = getdown_channel_base + "/" + getdownDir
130 getdown_app_dir = getdown_app_dir_alt
131 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
132 reportRsyncCommand = true
136 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
137 getdown_app_dir = getdown_app_dir_alt
138 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
141 default: // something wrong specified
142 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
148 println("Using a "+CHANNEL+" profile. appbase="+getdown_app_base)
149 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
150 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
151 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
152 getdownInstallDir = getdownWebsiteDir + '/' + getdown_install_dir
153 getdownLauncher = jalviewDir + '/' + getdown_launcher
154 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
155 getdownFilesInstallDir = getdownFilesDir+"/"+getdown_install_dir
156 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
157 modules_runtimeClasspath = modules_compileClasspath
162 def JAVA_INTEGER_VERSION
163 def additional_compiler_args = []
164 // these are getdown.txt properties defined dependent on the JAVA_VERSION
165 def getdown_alt_java_min_version
166 // this property is assigned below and expanded to multiple lines in the getdown task
167 def getdown_alt_multi_java_location
168 // this property is for the Java library used in eclipse
169 def eclipse_java_runtime_name
170 if (JAVA_VERSION.equals("1.8")) {
171 JAVA_INTEGER_VERSION = "8"
174 libDistDir = j8libDir
175 compile_source_compatibility = 1.8
176 compile_target_compatibility = 1.8
177 getdown_alt_java_min_version = getdown_alt_java8_min_version
178 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
179 eclipse_java_runtime_name = "JavaSE-1.8"
180 } else if (JAVA_VERSION.equals("11")) {
181 JAVA_INTEGER_VERSION = "11"
183 libDistDir = j11libDir
184 compile_source_compatibility = 11
185 compile_target_compatibility = 11
186 getdown_alt_java_min_version = getdown_alt_java11_min_version
187 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
188 eclipse_java_runtime_name = "JavaSE-11"
189 additional_compiler_args += [
190 '--module-path', ext.modules_compileClasspath.asPath,
191 '--add-modules', j11modules
193 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
194 JAVA_INTEGER_VERSION = JAVA_VERSION
196 libDistDir = j11libDir
197 compile_source_compatibility = JAVA_VERSION
198 compile_target_compatibility = JAVA_VERSION
199 getdown_alt_java_min_version = getdown_alt_java11_min_version
200 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
201 eclipse_java_runtime_name = "JavaSE-11"
202 additional_compiler_args += [
203 '--module-path', ext.modules_compileClasspath.asPath,
204 '--add-modules', j11modules
207 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
214 srcDirs "$jalviewDir/$sourceDir"
215 outputDir = file("$classes")
219 srcDirs "$jalviewDir/$resourceDir"
222 jar.destinationDir = file("$jalviewDir/$packageDir")
224 compileClasspath = files(sourceSets.main.java.outputDir)
225 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
227 runtimeClasspath = compileClasspath
231 srcDirs = [ cloverInstrDir ]
232 outputDir = file("${buildDir}/${cloverClassesDir}")
236 srcDirs = sourceSets.main.resources.srcDirs
238 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
239 compileClasspath += files(sourceSets.main.java.outputDir)
240 compileClasspath += sourceSets.main.compileClasspath
241 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
242 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
244 runtimeClasspath = compileClasspath
249 srcDirs "$jalviewDir/$testSourceDir"
250 outputDir = file("$jalviewDir/$testOutputDir")
254 srcDirs = sourceSets.main.resources.srcDirs
257 compileClasspath = files( sourceSets.test.java.outputDir )
260 compileClasspath += sourceSets.clover.compileClasspath
262 compileClasspath += files(sourceSets.main.java.outputDir)
265 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
266 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
268 runtimeClasspath = compileClasspath
275 cloverCompile 'org.openclover:clover:4.3.1'
276 testCompile 'org.openclover:clover:4.3.1'
282 cloverRuntime.extendsFrom cloverCompile
287 name = "Jalview with gradle build"
289 natures 'org.eclipse.jdt.core.javanature',
290 'org.eclipse.jdt.groovy.core.groovyNature',
291 'org.eclipse.buildship.core.gradleprojectnature'
293 buildCommand 'org.eclipse.jdt.core.javabuilder'
294 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
298 //defaultOutputDir = sourceSets.main.java.outputDir
300 configurations.each{ if (it.isCanBeResolved()) {
305 minusConfigurations += removeThese
306 plusConfigurations = [ ]
310 def removeTheseToo = []
311 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
312 cp.entries.each { entry ->
313 if (entry.kind == 'src') {
314 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
315 removeTheseToo += entry
317 addedSrcPath.putAt(entry.path, true)
321 cp.entries.removeAll(removeTheseToo)
323 print ("CP="+cp.inspect())
325 cp.entries += new Output("bin/main")
326 cp.entries += new Library(fileReference(helpParentDir))
327 cp.entries += new Library(fileReference(resourceDir))
329 HashMap<String, Boolean> addedLibPath = new HashMap<>();
331 // changing from sourcesets.main.classpath to specific Java version lib
332 //sourceSets.main.compileClasspath.each{
333 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
334 //don't want to add outputDir as eclipse is using its own output dir in bin/main
335 if (it.isDirectory() || ! it.exists()) {
336 // don't add dirs to classpath
339 def itPath = it.toString()
340 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
341 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
343 if (addedLibPath.get(itPath)) {
344 //println("Not adding duplicate entry "+itPath)
346 //println("Adding entry "+itPath)
347 cp.entries += new Library(fileReference(itPath))
348 addedLibPath.put(itPath, true)
352 // changing from sourcesets.main.classpath to specific Java version lib
353 //sourceSets.test.compileClasspath.each{
354 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
355 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
356 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
357 if (it.isDirectory() || ! it.exists()) {
358 // don't add dirs to classpath
359 return false // groovy "break" in .each loop
361 def itPath = it.toString()
362 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
363 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
365 if (addedLibPath.get(itPath)) {
368 def lib = new Library(fileReference(itPath))
369 // this doesn't work... yet. Adding test=true attribute using withXml below
370 //def attrs = new Node(null, 'attributes', ["test":"true"])
371 //lib.appendNode(attrs) //
373 addedLibPath.put(itPath, true)
378 // withXml changes ignored by buildship, these add the "test=true" attribute
380 def node = it.asNode()
382 def srcTestAttributes
383 node.children().each{ cpe ->
384 def attributes = cpe.attributes()
385 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
386 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
390 def addTestAttribute = true
391 srcTestAttributes.each{a ->
392 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
393 addTestAttribute = false
396 if (addTestAttribute) {
397 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
400 node.children().each{ cpe ->
401 def attributes = cpe.attributes()
402 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
403 cpe.appendNode('attributes')
404 .appendNode('attribute', [name:"test", value:"true"])
410 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
414 // for the IDE, use java 11 compatibility
415 sourceCompatibility = compile_source_compatibility
416 targetCompatibility = compile_target_compatibility
417 javaRuntimeName = eclipse_java_runtime_name
420 withProperties { props ->
421 def jalview_prefs = new Properties()
422 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
423 jalview_prefs.load(ins)
425 jalview_prefs.forEach { t, v ->
426 if (props.getAt(t) == null) {
434 //synchronizationTasks eclipseClasspath
435 //autoBuildTasks eclipseClasspath
439 // only instrument source, we build test classes as normal
440 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
441 outputs.dir cloverInstrDir
444 delete cloverInstrDir
445 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
446 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
447 argsList.addAll(inputs.files.files.collect({ file ->
450 String[] args = argsList.toArray()
451 println("About to instrument "+args.length +" files")
452 com.atlassian.clover.CloverInstr.mainImpl(args)
458 group = "Verification"
459 description = "Createst the Clover report"
460 inputs.dir "${buildDir}/clover"
461 outputs.dir "${reportsDir}/clover"
463 file("${buildDir}/clover/clover.db").exists()
466 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
467 "-o", "${reportsDir}/clover"]
468 String[] args = argsList.toArray()
469 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
471 // and generate ${reportsDir}/clover/clover.xml
472 args = ["--initstring", "${buildDir}/clover/clover.db",
473 "-o", "${reportsDir}/clover/clover.xml"].toArray()
474 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
484 sourceCompatibility = compile_source_compatibility
485 targetCompatibility = compile_target_compatibility
486 options.compilerArgs = additional_compiler_args
487 print ("Setting target compatibility to "+targetCompatibility+"\n")
494 dependsOn compileCloverJava
495 classpath += configurations.cloverRuntime
497 classpath += sourceSets.main.runtimeClasspath
500 sourceCompatibility = compile_source_compatibility
501 targetCompatibility = compile_target_compatibility
502 options.compilerArgs = additional_compiler_args
503 print ("Setting target compatibility to "+targetCompatibility+"\n")
511 sourceCompatibility = compile_source_compatibility
512 targetCompatibility = compile_target_compatibility
513 options.compilerArgs += additional_compiler_args
514 print ("Setting target compatibility to "+targetCompatibility+"\n")
516 classpath += configurations.cloverRuntime
520 delete sourceSets.main.java.outputDir
524 delete sourceSets.test.java.outputDir
525 delete cloverInstrDir
528 // format is a string like date.format("dd MMMM yyyy")
529 def getDate(format) {
530 def date = new Date()
531 return date.format(format)
535 def hashStdOut = new ByteArrayOutputStream()
537 commandLine "git", "rev-parse", "--short", "HEAD"
538 standardOutput = hashStdOut
542 def branchStdOut = new ByteArrayOutputStream()
544 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
545 standardOutput = branchStdOut
549 project.ext.gitHash = hashStdOut.toString().trim()
550 project.ext.gitBranch = branchStdOut.toString().trim()
552 outputs.upToDateWhen { false }
555 task createBuildProperties(type: WriteProperties) {
557 inputs.dir("$jalviewDir/$sourceDir")
558 inputs.dir("$classes")
559 inputs.dir("$jalviewDir/$resourceDir")
560 outputFile (buildProperties)
561 // taking time specific comment out to allow better incremental builds
562 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
563 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
564 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
565 property "VERSION", JALVIEW_VERSION
566 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
567 outputs.file(outputFile)
570 def buildingHTML = "$jalviewDir/$docDir/building.html"
571 task deleteBuildingHTML(type: Delete) {
575 task convertBuildingMD(type: Exec) {
576 dependsOn deleteBuildingHTML
577 def buildingMD = "$jalviewDir/$docDir/building.md"
578 def css = "$jalviewDir/$docDir/github.css"
581 pandoc_exec.split(",").each {
582 if (file(it.trim()).exists()) {
588 def hostname = "hostname".execute().text.trim()
589 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
590 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
593 if (pandoc != null && file(pandoc).exists()) {
594 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
601 inputs.file(buildingMD)
603 outputs.file(buildingHTML)
609 task syncDocs(type: Sync) {
610 dependsOn convertBuildingMD
611 def syncDir = "$classes/$docDir"
612 from fileTree("$jalviewDir/$docDir")
617 def helpFile = "$classes/$helpDir/help.jhm"
619 task copyHelp(type: Copy) {
620 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
621 def outputDir = "$classes/$helpDir"
626 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
636 outputs.files(helpFile)
637 outputs.dir(outputDir)
640 task syncLib(type: Sync) {
641 def syncDir = "$classes/$libDistDir"
642 from fileTree("$jalviewDir/$libDistDir")
646 task syncResources(type: Sync) {
647 from "$jalviewDir/$resourceDir"
657 dependsOn syncResources
663 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
666 dependsOn compileJava
668 dependsOn cloverInstr
672 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
676 includeGroups testngGroups
678 useDefaultListeners=true
681 workingDir = jalviewDir
682 //systemProperties 'clover.jar' System.properties.clover.jar
683 sourceCompatibility = compile_source_compatibility
684 targetCompatibility = compile_target_compatibility
685 jvmArgs += additional_compiler_args
686 print ("Setting target compatibility to "+targetCompatibility+"\n")
689 task buildIndices(type: JavaExec) {
691 classpath = sourceSets.main.compileClasspath
692 main = "com.sun.java.help.search.Indexer"
693 workingDir = "$classes/$helpDir"
696 inputs.dir("$workingDir/$argDir")
698 outputs.dir("$classes/doc")
699 outputs.dir("$classes/help")
700 outputs.file("$workingDir/JavaHelpSearch/DOCS")
701 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
702 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
703 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
704 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
705 outputs.file("$workingDir/JavaHelpSearch/TMAP")
708 task compileLinkCheck(type: JavaCompile) {
710 classpath = files("$jalviewDir/$utilsDir")
711 destinationDir = file("$jalviewDir/$utilsDir")
712 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
714 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
715 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
716 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
717 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
720 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
721 task linkCheck(type: JavaExec) {
722 dependsOn prepare, compileLinkCheck
723 classpath = files("$jalviewDir/$utilsDir")
724 main = "HelpLinksChecker"
725 workingDir = jalviewDir
726 def help = "$classes/$helpDir"
727 args = [ "$classes/$helpDir", "-nointernet" ]
730 helplinkscheckeroutputfile.createNewFile()
731 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
734 outputs.file(helplinkscheckeroutputfile)
737 task cleanPackageDir(type: Delete) {
738 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
743 dependsOn buildIndices
744 dependsOn createBuildProperties
747 attributes "Main-Class": mainClass,
748 "Permissions": "all-permissions",
749 "Application-Name": "Jalview Desktop",
750 "Codebase": application_codebase
753 destinationDir = file("$jalviewDir/$packageDir")
754 archiveName = rootProject.name+".jar"
762 inputs.dir("$classes")
763 outputs.file("$jalviewDir/$packageDir/$archiveName")
766 task copyJars(type: Copy) {
767 from fileTree("$classes").include("**/*.jar").include("*.jar").files
768 into "$jalviewDir/$packageDir"
771 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
772 task syncJars(type: Sync) {
773 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
774 into "$jalviewDir/$packageDir"
776 include jar.archiveName
782 description = "Put all required libraries in dist"
783 // order of "cleanPackageDir", "copyJars", "jar" important!
784 jar.mustRunAfter cleanPackageDir
785 syncJars.mustRunAfter cleanPackageDir
786 dependsOn cleanPackageDir
789 outputs.dir("$jalviewDir/$packageDir")
793 dependsOn cleanPackageDir
799 group = "distribution"
803 from ("$jalviewDir/$libDistDir") {
807 attributes 'Implementation-Version': JALVIEW_VERSION
809 mainClassName = shadowJarMainClass
811 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
815 task getdownWebsite() {
816 group = "distribution"
817 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
822 // clean the getdown website and files dir before creating getdown folders
823 delete project.ext.getdownWebsiteDir
824 delete project.ext.getdownFilesDir
826 def getdownWebsiteResourceFilenames = []
827 def getdownTextString = ""
828 def getdownResourceDir = project.ext.getdownResourceDir
829 def getdownAppDir = project.ext.getdownAppDir
830 def getdownResourceFilenames = []
835 rename(buildPropertiesFile, getdown_build_properties)
836 into project.ext.getdownWebsiteDir
838 getdownWebsiteResourceFilenames += getdown_build_properties
840 // go through properties looking for getdown_txt_...
841 def props = project.properties.sort { it.key }
842 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
843 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
845 props.put("getdown_txt_appbase", getdown_app_base)
846 props.each{ prop, val ->
847 if (prop.startsWith("getdown_txt_") && val != null) {
848 if (prop.startsWith("getdown_txt_multi_")) {
849 def key = prop.substring(18)
850 val.split(",").each{ v ->
851 def line = key + " = " + v + "\n"
852 getdownTextString += line
855 // file values rationalised
856 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
858 if (val.indexOf('/') == 0) {
861 } else if (val.indexOf('/') > 0) {
862 // relative path (relative to jalviewDir)
863 r = file( jalviewDir + '/' + val )
866 val = getdown_resource_dir + '/' + r.getName()
867 getdownWebsiteResourceFilenames += val
868 getdownResourceFilenames += r.getPath()
871 if (! prop.startsWith("getdown_txt_resource")) {
872 def line = prop.substring(12) + " = " + val + "\n"
873 getdownTextString += line
879 getdownWebsiteResourceFilenames.each{ filename ->
880 getdownTextString += "resource = "+filename+"\n"
882 getdownResourceFilenames.each{ filename ->
885 into project.ext.getdownResourceDir
890 fileTree(file(packageDir)).each{ f ->
891 if (f.isDirectory()) {
892 def files = fileTree(dir: f, include: ["*"]).getFiles()
894 } else if (f.exists()) {
898 codeFiles.sort().each{f ->
899 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
900 getdownTextString += line
903 into project.ext.getdownAppDir
907 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
909 if (JAVA_VERSION.equals("11")) {
910 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
911 j11libFiles.sort().each{f ->
912 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
913 getdownTextString += line
916 into project.ext.getdownJ11libDir
922 // getdown-launcher.jar should not be in main application class path so the main application can move it when updated. Listed as a resource so it gets updated.
923 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
924 getdownTextString += "resource = " + getdown_launcher_new + "\n"
925 getdownTextString += "class = " + mainClass + "\n"
927 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
928 getdown_txt.write(getdownTextString)
930 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
931 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
935 rename(file(getdownLauncher).getName(), getdown_launcher_new)
936 into project.ext.getdownWebsiteDir
941 into project.ext.getdownWebsiteDir
944 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
948 from getdownWebsiteDir+"/"+getdown_build_properties
949 into getdownInstallDir
953 from getdownInstallDir
954 into getdownFilesInstallDir
962 from getdownWebsiteDir+"/"+getdown_build_properties
967 from getdownResourceDir
968 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
973 inputs.dir(jalviewDir + '/' + packageDir)
975 outputs.dir(project.ext.getdownWebsiteDir)
976 outputs.dir(project.ext.getdownFilesDir)
979 task getdownDigest(type: JavaExec) {
980 group = "distribution"
981 description = "Digest the getdown website folder"
982 dependsOn getdownWebsite
983 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
984 main = "com.threerings.getdown.tools.Digester"
985 args project.ext.getdownWebsiteDir
986 inputs.dir(project.ext.getdownWebsiteDir)
987 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
991 group = "distribution"
992 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
993 dependsOn getdownDigest
995 if (reportRsyncCommand) {
996 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
997 def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
998 println "LIKELY RSYNC COMMAND:"
999 println "rsync -avh --delete '$fromDir' '$toDir'"
1000 if (RUNRSYNC == "true") {
1002 commandLine "mkdir", "-p", toDir
1005 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1013 delete project.ext.getdownWebsiteDir
1014 delete project.ext.getdownFilesDir
1018 def install4jHomeDir = "/opt/install4j"
1019 def hostname = "hostname".execute().text.trim()
1020 if (hostname.equals("jv-bamboo")) {
1021 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1022 } else if (OperatingSystem.current().isMacOsX()) {
1023 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1024 if (! file(install4jHomeDir).exists()) {
1025 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1027 } else if (OperatingSystem.current().isLinux()) {
1028 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1030 installDir = file(install4jHomeDir)
1031 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1032 if (install4jFaster.equals("true")) {
1040 def windowsJavaVMDir
1041 def windowsJavaVMTgz
1042 def install4jDir = "$jalviewDir/$install4jResourceDir"
1043 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
1044 install4jConf = "$install4jDir/$install4jConfFile"
1046 task copyInstall4jTemplate(type: Copy) {
1047 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
1048 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
1049 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
1050 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
1051 from (install4jDir) {
1052 include install4jTemplate
1053 rename (install4jTemplate, install4jConfFile)
1054 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1055 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1057 'JAVA_VERSION': JAVA_VERSION,
1058 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1059 'VERSION': JALVIEW_VERSION,
1060 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1061 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1062 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1063 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1064 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1065 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1066 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1067 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1068 'GETDOWN_DIST_DIR': getdown_app_dir,
1069 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1070 'GETDOWN_INSTALL_DIR': getdown_install_dir
1073 if (OSX_KEYPASS=="") {
1074 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1075 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1079 outputs.files(install4jConf)
1082 // include file associations in installer
1083 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
1087 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1088 replace: installerFileAssociationsXml,
1092 // include uninstaller applescript app files in dmg
1093 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1097 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1098 replace: installerDMGUninstallerXml,
1105 task installers(type: com.install4j.gradle.Install4jTask) {
1106 group = "distribution"
1107 description = "Create the install4j installers"
1109 dependsOn copyInstall4jTemplate
1110 projectFile = file(install4jConf)
1111 println("Using projectFile "+projectFile)
1112 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1113 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
1114 buildSelected = true
1117 macKeystorePassword=OSX_KEYPASS
1121 inputs.dir(project.ext.getdownWebsiteDir)
1122 inputs.file(install4jConf)
1123 inputs.dir(macosJavaVMDir)
1124 inputs.dir(windowsJavaVMDir)
1125 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1130 delete install4jConf