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 if (JAVA_VERSION.equals("1.8")) {
76 JAVA_INTEGER_VERSION = "8"
79 compile_source_compatibility = 1.8
80 compile_target_compatibility = 1.8
81 getdown_alt_java_min_version = getdown_alt_java8_min_version
82 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
83 } else if (JAVA_VERSION.equals("11")) {
84 JAVA_INTEGER_VERSION = "11"
86 libDistDir = j11libDir
87 compile_source_compatibility = 11
88 compile_target_compatibility = 11
89 getdown_alt_java_min_version = getdown_alt_java11_min_version
90 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
91 additional_compiler_args += [
92 '--module-path', ext.modules_compileClasspath.asPath,
93 '--add-modules', j11modules
96 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
103 srcDirs "$jalviewDir/$sourceDir"
104 outputDir = file("$classes")
108 srcDirs "$jalviewDir/$resourceDir"
109 srcDirs "$jalviewDir/$libDistDir"
112 jar.destinationDir = file("$jalviewDir/$packageDir")
114 compileClasspath = files(sourceSets.main.java.outputDir)
115 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
117 runtimeClasspath = compileClasspath
121 srcDirs = [ cloverInstrDir ]
122 outputDir = file("${buildDir}/${cloverClassesDir}")
126 srcDirs = sourceSets.main.resources.srcDirs
128 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
129 compileClasspath += files(sourceSets.main.java.outputDir)
130 compileClasspath += sourceSets.main.compileClasspath
131 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
132 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
134 runtimeClasspath = compileClasspath
139 srcDirs "$jalviewDir/$testSourceDir"
140 outputDir = file("$jalviewDir/$testOutputDir")
144 srcDirs = sourceSets.main.resources.srcDirs
147 compileClasspath = files( sourceSets.test.java.outputDir )
150 compileClasspath += sourceSets.clover.compileClasspath
152 compileClasspath += files(sourceSets.main.java.outputDir)
154 //compileClasspath += sourceSets.main.compileClasspath
155 //compileClasspath += files( sourceSets.main.resources.srcDirs)
156 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
157 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
159 runtimeClasspath = compileClasspath
166 cloverCompile 'org.openclover:clover:4.3.1'
167 testCompile 'org.openclover:clover:4.3.1'
173 cloverRuntime.extendsFrom cloverCompile
178 name = "Jalview with gradle build"
180 natures 'org.eclipse.jdt.core.javanature',
181 'org.eclipse.jdt.groovy.core.groovyNature',
182 'org.eclipse.buildship.core.gradleprojectnature'
184 buildCommand 'org.eclipse.jdt.core.javabuilder'
185 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
189 //defaultOutputDir = sourceSets.main.java.outputDir
191 configurations.each{ if (it.isCanBeResolved()) {
196 minusConfigurations += removeThese
197 plusConfigurations = [ ]
201 def removeTheseToo = []
202 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
203 cp.entries.each { entry ->
204 if (entry.kind == 'src') {
205 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
206 removeTheseToo += entry
208 addedSrcPath.putAt(entry.path, true)
212 cp.entries.removeAll(removeTheseToo)
214 cp.entries += new Output("bin/main")
215 cp.entries += new Library(fileReference(helpParentDir))
216 cp.entries += new Library(fileReference(resourceDir))
218 HashMap<String, Boolean> addedLibPath = new HashMap<>();
219 def allPaths = sourceSets.test.compileClasspath + sourceSets.main.compileClasspath
220 sourceSets.main.compileClasspath.each{
221 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
222 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
223 if (it.isDirectory() || ! it.exists()) {
224 // don't add dirs to classpath
227 def itPath = it.toString()
228 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
229 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
231 if (addedLibPath.get(itPath)) {
232 //println("Not adding duplicate entry "+itPath)
234 //println("Adding entry "+itPath)
235 cp.entries += new Library(fileReference(itPath))
236 addedLibPath.put(itPath, true)
240 sourceSets.test.compileClasspath.each{
241 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
242 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
243 if (it.isDirectory() || ! it.exists()) {
244 // don't add dirs to classpath
245 return false // groovy "break" in .each loop
247 def itPath = it.toString()
248 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
249 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
251 if (addedLibPath.get(itPath)) {
254 def lib = new Library(fileReference(itPath))
255 // this doesn't work... yet. Adding test=true attribute using withXml below
256 //def attrs = new Node(null, 'attributes', ["test":"true"])
257 //lib.appendNode(attrs) //
259 addedLibPath.put(itPath, true)
264 // withXml changes ignored by buildship, these add the "test=true" attribute
266 def node = it.asNode()
268 def srcTestAttributes
269 node.children().each{ cpe ->
270 def attributes = cpe.attributes()
271 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
272 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
276 def addTestAttribute = true
277 srcTestAttributes.each{a ->
278 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
279 addTestAttribute = false
282 if (addTestAttribute) {
283 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
286 node.children().each{ cpe ->
287 def attributes = cpe.attributes()
288 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
289 cpe.appendNode('attributes')
290 .appendNode('attribute', [name:"test", value:"true"])
296 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
300 // for the IDE, use java 11 compatibility
301 sourceCompatibility = 11
302 targetCompatibility = 11
303 javaRuntimeName = "JavaSE-11"
306 withProperties { props ->
307 def jalview_prefs = new Properties()
308 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
309 jalview_prefs.load(ins)
311 jalview_prefs.forEach { t, v ->
312 if (props.getAt(t) == null) {
320 //synchronizationTasks eclipseClasspath
321 //autoBuildTasks eclipseClasspath
325 // only instrument source, we build test classes as normal
326 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
327 outputs.dir cloverInstrDir
330 delete cloverInstrDir
331 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
332 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
333 argsList.addAll(inputs.files.files.collect({ file ->
336 String[] args = argsList.toArray()
337 println("About to instrument "+args.length +" files")
338 com.atlassian.clover.CloverInstr.mainImpl(args)
344 group = "Verification"
345 description = "Createst the Clover report"
346 inputs.dir "${buildDir}/clover"
347 outputs.dir "${reportsDir}/clover"
349 file("${buildDir}/clover/clover.db").exists()
352 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
353 "-o", "${reportsDir}/clover"]
354 String[] args = argsList.toArray()
355 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
357 // and generate ${reportsDir}/clover/clover.xml
358 args = ["--initstring", "${buildDir}/clover/clover.db",
359 "-o", "${reportsDir}/clover/clover.xml"].toArray()
360 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
370 sourceCompatibility = compile_source_compatibility
371 targetCompatibility = compile_target_compatibility
372 options.compilerArgs = additional_compiler_args
373 print ("Setting target compatibility to "+targetCompatibility+"\n")
380 dependsOn compileCloverJava
381 classpath += configurations.cloverRuntime
383 classpath += sourceSets.main.runtimeClasspath
386 sourceCompatibility = compile_source_compatibility
387 targetCompatibility = compile_target_compatibility
388 options.compilerArgs = additional_compiler_args
389 print ("Setting target compatibility to "+targetCompatibility+"\n")
397 sourceCompatibility = compile_source_compatibility
398 targetCompatibility = compile_target_compatibility
399 options.compilerArgs += additional_compiler_args
400 print ("Setting target compatibility to "+targetCompatibility+"\n")
402 classpath += configurations.cloverRuntime
406 delete sourceSets.main.java.outputDir
410 delete sourceSets.test.java.outputDir
411 delete cloverInstrDir
414 def getDate(format) {
415 def date = new Date()
416 //return date.format("dd MMMM yyyy")
417 return date.format(format)
420 task setGitHash(type: Exec) {
421 workingDir = jalviewDir
422 commandLine "git", "rev-parse", "--short", "HEAD"
423 standardOutput = new ByteArrayOutputStream()
424 project.ext.gitHash = {
425 return standardOutput.toString().trim()
429 task setGitBranch(type: Exec) {
430 workingDir = jalviewDir
431 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
432 standardOutput = new ByteArrayOutputStream()
433 project.ext.gitBranch = {
434 return standardOutput.toString().trim()
440 dependsOn setGitBranch
443 task createBuildProperties(type: WriteProperties) {
445 inputs.dir("$jalviewDir/$sourceDir")
446 inputs.dir("$jalviewDir/$resourceDir")
447 outputFile "$classes/$buildPropertiesFile"
448 // taking time specific comment out to allow better incremental builds
449 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
450 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
451 property "BUILD_DATE", getDate("dd MMMM yyyy")
452 property "VERSION", JALVIEW_VERSION
453 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
454 outputs.file(outputFile)
455 outputs.dir("$classes")
458 def buildingHTML = "$jalviewDir/$docDir/building.html"
459 task deleteBuildingHTML(type: Delete) {
463 task convertBuildingMD(type: Exec) {
464 dependsOn deleteBuildingHTML
465 def buildingMD = "$jalviewDir/$docDir/building.md"
466 def css = "$jalviewDir/$docDir/github.css"
468 def pandoc = pandoc_exec
469 def hostname = "hostname".execute().text.trim()
470 if (! file(pandoc).exists() && hostname.equals("jv-bamboo")) {
471 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
474 if (file(pandoc).exists()) {
475 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
482 inputs.file(buildingMD)
484 outputs.file(buildingHTML)
490 task syncDocs(type: Sync) {
491 dependsOn convertBuildingMD
492 def syncDir = "$classes/$docDir"
493 from fileTree("$jalviewDir/$docDir")
498 def helpFile = "$classes/$helpDir/help.jhm"
500 task copyHelp(type: Copy) {
501 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
502 def outputDir = "$classes/$helpDir"
507 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
517 outputs.files(helpFile)
518 outputs.dir(outputDir)
521 task syncLib(type: Sync) {
522 def syncDir = "$classes/$libDistDir"
523 from fileTree("$jalviewDir/$libDistDir")
527 task syncResources(type: Sync) {
528 from "$jalviewDir/$resourceDir"
538 dependsOn syncResources
544 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
547 dependsOn compileJava
549 dependsOn cloverInstr
552 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
555 includeGroups testngGroups
557 useDefaultListeners=true
560 workingDir = jalviewDir
561 //systemProperties 'clover.jar' System.properties.clover.jar
562 sourceCompatibility = compile_source_compatibility
563 targetCompatibility = compile_target_compatibility
564 jvmArgs += additional_compiler_args
565 print ("Setting target compatibility to "+targetCompatibility+"\n")
568 task buildIndices(type: JavaExec) {
570 classpath = sourceSets.main.compileClasspath
571 main = "com.sun.java.help.search.Indexer"
572 workingDir = "$classes/$helpDir"
575 inputs.dir("$workingDir/$argDir")
577 outputs.dir("$classes/doc")
578 outputs.dir("$classes/help")
579 outputs.file("$workingDir/JavaHelpSearch/DOCS")
580 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
581 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
582 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
583 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
584 outputs.file("$workingDir/JavaHelpSearch/TMAP")
587 task compileLinkCheck(type: JavaCompile) {
589 classpath = files("$jalviewDir/$utilsDir")
590 destinationDir = file("$jalviewDir/$utilsDir")
591 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
593 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
594 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
595 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
596 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
599 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
600 task linkCheck(type: JavaExec) {
601 dependsOn prepare, compileLinkCheck
602 classpath = files("$jalviewDir/$utilsDir")
603 main = "HelpLinksChecker"
604 workingDir = jalviewDir
605 def help = "$classes/$helpDir"
606 args = [ "$classes/$helpDir", "-nointernet" ]
609 helplinkscheckeroutputfile.createNewFile()
610 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
613 outputs.file(helplinkscheckeroutputfile)
616 task cleanPackageDir(type: Delete) {
617 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
622 dependsOn buildIndices
623 dependsOn createBuildProperties
626 attributes "Main-Class": mainClass,
627 "Permissions": "all-permissions",
628 "Application-Name": "Jalview Desktop",
629 "Codebase": application_codebase
632 destinationDir = file("$jalviewDir/$packageDir")
633 archiveName = rootProject.name+".jar"
641 inputs.dir("$classes")
642 outputs.file("$jalviewDir/$packageDir/$archiveName")
645 task copyJars(type: Copy) {
646 from fileTree("$classes").include("**/*.jar").include("*.jar").files
647 into "$jalviewDir/$packageDir"
650 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
651 task syncJars(type: Sync) {
652 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
653 into "$jalviewDir/$packageDir"
655 include jar.archiveName
661 description = "Put all required libraries in dist"
662 // order of "cleanPackageDir", "copyJars", "jar" important!
663 jar.mustRunAfter cleanPackageDir
664 syncJars.mustRunAfter cleanPackageDir
665 dependsOn cleanPackageDir
668 outputs.dir("$jalviewDir/$packageDir")
672 dependsOn cleanPackageDir
678 group = "distribution"
680 from ("$jalviewDir/$libDistDir") {
683 mainClassName = shadowJarMainClass
685 classifier = "all-"+JAVA_VERSION
689 task getdownWebsite() {
690 group = "distribution"
691 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
693 def getdownWebsiteResourceFilenames = []
694 def getdownTextString = ""
695 def getdownResourceDir = project.ext.getdownResourceDir
696 def getdownAppDir = project.ext.getdownAppDir
697 def getdownResourceFilenames = []
699 // go through properties looking for getdown_txt_...
700 def props = project.properties.sort { it.key }
701 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
702 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
704 if (getdown_local == "true") {
705 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
707 props.put("getdown_txt_appbase", getdown_app_base)
708 props.each{ prop, val ->
709 if (prop.startsWith("getdown_txt_") && val != null) {
710 if (prop.startsWith("getdown_txt_multi_")) {
711 def key = prop.substring(18)
712 val.split(",").each{ v ->
713 def line = key + " = " + v + "\n"
714 getdownTextString += line
717 // file values rationalised
718 if (val.indexOf('/') > -1) {
720 if (val.indexOf('/') == 0) {
723 } else if (val.indexOf('/') > 0) {
724 // relative path (relative to jalviewDir)
725 r = file( jalviewDir + '/' + val )
728 val = getdown_resource_dir + '/' + r.getName()
729 getdownWebsiteResourceFilenames += val
730 getdownResourceFilenames += r.getPath()
733 def line = prop.substring(12) + " = " + val + "\n"
734 getdownTextString += line
739 getdownWebsiteResourceFilenames.each{ filename ->
740 getdownTextString += "resource = "+filename+"\n"
742 getdownResourceFilenames.each{ filename ->
745 into project.ext.getdownResourceDir
750 makeDist.outputs.files.each{ f ->
751 if (f.isDirectory()) {
752 def files = fileTree(dir: f, include: ["*"]).getFiles()
754 } else if (f.exists()) {
758 codeFiles.sort().each{f ->
759 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
760 getdownTextString += line
763 into project.ext.getdownAppDir
767 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
769 if (JAVA_VERSION.equals("11")) {
770 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
771 j11libFiles.sort().each{f ->
772 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
773 getdownTextString += line
776 into project.ext.getdownJ11libDir
782 // 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.
783 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
784 getdownTextString += "resource = " + file(getdownLauncher).getName() + "\n"
785 getdownTextString += "class = " + mainClass + "\n"
787 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
788 getdown_txt.write(getdownTextString)
792 into project.ext.getdownFilesDir
797 into project.ext.getdownFilesDir
802 into project.ext.getdownWebsiteDir
806 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
807 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
808 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
809 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
810 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
811 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
815 inputs.dir(jalviewDir + '/' + packageDir)
816 outputs.dir(project.ext.getdownWebsiteDir)
817 outputs.dir(project.ext.getdownFilesDir)
820 task getdownDigest(type: JavaExec) {
821 group = "distribution"
822 description = "Digest the getdown website folder"
823 dependsOn getdownWebsite
824 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
825 main = "com.threerings.getdown.tools.Digester"
826 args project.ext.getdownWebsiteDir
827 inputs.dir(project.ext.getdownWebsiteDir)
828 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
832 group = "distribution"
833 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
834 dependsOn getdownDigest
838 delete project.ext.getdownWebsiteDir
839 delete project.ext.getdownFilesDir
843 def install4jHomeDir = "/opt/install4j"
844 def hostname = "hostname".execute().text.trim()
845 if (hostname.equals("jv-bamboo")) {
846 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
847 } else if (OperatingSystem.current().isMacOsX()) {
848 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
849 if (! file(install4jHomeDir).exists()) {
850 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
852 } else if (OperatingSystem.current().isLinux()) {
853 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
855 installDir = file(install4jHomeDir)
856 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
857 if (install4jFaster.equals("true")) {
867 def install4jDir = "$jalviewDir/$install4jResourceDir"
868 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
869 install4jConf = "$install4jDir/$install4jConfFile"
871 task copyInstall4jTemplate(type: Copy) {
872 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
873 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
874 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
875 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
876 from (install4jDir) {
877 include install4jTemplate
878 rename (install4jTemplate, install4jConfFile)
879 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
880 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
882 'JAVA_VERSION': JAVA_VERSION,
883 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
884 'VERSION': JALVIEW_VERSION,
885 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
886 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
887 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
888 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
889 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
890 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
891 'MACOS_BUNDLE_ID': install4jMacOSBundleId
894 if (OSX_KEYPASS=="") {
895 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
896 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
900 outputs.files(install4jConf)
903 // include file associations in installer
904 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
908 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
909 replace: installerFileAssociationsXml,
913 // include uninstaller applescript app files in dmg
914 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
918 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
919 replace: installerDMGUninstallerXml,
926 task installers(type: com.install4j.gradle.Install4jTask) {
927 group = "distribution"
928 description = "Create the install4j installers"
930 dependsOn copyInstall4jTemplate
931 projectFile = file(install4jConf)
932 println("Using projectFile "+projectFile)
933 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
934 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
938 macKeystorePassword=OSX_KEYPASS
942 inputs.dir(project.ext.getdownWebsiteDir)
943 inputs.file(install4jConf)
944 inputs.dir(macosJavaVMDir)
945 inputs.dir(windowsJavaVMDir)
946 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")