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 // where the getdown channel will be built.
55 // TODO: consider allowing this expression to be overridden by -P arg
56 getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION
57 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
58 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
59 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
60 getdownLauncher = jalviewDir + '/' + getdown_launcher
61 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
62 getdown_app_base = getdown_channel_base+"/"+getdown_channel_name+"/"+JAVA_VERSION+"/"
63 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
64 modules_runtimeClasspath = modules_compileClasspath
69 def JAVA_INTEGER_VERSION
70 def additional_compiler_args = []
71 // these are getdown.txt properties defined dependent on the JAVA_VERSION
72 def getdown_alt_java_min_version
73 // this property is assigned below and expanded to multiple lines in the getdown task
74 def getdown_alt_multi_java_location
75 // this property is for the Java library used in eclipse
76 def eclipse_java_runtime_name
77 if (JAVA_VERSION.equals("1.8")) {
78 JAVA_INTEGER_VERSION = "8"
82 compile_source_compatibility = 1.8
83 compile_target_compatibility = 1.8
84 getdown_alt_java_min_version = getdown_alt_java8_min_version
85 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
86 eclipse_java_runtime_name = "JavaSE-1.8"
87 } else if (JAVA_VERSION.equals("11")) {
88 JAVA_INTEGER_VERSION = "11"
90 libDistDir = j11libDir
91 compile_source_compatibility = 11
92 compile_target_compatibility = 11
93 getdown_alt_java_min_version = getdown_alt_java11_min_version
94 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
95 eclipse_java_runtime_name = "JavaSE-11"
96 additional_compiler_args += [
97 '--module-path', ext.modules_compileClasspath.asPath,
98 '--add-modules', j11modules
100 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
101 JAVA_INTEGER_VERSION = JAVA_VERSION
103 libDistDir = j11libDir
104 compile_source_compatibility = JAVA_VERSION
105 compile_target_compatibility = JAVA_VERSION
106 getdown_alt_java_min_version = getdown_alt_java11_min_version
107 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
108 eclipse_java_runtime_name = "JavaSE-11"
109 additional_compiler_args += [
110 '--module-path', ext.modules_compileClasspath.asPath,
111 '--add-modules', j11modules
114 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
121 srcDirs "$jalviewDir/$sourceDir"
122 outputDir = file("$classes")
126 srcDirs "$jalviewDir/$resourceDir"
129 jar.destinationDir = file("$jalviewDir/$packageDir")
131 compileClasspath = files(sourceSets.main.java.outputDir)
132 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
134 runtimeClasspath = compileClasspath
138 srcDirs = [ cloverInstrDir ]
139 outputDir = file("${buildDir}/${cloverClassesDir}")
143 srcDirs = sourceSets.main.resources.srcDirs
145 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
146 compileClasspath += files(sourceSets.main.java.outputDir)
147 compileClasspath += sourceSets.main.compileClasspath
148 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
149 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
151 runtimeClasspath = compileClasspath
156 srcDirs "$jalviewDir/$testSourceDir"
157 outputDir = file("$jalviewDir/$testOutputDir")
161 srcDirs = sourceSets.main.resources.srcDirs
164 compileClasspath = files( sourceSets.test.java.outputDir )
167 compileClasspath += sourceSets.clover.compileClasspath
169 compileClasspath += files(sourceSets.main.java.outputDir)
172 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
173 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
175 runtimeClasspath = compileClasspath
182 cloverCompile 'org.openclover:clover:4.3.1'
183 testCompile 'org.openclover:clover:4.3.1'
189 cloverRuntime.extendsFrom cloverCompile
194 name = "Jalview with gradle build"
196 natures 'org.eclipse.jdt.core.javanature',
197 'org.eclipse.jdt.groovy.core.groovyNature',
198 'org.eclipse.buildship.core.gradleprojectnature'
200 buildCommand 'org.eclipse.jdt.core.javabuilder'
201 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
205 //defaultOutputDir = sourceSets.main.java.outputDir
207 configurations.each{ if (it.isCanBeResolved()) {
212 minusConfigurations += removeThese
213 plusConfigurations = [ ]
217 def removeTheseToo = []
218 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
219 cp.entries.each { entry ->
220 if (entry.kind == 'src') {
221 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
222 removeTheseToo += entry
224 addedSrcPath.putAt(entry.path, true)
228 cp.entries.removeAll(removeTheseToo)
230 print ("CP="+cp.inspect())
232 cp.entries += new Output("bin/main")
233 cp.entries += new Library(fileReference(helpParentDir))
234 cp.entries += new Library(fileReference(resourceDir))
236 HashMap<String, Boolean> addedLibPath = new HashMap<>();
238 // changing from sourcesets.main.classpath to specific Java version lib
239 //sourceSets.main.compileClasspath.each{
240 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
241 //don't want to add outputDir as eclipse is using its own output dir in bin/main
242 if (it.isDirectory() || ! it.exists()) {
243 // don't add dirs to classpath
246 def itPath = it.toString()
247 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
248 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
250 if (addedLibPath.get(itPath)) {
251 //println("Not adding duplicate entry "+itPath)
253 //println("Adding entry "+itPath)
254 cp.entries += new Library(fileReference(itPath))
255 addedLibPath.put(itPath, true)
259 // changing from sourcesets.main.classpath to specific Java version lib
260 //sourceSets.test.compileClasspath.each{
261 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
262 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
263 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
264 if (it.isDirectory() || ! it.exists()) {
265 // don't add dirs to classpath
266 return false // groovy "break" in .each loop
268 def itPath = it.toString()
269 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
270 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
272 if (addedLibPath.get(itPath)) {
275 def lib = new Library(fileReference(itPath))
276 // this doesn't work... yet. Adding test=true attribute using withXml below
277 //def attrs = new Node(null, 'attributes', ["test":"true"])
278 //lib.appendNode(attrs) //
280 addedLibPath.put(itPath, true)
285 // withXml changes ignored by buildship, these add the "test=true" attribute
287 def node = it.asNode()
289 def srcTestAttributes
290 node.children().each{ cpe ->
291 def attributes = cpe.attributes()
292 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
293 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
297 def addTestAttribute = true
298 srcTestAttributes.each{a ->
299 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
300 addTestAttribute = false
303 if (addTestAttribute) {
304 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
307 node.children().each{ cpe ->
308 def attributes = cpe.attributes()
309 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
310 cpe.appendNode('attributes')
311 .appendNode('attribute', [name:"test", value:"true"])
317 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
321 // for the IDE, use java 11 compatibility
322 sourceCompatibility = compile_source_compatibility
323 targetCompatibility = compile_target_compatibility
324 javaRuntimeName = eclipse_java_runtime_name
327 withProperties { props ->
328 def jalview_prefs = new Properties()
329 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
330 jalview_prefs.load(ins)
332 jalview_prefs.forEach { t, v ->
333 if (props.getAt(t) == null) {
341 //synchronizationTasks eclipseClasspath
342 //autoBuildTasks eclipseClasspath
346 // only instrument source, we build test classes as normal
347 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
348 outputs.dir cloverInstrDir
351 delete cloverInstrDir
352 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
353 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
354 argsList.addAll(inputs.files.files.collect({ file ->
357 String[] args = argsList.toArray()
358 println("About to instrument "+args.length +" files")
359 com.atlassian.clover.CloverInstr.mainImpl(args)
365 group = "Verification"
366 description = "Createst the Clover report"
367 inputs.dir "${buildDir}/clover"
368 outputs.dir "${reportsDir}/clover"
370 file("${buildDir}/clover/clover.db").exists()
373 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
374 "-o", "${reportsDir}/clover"]
375 String[] args = argsList.toArray()
376 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
378 // and generate ${reportsDir}/clover/clover.xml
379 args = ["--initstring", "${buildDir}/clover/clover.db",
380 "-o", "${reportsDir}/clover/clover.xml"].toArray()
381 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
391 sourceCompatibility = compile_source_compatibility
392 targetCompatibility = compile_target_compatibility
393 options.compilerArgs = additional_compiler_args
394 print ("Setting target compatibility to "+targetCompatibility+"\n")
401 dependsOn compileCloverJava
402 classpath += configurations.cloverRuntime
404 classpath += sourceSets.main.runtimeClasspath
407 sourceCompatibility = compile_source_compatibility
408 targetCompatibility = compile_target_compatibility
409 options.compilerArgs = additional_compiler_args
410 print ("Setting target compatibility to "+targetCompatibility+"\n")
418 sourceCompatibility = compile_source_compatibility
419 targetCompatibility = compile_target_compatibility
420 options.compilerArgs += additional_compiler_args
421 print ("Setting target compatibility to "+targetCompatibility+"\n")
423 classpath += configurations.cloverRuntime
427 delete sourceSets.main.java.outputDir
431 delete sourceSets.test.java.outputDir
432 delete cloverInstrDir
435 // format is a string like date.format("dd MMMM yyyy")
436 def getDate(format) {
437 def date = new Date()
438 return date.format(format)
442 def hashStdOut = new ByteArrayOutputStream()
444 commandLine "git", "rev-parse", "--short", "HEAD"
445 standardOutput = hashStdOut
449 def branchStdOut = new ByteArrayOutputStream()
451 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
452 standardOutput = branchStdOut
456 project.ext.gitHash = hashStdOut.toString().trim()
457 project.ext.gitBranch = branchStdOut.toString().trim()
459 outputs.upToDateWhen { false }
462 task createBuildProperties(type: WriteProperties) {
464 inputs.dir("$jalviewDir/$sourceDir")
465 inputs.dir("$classes")
466 inputs.dir("$jalviewDir/$resourceDir")
467 outputFile "$classes/$buildPropertiesFile"
468 // taking time specific comment out to allow better incremental builds
469 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
470 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
471 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
472 property "VERSION", JALVIEW_VERSION
473 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
474 outputs.file(outputFile)
477 def buildingHTML = "$jalviewDir/$docDir/building.html"
478 task deleteBuildingHTML(type: Delete) {
482 task convertBuildingMD(type: Exec) {
483 dependsOn deleteBuildingHTML
484 def buildingMD = "$jalviewDir/$docDir/building.md"
485 def css = "$jalviewDir/$docDir/github.css"
488 pandoc_exec.split(",").each {
489 if (file(it.trim()).exists()) {
495 def hostname = "hostname".execute().text.trim()
496 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
497 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
500 if (pandoc != null && file(pandoc).exists()) {
501 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
508 inputs.file(buildingMD)
510 outputs.file(buildingHTML)
516 task syncDocs(type: Sync) {
517 dependsOn convertBuildingMD
518 def syncDir = "$classes/$docDir"
519 from fileTree("$jalviewDir/$docDir")
524 def helpFile = "$classes/$helpDir/help.jhm"
526 task copyHelp(type: Copy) {
527 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
528 def outputDir = "$classes/$helpDir"
533 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
543 outputs.files(helpFile)
544 outputs.dir(outputDir)
547 task syncLib(type: Sync) {
548 def syncDir = "$classes/$libDistDir"
549 from fileTree("$jalviewDir/$libDistDir")
553 task syncResources(type: Sync) {
554 from "$jalviewDir/$resourceDir"
564 dependsOn syncResources
570 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
573 dependsOn compileJava
575 dependsOn cloverInstr
578 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
581 includeGroups testngGroups
583 useDefaultListeners=true
586 workingDir = jalviewDir
587 //systemProperties 'clover.jar' System.properties.clover.jar
588 sourceCompatibility = compile_source_compatibility
589 targetCompatibility = compile_target_compatibility
590 jvmArgs += additional_compiler_args
591 print ("Setting target compatibility to "+targetCompatibility+"\n")
594 task buildIndices(type: JavaExec) {
596 classpath = sourceSets.main.compileClasspath
597 main = "com.sun.java.help.search.Indexer"
598 workingDir = "$classes/$helpDir"
601 inputs.dir("$workingDir/$argDir")
603 outputs.dir("$classes/doc")
604 outputs.dir("$classes/help")
605 outputs.file("$workingDir/JavaHelpSearch/DOCS")
606 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
607 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
608 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
609 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
610 outputs.file("$workingDir/JavaHelpSearch/TMAP")
613 task compileLinkCheck(type: JavaCompile) {
615 classpath = files("$jalviewDir/$utilsDir")
616 destinationDir = file("$jalviewDir/$utilsDir")
617 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
619 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
620 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
621 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
622 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
625 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
626 task linkCheck(type: JavaExec) {
627 dependsOn prepare, compileLinkCheck
628 classpath = files("$jalviewDir/$utilsDir")
629 main = "HelpLinksChecker"
630 workingDir = jalviewDir
631 def help = "$classes/$helpDir"
632 args = [ "$classes/$helpDir", "-nointernet" ]
635 helplinkscheckeroutputfile.createNewFile()
636 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
639 outputs.file(helplinkscheckeroutputfile)
642 task cleanPackageDir(type: Delete) {
643 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
648 dependsOn buildIndices
649 dependsOn createBuildProperties
652 attributes "Main-Class": mainClass,
653 "Permissions": "all-permissions",
654 "Application-Name": "Jalview Desktop",
655 "Codebase": application_codebase
658 destinationDir = file("$jalviewDir/$packageDir")
659 archiveName = rootProject.name+".jar"
667 inputs.dir("$classes")
668 outputs.file("$jalviewDir/$packageDir/$archiveName")
671 task copyJars(type: Copy) {
672 from fileTree("$classes").include("**/*.jar").include("*.jar").files
673 into "$jalviewDir/$packageDir"
676 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
677 task syncJars(type: Sync) {
678 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
679 into "$jalviewDir/$packageDir"
681 include jar.archiveName
687 description = "Put all required libraries in dist"
688 // order of "cleanPackageDir", "copyJars", "jar" important!
689 jar.mustRunAfter cleanPackageDir
690 syncJars.mustRunAfter cleanPackageDir
691 dependsOn cleanPackageDir
694 outputs.dir("$jalviewDir/$packageDir")
698 dependsOn cleanPackageDir
704 group = "distribution"
706 from ("$jalviewDir/$libDistDir") {
709 mainClassName = shadowJarMainClass
711 classifier = "all-"+JAVA_VERSION
715 task getdownWebsite() {
716 group = "distribution"
717 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
719 def getdownWebsiteResourceFilenames = []
720 def getdownTextString = ""
721 def getdownResourceDir = project.ext.getdownResourceDir
722 def getdownAppDir = project.ext.getdownAppDir
723 def getdownResourceFilenames = []
726 from "$classes/$buildPropertiesFile"
727 rename(buildPropertiesFile, getdown_install_build_properties)
728 into project.ext.getdownWebsiteDir
730 getdownResourceFilenames += getdown_current_build_properties
733 // go through properties looking for getdown_txt_...
734 def props = project.properties.sort { it.key }
735 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
736 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
737 props.put("getdown_txt_resource", "$classes/$buildPropertiesFile")
739 if (getdown_local == "true") {
740 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
742 props.put("getdown_txt_appbase", getdown_app_base)
743 props.each{ prop, val ->
744 if (prop.startsWith("getdown_txt_") && val != null) {
745 if (prop.startsWith("getdown_txt_multi_")) {
746 def key = prop.substring(18)
747 val.split(",").each{ v ->
748 def line = key + " = " + v + "\n"
749 getdownTextString += line
752 // file values rationalised
753 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
755 if (val.indexOf('/') == 0) {
758 } else if (val.indexOf('/') > 0) {
759 // relative path (relative to jalviewDir)
760 r = file( jalviewDir + '/' + val )
763 val = getdown_resource_dir + '/' + r.getName()
764 getdownWebsiteResourceFilenames += val
765 getdownResourceFilenames += r.getPath()
768 if (! prop.startsWith("getdown_txt_resource")) {
769 def line = prop.substring(12) + " = " + val + "\n"
770 getdownTextString += line
776 getdownWebsiteResourceFilenames.each{ filename ->
777 getdownTextString += "resource = "+filename+"\n"
779 getdownResourceFilenames.each{ filename ->
782 into project.ext.getdownResourceDir
787 makeDist.outputs.files.each{ f ->
788 if (f.isDirectory()) {
789 def files = fileTree(dir: f, include: ["*"]).getFiles()
791 } else if (f.exists()) {
795 codeFiles.sort().each{f ->
796 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
797 getdownTextString += line
800 into project.ext.getdownAppDir
804 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
806 if (JAVA_VERSION.equals("11")) {
807 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
808 j11libFiles.sort().each{f ->
809 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
810 getdownTextString += line
813 into project.ext.getdownJ11libDir
819 // 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.
820 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
821 getdownTextString += "resource = " + getdown_launcher_new + "\n"
822 getdownTextString += "class = " + mainClass + "\n"
824 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
825 getdown_txt.write(getdownTextString)
827 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
828 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
833 from project.ext.getdownWebsiteDir+"/"+getdown_current_build_properties
834 from project.ext.getdownWebsiteDir+"/"+getdown_install_build_properties
835 into project.ext.getdownFilesDir
840 into project.ext.getdownWebsiteDir
841 rename(file(getdownLauncher).getName(), getdown_launcher_new)
846 into project.ext.getdownFilesDir
851 into project.ext.getdownWebsiteDir
855 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
856 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
857 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
858 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
859 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
860 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
864 inputs.dir(jalviewDir + '/' + packageDir)
865 outputs.dir(project.ext.getdownWebsiteDir)
866 outputs.dir(project.ext.getdownFilesDir)
869 task getdownDigest(type: JavaExec) {
870 group = "distribution"
871 description = "Digest the getdown website folder"
872 dependsOn getdownWebsite
873 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
874 main = "com.threerings.getdown.tools.Digester"
875 args project.ext.getdownWebsiteDir
876 inputs.dir(project.ext.getdownWebsiteDir)
877 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
881 group = "distribution"
882 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
883 dependsOn getdownDigest
887 delete project.ext.getdownWebsiteDir
888 delete project.ext.getdownFilesDir
892 def install4jHomeDir = "/opt/install4j"
893 def hostname = "hostname".execute().text.trim()
894 if (hostname.equals("jv-bamboo")) {
895 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
896 } else if (OperatingSystem.current().isMacOsX()) {
897 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
898 if (! file(install4jHomeDir).exists()) {
899 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
901 } else if (OperatingSystem.current().isLinux()) {
902 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
904 installDir = file(install4jHomeDir)
905 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
906 if (install4jFaster.equals("true")) {
916 def install4jDir = "$jalviewDir/$install4jResourceDir"
917 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
918 install4jConf = "$install4jDir/$install4jConfFile"
920 task copyInstall4jTemplate(type: Copy) {
921 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
922 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
923 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
924 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
925 from (install4jDir) {
926 include install4jTemplate
927 rename (install4jTemplate, install4jConfFile)
928 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
929 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
931 'JAVA_VERSION': JAVA_VERSION,
932 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
933 'VERSION': JALVIEW_VERSION,
934 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
935 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
936 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
937 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
938 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
939 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
940 'MACOS_BUNDLE_ID': install4jMacOSBundleId
943 if (OSX_KEYPASS=="") {
944 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
945 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
949 outputs.files(install4jConf)
952 // include file associations in installer
953 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
957 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
958 replace: installerFileAssociationsXml,
962 // include uninstaller applescript app files in dmg
963 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
967 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
968 replace: installerDMGUninstallerXml,
975 task installers(type: com.install4j.gradle.Install4jTask) {
976 group = "distribution"
977 description = "Create the install4j installers"
979 dependsOn copyInstall4jTemplate
980 projectFile = file(install4jConf)
981 println("Using projectFile "+projectFile)
982 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
983 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
987 macKeystorePassword=OSX_KEYPASS
991 inputs.dir(project.ext.getdownWebsiteDir)
992 inputs.file(install4jConf)
993 inputs.dir(macosJavaVMDir)
994 inputs.dir(windowsJavaVMDir)
995 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")