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
101 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
108 srcDirs "$jalviewDir/$sourceDir"
109 outputDir = file("$classes")
113 srcDirs "$jalviewDir/$resourceDir"
116 jar.destinationDir = file("$jalviewDir/$packageDir")
118 compileClasspath = files(sourceSets.main.java.outputDir)
119 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
121 runtimeClasspath = compileClasspath
125 srcDirs = [ cloverInstrDir ]
126 outputDir = file("${buildDir}/${cloverClassesDir}")
130 srcDirs = sourceSets.main.resources.srcDirs
132 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
133 compileClasspath += files(sourceSets.main.java.outputDir)
134 compileClasspath += sourceSets.main.compileClasspath
135 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
136 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
138 runtimeClasspath = compileClasspath
143 srcDirs "$jalviewDir/$testSourceDir"
144 outputDir = file("$jalviewDir/$testOutputDir")
148 srcDirs = sourceSets.main.resources.srcDirs
151 compileClasspath = files( sourceSets.test.java.outputDir )
154 compileClasspath += sourceSets.clover.compileClasspath
156 compileClasspath += files(sourceSets.main.java.outputDir)
159 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
160 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
162 runtimeClasspath = compileClasspath
169 cloverCompile 'org.openclover:clover:4.3.1'
170 testCompile 'org.openclover:clover:4.3.1'
176 cloverRuntime.extendsFrom cloverCompile
181 name = "Jalview with gradle build"
183 natures 'org.eclipse.jdt.core.javanature',
184 'org.eclipse.jdt.groovy.core.groovyNature',
185 'org.eclipse.buildship.core.gradleprojectnature'
187 buildCommand 'org.eclipse.jdt.core.javabuilder'
188 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
192 //defaultOutputDir = sourceSets.main.java.outputDir
194 configurations.each{ if (it.isCanBeResolved()) {
199 minusConfigurations += removeThese
200 plusConfigurations = [ ]
204 def removeTheseToo = []
205 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
206 cp.entries.each { entry ->
207 if (entry.kind == 'src') {
208 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
209 removeTheseToo += entry
211 addedSrcPath.putAt(entry.path, true)
215 cp.entries.removeAll(removeTheseToo)
217 print ("CP="+cp.inspect())
219 cp.entries += new Output("bin/main")
220 cp.entries += new Library(fileReference(helpParentDir))
221 cp.entries += new Library(fileReference(resourceDir))
223 HashMap<String, Boolean> addedLibPath = new HashMap<>();
225 // changing from sourcesets.main.classpath to specific Java version lib
226 //sourceSets.main.compileClasspath.each{
227 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
228 //don't want to add outputDir as eclipse is using its own output dir in bin/main
229 if (it.isDirectory() || ! it.exists()) {
230 // don't add dirs to classpath
233 def itPath = it.toString()
234 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
235 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
237 if (addedLibPath.get(itPath)) {
238 //println("Not adding duplicate entry "+itPath)
240 //println("Adding entry "+itPath)
241 cp.entries += new Library(fileReference(itPath))
242 addedLibPath.put(itPath, true)
246 // changing from sourcesets.main.classpath to specific Java version lib
247 //sourceSets.test.compileClasspath.each{
248 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
249 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
250 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
251 if (it.isDirectory() || ! it.exists()) {
252 // don't add dirs to classpath
253 return false // groovy "break" in .each loop
255 def itPath = it.toString()
256 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
257 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
259 if (addedLibPath.get(itPath)) {
262 def lib = new Library(fileReference(itPath))
263 // this doesn't work... yet. Adding test=true attribute using withXml below
264 //def attrs = new Node(null, 'attributes', ["test":"true"])
265 //lib.appendNode(attrs) //
267 addedLibPath.put(itPath, true)
272 // withXml changes ignored by buildship, these add the "test=true" attribute
274 def node = it.asNode()
276 def srcTestAttributes
277 node.children().each{ cpe ->
278 def attributes = cpe.attributes()
279 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
280 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
284 def addTestAttribute = true
285 srcTestAttributes.each{a ->
286 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
287 addTestAttribute = false
290 if (addTestAttribute) {
291 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
294 node.children().each{ cpe ->
295 def attributes = cpe.attributes()
296 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
297 cpe.appendNode('attributes')
298 .appendNode('attribute', [name:"test", value:"true"])
304 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
308 // for the IDE, use java 11 compatibility
309 sourceCompatibility = compile_source_compatibility
310 targetCompatibility = compile_target_compatibility
311 javaRuntimeName = eclipse_java_runtime_name
314 withProperties { props ->
315 def jalview_prefs = new Properties()
316 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
317 jalview_prefs.load(ins)
319 jalview_prefs.forEach { t, v ->
320 if (props.getAt(t) == null) {
328 //synchronizationTasks eclipseClasspath
329 //autoBuildTasks eclipseClasspath
333 // only instrument source, we build test classes as normal
334 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
335 outputs.dir cloverInstrDir
338 delete cloverInstrDir
339 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
340 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
341 argsList.addAll(inputs.files.files.collect({ file ->
344 String[] args = argsList.toArray()
345 println("About to instrument "+args.length +" files")
346 com.atlassian.clover.CloverInstr.mainImpl(args)
352 group = "Verification"
353 description = "Createst the Clover report"
354 inputs.dir "${buildDir}/clover"
355 outputs.dir "${reportsDir}/clover"
357 file("${buildDir}/clover/clover.db").exists()
360 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
361 "-o", "${reportsDir}/clover"]
362 String[] args = argsList.toArray()
363 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
365 // and generate ${reportsDir}/clover/clover.xml
366 args = ["--initstring", "${buildDir}/clover/clover.db",
367 "-o", "${reportsDir}/clover/clover.xml"].toArray()
368 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
378 sourceCompatibility = compile_source_compatibility
379 targetCompatibility = compile_target_compatibility
380 options.compilerArgs = additional_compiler_args
381 print ("Setting target compatibility to "+targetCompatibility+"\n")
388 dependsOn compileCloverJava
389 classpath += configurations.cloverRuntime
391 classpath += sourceSets.main.runtimeClasspath
394 sourceCompatibility = compile_source_compatibility
395 targetCompatibility = compile_target_compatibility
396 options.compilerArgs = additional_compiler_args
397 print ("Setting target compatibility to "+targetCompatibility+"\n")
405 sourceCompatibility = compile_source_compatibility
406 targetCompatibility = compile_target_compatibility
407 options.compilerArgs += additional_compiler_args
408 print ("Setting target compatibility to "+targetCompatibility+"\n")
410 classpath += configurations.cloverRuntime
414 delete sourceSets.main.java.outputDir
418 delete sourceSets.test.java.outputDir
419 delete cloverInstrDir
422 // format is a string like date.format("dd MMMM yyyy")
423 def getDate(format) {
424 def date = new Date()
425 return date.format(format)
429 def hashStdOut = new ByteArrayOutputStream()
431 commandLine "git", "rev-parse", "--short", "HEAD"
432 standardOutput = hashStdOut
436 def branchStdOut = new ByteArrayOutputStream()
438 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
439 standardOutput = branchStdOut
443 project.ext.gitHash = hashStdOut.toString().trim()
444 project.ext.gitBranch = branchStdOut.toString().trim()
446 outputs.upToDateWhen { false }
449 task createBuildProperties(type: WriteProperties) {
451 inputs.dir("$jalviewDir/$sourceDir")
452 inputs.dir("$classes")
453 inputs.dir("$jalviewDir/$resourceDir")
454 outputFile "$classes/$buildPropertiesFile"
455 // taking time specific comment out to allow better incremental builds
456 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
457 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
458 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
459 property "VERSION", JALVIEW_VERSION
460 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
461 outputs.file(outputFile)
464 def buildingHTML = "$jalviewDir/$docDir/building.html"
465 task deleteBuildingHTML(type: Delete) {
469 task convertBuildingMD(type: Exec) {
470 dependsOn deleteBuildingHTML
471 def buildingMD = "$jalviewDir/$docDir/building.md"
472 def css = "$jalviewDir/$docDir/github.css"
474 def pandoc = pandoc_exec
475 def hostname = "hostname".execute().text.trim()
476 if (! file(pandoc).exists() && hostname.equals("jv-bamboo")) {
477 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
480 if (file(pandoc).exists()) {
481 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
488 inputs.file(buildingMD)
490 outputs.file(buildingHTML)
496 task syncDocs(type: Sync) {
497 dependsOn convertBuildingMD
498 def syncDir = "$classes/$docDir"
499 from fileTree("$jalviewDir/$docDir")
504 def helpFile = "$classes/$helpDir/help.jhm"
506 task copyHelp(type: Copy) {
507 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
508 def outputDir = "$classes/$helpDir"
513 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
523 outputs.files(helpFile)
524 outputs.dir(outputDir)
527 task syncLib(type: Sync) {
528 def syncDir = "$classes/$libDistDir"
529 from fileTree("$jalviewDir/$libDistDir")
533 task syncResources(type: Sync) {
534 from "$jalviewDir/$resourceDir"
544 dependsOn syncResources
550 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
553 dependsOn compileJava
555 dependsOn cloverInstr
558 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
561 includeGroups testngGroups
563 useDefaultListeners=true
566 workingDir = jalviewDir
567 //systemProperties 'clover.jar' System.properties.clover.jar
568 sourceCompatibility = compile_source_compatibility
569 targetCompatibility = compile_target_compatibility
570 jvmArgs += additional_compiler_args
571 print ("Setting target compatibility to "+targetCompatibility+"\n")
574 task buildIndices(type: JavaExec) {
576 classpath = sourceSets.main.compileClasspath
577 main = "com.sun.java.help.search.Indexer"
578 workingDir = "$classes/$helpDir"
581 inputs.dir("$workingDir/$argDir")
583 outputs.dir("$classes/doc")
584 outputs.dir("$classes/help")
585 outputs.file("$workingDir/JavaHelpSearch/DOCS")
586 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
587 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
588 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
589 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
590 outputs.file("$workingDir/JavaHelpSearch/TMAP")
593 task compileLinkCheck(type: JavaCompile) {
595 classpath = files("$jalviewDir/$utilsDir")
596 destinationDir = file("$jalviewDir/$utilsDir")
597 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
599 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
600 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
601 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
602 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
605 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
606 task linkCheck(type: JavaExec) {
607 dependsOn prepare, compileLinkCheck
608 classpath = files("$jalviewDir/$utilsDir")
609 main = "HelpLinksChecker"
610 workingDir = jalviewDir
611 def help = "$classes/$helpDir"
612 args = [ "$classes/$helpDir", "-nointernet" ]
615 helplinkscheckeroutputfile.createNewFile()
616 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
619 outputs.file(helplinkscheckeroutputfile)
622 task cleanPackageDir(type: Delete) {
623 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
628 dependsOn buildIndices
629 dependsOn createBuildProperties
632 attributes "Main-Class": mainClass,
633 "Permissions": "all-permissions",
634 "Application-Name": "Jalview Desktop",
635 "Codebase": application_codebase
638 destinationDir = file("$jalviewDir/$packageDir")
639 archiveName = rootProject.name+".jar"
647 inputs.dir("$classes")
648 outputs.file("$jalviewDir/$packageDir/$archiveName")
651 task copyJars(type: Copy) {
652 from fileTree("$classes").include("**/*.jar").include("*.jar").files
653 into "$jalviewDir/$packageDir"
656 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
657 task syncJars(type: Sync) {
658 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
659 into "$jalviewDir/$packageDir"
661 include jar.archiveName
667 description = "Put all required libraries in dist"
668 // order of "cleanPackageDir", "copyJars", "jar" important!
669 jar.mustRunAfter cleanPackageDir
670 syncJars.mustRunAfter cleanPackageDir
671 dependsOn cleanPackageDir
674 outputs.dir("$jalviewDir/$packageDir")
678 dependsOn cleanPackageDir
684 group = "distribution"
686 from ("$jalviewDir/$libDistDir") {
689 mainClassName = shadowJarMainClass
691 classifier = "all-"+JAVA_VERSION
695 task getdownWebsite() {
696 group = "distribution"
697 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
699 def getdownWebsiteResourceFilenames = []
700 def getdownTextString = ""
701 def getdownResourceDir = project.ext.getdownResourceDir
702 def getdownAppDir = project.ext.getdownAppDir
703 def getdownResourceFilenames = []
705 // go through properties looking for getdown_txt_...
706 def props = project.properties.sort { it.key }
707 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
708 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
710 if (getdown_local == "true") {
711 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
713 props.put("getdown_txt_appbase", getdown_app_base)
714 props.each{ prop, val ->
715 if (prop.startsWith("getdown_txt_") && val != null) {
716 if (prop.startsWith("getdown_txt_multi_")) {
717 def key = prop.substring(18)
718 val.split(",").each{ v ->
719 def line = key + " = " + v + "\n"
720 getdownTextString += line
723 // file values rationalised
724 if (val.indexOf('/') > -1) {
726 if (val.indexOf('/') == 0) {
729 } else if (val.indexOf('/') > 0) {
730 // relative path (relative to jalviewDir)
731 r = file( jalviewDir + '/' + val )
734 val = getdown_resource_dir + '/' + r.getName()
735 getdownWebsiteResourceFilenames += val
736 getdownResourceFilenames += r.getPath()
739 def line = prop.substring(12) + " = " + val + "\n"
740 getdownTextString += line
745 getdownWebsiteResourceFilenames.each{ filename ->
746 getdownTextString += "resource = "+filename+"\n"
748 getdownResourceFilenames.each{ filename ->
751 into project.ext.getdownResourceDir
756 makeDist.outputs.files.each{ f ->
757 if (f.isDirectory()) {
758 def files = fileTree(dir: f, include: ["*"]).getFiles()
760 } else if (f.exists()) {
764 codeFiles.sort().each{f ->
765 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
766 getdownTextString += line
769 into project.ext.getdownAppDir
773 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
775 if (JAVA_VERSION.equals("11")) {
776 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
777 j11libFiles.sort().each{f ->
778 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
779 getdownTextString += line
782 into project.ext.getdownJ11libDir
788 // 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.
789 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
790 getdownTextString += "resource = " + file(getdownLauncher).getName() + "\n"
791 getdownTextString += "class = " + mainClass + "\n"
793 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
794 getdown_txt.write(getdownTextString)
798 into project.ext.getdownFilesDir
803 into project.ext.getdownFilesDir
808 into project.ext.getdownWebsiteDir
812 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
813 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
814 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
815 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
816 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
817 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
821 inputs.dir(jalviewDir + '/' + packageDir)
822 outputs.dir(project.ext.getdownWebsiteDir)
823 outputs.dir(project.ext.getdownFilesDir)
826 task getdownDigest(type: JavaExec) {
827 group = "distribution"
828 description = "Digest the getdown website folder"
829 dependsOn getdownWebsite
830 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
831 main = "com.threerings.getdown.tools.Digester"
832 args project.ext.getdownWebsiteDir
833 inputs.dir(project.ext.getdownWebsiteDir)
834 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
838 group = "distribution"
839 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
840 dependsOn getdownDigest
844 delete project.ext.getdownWebsiteDir
845 delete project.ext.getdownFilesDir
849 def install4jHomeDir = "/opt/install4j"
850 def hostname = "hostname".execute().text.trim()
851 if (hostname.equals("jv-bamboo")) {
852 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
853 } else if (OperatingSystem.current().isMacOsX()) {
854 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
855 if (! file(install4jHomeDir).exists()) {
856 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
858 } else if (OperatingSystem.current().isLinux()) {
859 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
861 installDir = file(install4jHomeDir)
862 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
863 if (install4jFaster.equals("true")) {
873 def install4jDir = "$jalviewDir/$install4jResourceDir"
874 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
875 install4jConf = "$install4jDir/$install4jConfFile"
877 task copyInstall4jTemplate(type: Copy) {
878 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
879 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
880 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
881 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
882 from (install4jDir) {
883 include install4jTemplate
884 rename (install4jTemplate, install4jConfFile)
885 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
886 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
888 'JAVA_VERSION': JAVA_VERSION,
889 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
890 'VERSION': JALVIEW_VERSION,
891 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
892 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
893 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
894 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
895 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
896 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
897 'MACOS_BUNDLE_ID': install4jMacOSBundleId
900 if (OSX_KEYPASS=="") {
901 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
902 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
906 outputs.files(install4jConf)
909 // include file associations in installer
910 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
914 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
915 replace: installerFileAssociationsXml,
919 // include uninstaller applescript app files in dmg
920 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
924 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
925 replace: installerDMGUninstallerXml,
932 task installers(type: com.install4j.gradle.Install4jTask) {
933 group = "distribution"
934 description = "Create the install4j installers"
936 dependsOn copyInstall4jTemplate
937 projectFile = file(install4jConf)
938 println("Using projectFile "+projectFile)
939 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
940 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
944 macKeystorePassword=OSX_KEYPASS
948 inputs.dir(project.ext.getdownWebsiteDir)
949 inputs.file(install4jConf)
950 inputs.dir(macosJavaVMDir)
951 inputs.dir(windowsJavaVMDir)
952 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")