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"
475 pandoc_exec.split(",").each {
476 if (file(it.trim()).exists()) {
482 def hostname = "hostname".execute().text.trim()
483 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
484 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
487 if (pandoc != null && file(pandoc).exists()) {
488 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
495 inputs.file(buildingMD)
497 outputs.file(buildingHTML)
503 task syncDocs(type: Sync) {
504 dependsOn convertBuildingMD
505 def syncDir = "$classes/$docDir"
506 from fileTree("$jalviewDir/$docDir")
511 def helpFile = "$classes/$helpDir/help.jhm"
513 task copyHelp(type: Copy) {
514 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
515 def outputDir = "$classes/$helpDir"
520 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
530 outputs.files(helpFile)
531 outputs.dir(outputDir)
534 task syncLib(type: Sync) {
535 def syncDir = "$classes/$libDistDir"
536 from fileTree("$jalviewDir/$libDistDir")
540 task syncResources(type: Sync) {
541 from "$jalviewDir/$resourceDir"
551 dependsOn syncResources
557 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
560 dependsOn compileJava
562 dependsOn cloverInstr
565 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
568 includeGroups testngGroups
570 useDefaultListeners=true
573 workingDir = jalviewDir
574 //systemProperties 'clover.jar' System.properties.clover.jar
575 sourceCompatibility = compile_source_compatibility
576 targetCompatibility = compile_target_compatibility
577 jvmArgs += additional_compiler_args
578 print ("Setting target compatibility to "+targetCompatibility+"\n")
581 task buildIndices(type: JavaExec) {
583 classpath = sourceSets.main.compileClasspath
584 main = "com.sun.java.help.search.Indexer"
585 workingDir = "$classes/$helpDir"
588 inputs.dir("$workingDir/$argDir")
590 outputs.dir("$classes/doc")
591 outputs.dir("$classes/help")
592 outputs.file("$workingDir/JavaHelpSearch/DOCS")
593 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
594 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
595 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
596 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
597 outputs.file("$workingDir/JavaHelpSearch/TMAP")
600 task compileLinkCheck(type: JavaCompile) {
602 classpath = files("$jalviewDir/$utilsDir")
603 destinationDir = file("$jalviewDir/$utilsDir")
604 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
606 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
607 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
608 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
609 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
612 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
613 task linkCheck(type: JavaExec) {
614 dependsOn prepare, compileLinkCheck
615 classpath = files("$jalviewDir/$utilsDir")
616 main = "HelpLinksChecker"
617 workingDir = jalviewDir
618 def help = "$classes/$helpDir"
619 args = [ "$classes/$helpDir", "-nointernet" ]
622 helplinkscheckeroutputfile.createNewFile()
623 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
626 outputs.file(helplinkscheckeroutputfile)
629 task cleanPackageDir(type: Delete) {
630 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
635 dependsOn buildIndices
636 dependsOn createBuildProperties
639 attributes "Main-Class": mainClass,
640 "Permissions": "all-permissions",
641 "Application-Name": "Jalview Desktop",
642 "Codebase": application_codebase
645 destinationDir = file("$jalviewDir/$packageDir")
646 archiveName = rootProject.name+".jar"
654 inputs.dir("$classes")
655 outputs.file("$jalviewDir/$packageDir/$archiveName")
658 task copyJars(type: Copy) {
659 from fileTree("$classes").include("**/*.jar").include("*.jar").files
660 into "$jalviewDir/$packageDir"
663 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
664 task syncJars(type: Sync) {
665 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
666 into "$jalviewDir/$packageDir"
668 include jar.archiveName
674 description = "Put all required libraries in dist"
675 // order of "cleanPackageDir", "copyJars", "jar" important!
676 jar.mustRunAfter cleanPackageDir
677 syncJars.mustRunAfter cleanPackageDir
678 dependsOn cleanPackageDir
681 outputs.dir("$jalviewDir/$packageDir")
685 dependsOn cleanPackageDir
691 group = "distribution"
693 from ("$jalviewDir/$libDistDir") {
696 mainClassName = shadowJarMainClass
698 classifier = "all-"+JAVA_VERSION
702 task getdownWebsite() {
703 group = "distribution"
704 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
706 def getdownWebsiteResourceFilenames = []
707 def getdownTextString = ""
708 def getdownResourceDir = project.ext.getdownResourceDir
709 def getdownAppDir = project.ext.getdownAppDir
710 def getdownResourceFilenames = []
712 // go through properties looking for getdown_txt_...
713 def props = project.properties.sort { it.key }
714 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
715 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
717 if (getdown_local == "true") {
718 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
720 props.put("getdown_txt_appbase", getdown_app_base)
721 props.each{ prop, val ->
722 if (prop.startsWith("getdown_txt_") && val != null) {
723 if (prop.startsWith("getdown_txt_multi_")) {
724 def key = prop.substring(18)
725 val.split(",").each{ v ->
726 def line = key + " = " + v + "\n"
727 getdownTextString += line
730 // file values rationalised
731 if (val.indexOf('/') > -1) {
733 if (val.indexOf('/') == 0) {
736 } else if (val.indexOf('/') > 0) {
737 // relative path (relative to jalviewDir)
738 r = file( jalviewDir + '/' + val )
741 val = getdown_resource_dir + '/' + r.getName()
742 getdownWebsiteResourceFilenames += val
743 getdownResourceFilenames += r.getPath()
746 def line = prop.substring(12) + " = " + val + "\n"
747 getdownTextString += line
752 getdownWebsiteResourceFilenames.each{ filename ->
753 getdownTextString += "resource = "+filename+"\n"
755 getdownResourceFilenames.each{ filename ->
758 into project.ext.getdownResourceDir
763 makeDist.outputs.files.each{ f ->
764 if (f.isDirectory()) {
765 def files = fileTree(dir: f, include: ["*"]).getFiles()
767 } else if (f.exists()) {
771 codeFiles.sort().each{f ->
772 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
773 getdownTextString += line
776 into project.ext.getdownAppDir
780 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
782 if (JAVA_VERSION.equals("11")) {
783 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
784 j11libFiles.sort().each{f ->
785 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
786 getdownTextString += line
789 into project.ext.getdownJ11libDir
795 // 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.
796 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
797 getdownTextString += "resource = " + file(getdownLauncher).getName() + "\n"
798 getdownTextString += "class = " + mainClass + "\n"
800 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
801 getdown_txt.write(getdownTextString)
805 into project.ext.getdownFilesDir
810 into project.ext.getdownFilesDir
815 into project.ext.getdownWebsiteDir
819 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
820 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
821 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
822 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
823 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
824 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
828 inputs.dir(jalviewDir + '/' + packageDir)
829 outputs.dir(project.ext.getdownWebsiteDir)
830 outputs.dir(project.ext.getdownFilesDir)
833 task getdownDigest(type: JavaExec) {
834 group = "distribution"
835 description = "Digest the getdown website folder"
836 dependsOn getdownWebsite
837 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
838 main = "com.threerings.getdown.tools.Digester"
839 args project.ext.getdownWebsiteDir
840 inputs.dir(project.ext.getdownWebsiteDir)
841 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
845 group = "distribution"
846 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
847 dependsOn getdownDigest
851 delete project.ext.getdownWebsiteDir
852 delete project.ext.getdownFilesDir
856 def install4jHomeDir = "/opt/install4j"
857 def hostname = "hostname".execute().text.trim()
858 if (hostname.equals("jv-bamboo")) {
859 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
860 } else if (OperatingSystem.current().isMacOsX()) {
861 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
862 if (! file(install4jHomeDir).exists()) {
863 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
865 } else if (OperatingSystem.current().isLinux()) {
866 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
868 installDir = file(install4jHomeDir)
869 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
870 if (install4jFaster.equals("true")) {
880 def install4jDir = "$jalviewDir/$install4jResourceDir"
881 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
882 install4jConf = "$install4jDir/$install4jConfFile"
884 task copyInstall4jTemplate(type: Copy) {
885 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
886 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
887 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
888 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
889 from (install4jDir) {
890 include install4jTemplate
891 rename (install4jTemplate, install4jConfFile)
892 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
893 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
895 'JAVA_VERSION': JAVA_VERSION,
896 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
897 'VERSION': JALVIEW_VERSION,
898 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
899 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
900 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
901 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
902 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
903 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
904 'MACOS_BUNDLE_ID': install4jMacOSBundleId
907 if (OSX_KEYPASS=="") {
908 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
909 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
913 outputs.files(install4jConf)
916 // include file associations in installer
917 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
921 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
922 replace: installerFileAssociationsXml,
926 // include uninstaller applescript app files in dmg
927 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
931 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
932 replace: installerDMGUninstallerXml,
939 task installers(type: com.install4j.gradle.Install4jTask) {
940 group = "distribution"
941 description = "Create the install4j installers"
943 dependsOn copyInstall4jTemplate
944 projectFile = file(install4jConf)
945 println("Using projectFile "+projectFile)
946 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
947 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
951 macKeystorePassword=OSX_KEYPASS
955 inputs.dir(project.ext.getdownWebsiteDir)
956 inputs.file(install4jConf)
957 inputs.dir(macosJavaVMDir)
958 inputs.dir(windowsJavaVMDir)
959 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")