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"
114 srcDirs "$jalviewDir/$libDistDir"
117 jar.destinationDir = file("$jalviewDir/$packageDir")
119 compileClasspath = files(sourceSets.main.java.outputDir)
120 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
122 runtimeClasspath = compileClasspath
126 srcDirs = [ cloverInstrDir ]
127 outputDir = file("${buildDir}/${cloverClassesDir}")
131 srcDirs = sourceSets.main.resources.srcDirs
133 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
134 compileClasspath += files(sourceSets.main.java.outputDir)
135 compileClasspath += sourceSets.main.compileClasspath
136 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
137 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
139 runtimeClasspath = compileClasspath
144 srcDirs "$jalviewDir/$testSourceDir"
145 outputDir = file("$jalviewDir/$testOutputDir")
149 srcDirs = sourceSets.main.resources.srcDirs
152 compileClasspath = files( sourceSets.test.java.outputDir )
155 compileClasspath += sourceSets.clover.compileClasspath
157 compileClasspath += files(sourceSets.main.java.outputDir)
159 //compileClasspath += sourceSets.main.compileClasspath
160 //compileClasspath += files( sourceSets.main.resources.srcDirs)
161 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
162 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
164 runtimeClasspath = compileClasspath
171 cloverCompile 'org.openclover:clover:4.3.1'
172 testCompile 'org.openclover:clover:4.3.1'
178 cloverRuntime.extendsFrom cloverCompile
183 name = "Jalview with gradle build"
185 natures 'org.eclipse.jdt.core.javanature',
186 'org.eclipse.jdt.groovy.core.groovyNature',
187 'org.eclipse.buildship.core.gradleprojectnature'
189 buildCommand 'org.eclipse.jdt.core.javabuilder'
190 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
194 //defaultOutputDir = sourceSets.main.java.outputDir
196 configurations.each{ if (it.isCanBeResolved()) {
201 minusConfigurations += removeThese
202 plusConfigurations = [ ]
206 def removeTheseToo = []
207 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
208 cp.entries.each { entry ->
209 if (entry.kind == 'src') {
210 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
211 removeTheseToo += entry
213 addedSrcPath.putAt(entry.path, true)
217 cp.entries.removeAll(removeTheseToo)
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<>();
224 def allPaths = sourceSets.test.compileClasspath + sourceSets.main.compileClasspath
225 sourceSets.main.compileClasspath.each{
226 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
227 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
228 if (it.isDirectory() || ! it.exists()) {
229 // don't add dirs to classpath
232 def itPath = it.toString()
233 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
234 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
236 if (addedLibPath.get(itPath)) {
237 //println("Not adding duplicate entry "+itPath)
239 //println("Adding entry "+itPath)
240 cp.entries += new Library(fileReference(itPath))
241 addedLibPath.put(itPath, true)
245 sourceSets.test.compileClasspath.each{
246 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
247 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
248 if (it.isDirectory() || ! it.exists()) {
249 // don't add dirs to classpath
250 return false // groovy "break" in .each loop
252 def itPath = it.toString()
253 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
254 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
256 if (addedLibPath.get(itPath)) {
259 def lib = new Library(fileReference(itPath))
260 // this doesn't work... yet. Adding test=true attribute using withXml below
261 //def attrs = new Node(null, 'attributes', ["test":"true"])
262 //lib.appendNode(attrs) //
264 addedLibPath.put(itPath, true)
269 // withXml changes ignored by buildship, these add the "test=true" attribute
271 def node = it.asNode()
273 def srcTestAttributes
274 node.children().each{ cpe ->
275 def attributes = cpe.attributes()
276 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
277 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
281 def addTestAttribute = true
282 srcTestAttributes.each{a ->
283 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
284 addTestAttribute = false
287 if (addTestAttribute) {
288 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
291 node.children().each{ cpe ->
292 def attributes = cpe.attributes()
293 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
294 cpe.appendNode('attributes')
295 .appendNode('attribute', [name:"test", value:"true"])
301 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
305 // for the IDE, use java 11 compatibility
306 sourceCompatibility = JAVA_VERSION
307 targetCompatibility = JAVA_VERSION
308 javaRuntimeName = eclipse_java_runtime_name
311 withProperties { props ->
312 def jalview_prefs = new Properties()
313 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
314 jalview_prefs.load(ins)
316 jalview_prefs.forEach { t, v ->
317 if (props.getAt(t) == null) {
325 //synchronizationTasks eclipseClasspath
326 //autoBuildTasks eclipseClasspath
330 // only instrument source, we build test classes as normal
331 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
332 outputs.dir cloverInstrDir
335 delete cloverInstrDir
336 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
337 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
338 argsList.addAll(inputs.files.files.collect({ file ->
341 String[] args = argsList.toArray()
342 println("About to instrument "+args.length +" files")
343 com.atlassian.clover.CloverInstr.mainImpl(args)
349 group = "Verification"
350 description = "Createst the Clover report"
351 inputs.dir "${buildDir}/clover"
352 outputs.dir "${reportsDir}/clover"
354 file("${buildDir}/clover/clover.db").exists()
357 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
358 "-o", "${reportsDir}/clover"]
359 String[] args = argsList.toArray()
360 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
362 // and generate ${reportsDir}/clover/clover.xml
363 args = ["--initstring", "${buildDir}/clover/clover.db",
364 "-o", "${reportsDir}/clover/clover.xml"].toArray()
365 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
375 sourceCompatibility = compile_source_compatibility
376 targetCompatibility = compile_target_compatibility
377 options.compilerArgs = additional_compiler_args
378 print ("Setting target compatibility to "+targetCompatibility+"\n")
385 dependsOn compileCloverJava
386 classpath += configurations.cloverRuntime
388 classpath += sourceSets.main.runtimeClasspath
391 sourceCompatibility = compile_source_compatibility
392 targetCompatibility = compile_target_compatibility
393 options.compilerArgs = additional_compiler_args
394 print ("Setting target compatibility to "+targetCompatibility+"\n")
402 sourceCompatibility = compile_source_compatibility
403 targetCompatibility = compile_target_compatibility
404 options.compilerArgs += additional_compiler_args
405 print ("Setting target compatibility to "+targetCompatibility+"\n")
407 classpath += configurations.cloverRuntime
411 delete sourceSets.main.java.outputDir
415 delete sourceSets.test.java.outputDir
416 delete cloverInstrDir
419 def getDate(format) {
420 def date = new Date()
421 //return date.format("dd MMMM yyyy")
422 return date.format(format)
426 def hashStdOut = new ByteArrayOutputStream()
428 commandLine "git", "rev-parse", "--short", "HEAD"
429 standardOutput = hashStdOut
433 def branchStdOut = new ByteArrayOutputStream()
435 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
436 standardOutput = branchStdOut
440 project.ext.gitHash = hashStdOut.toString().trim()
441 project.ext.gitBranch = branchStdOut.toString().trim()
443 outputs.upToDateWhen { false }
446 task createBuildProperties(type: WriteProperties) {
448 inputs.dir("$jalviewDir/$sourceDir")
449 inputs.dir("$classes")
450 inputs.dir("$jalviewDir/$resourceDir")
451 outputFile "$classes/$buildPropertiesFile"
452 // taking time specific comment out to allow better incremental builds
453 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
454 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
455 property "BUILD_DATE", getDate("dd MMMM yyyy")
456 property "VERSION", JALVIEW_VERSION
457 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
458 outputs.file(outputFile)
461 def buildingHTML = "$jalviewDir/$docDir/building.html"
462 task deleteBuildingHTML(type: Delete) {
466 task convertBuildingMD(type: Exec) {
467 dependsOn deleteBuildingHTML
468 def buildingMD = "$jalviewDir/$docDir/building.md"
469 def css = "$jalviewDir/$docDir/github.css"
471 def pandoc = pandoc_exec
472 def hostname = "hostname".execute().text.trim()
473 if (! file(pandoc).exists() && hostname.equals("jv-bamboo")) {
474 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
477 if (file(pandoc).exists()) {
478 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
485 inputs.file(buildingMD)
487 outputs.file(buildingHTML)
493 task syncDocs(type: Sync) {
494 dependsOn convertBuildingMD
495 def syncDir = "$classes/$docDir"
496 from fileTree("$jalviewDir/$docDir")
501 def helpFile = "$classes/$helpDir/help.jhm"
503 task copyHelp(type: Copy) {
504 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
505 def outputDir = "$classes/$helpDir"
510 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
520 outputs.files(helpFile)
521 outputs.dir(outputDir)
524 task syncLib(type: Sync) {
525 def syncDir = "$classes/$libDistDir"
526 from fileTree("$jalviewDir/$libDistDir")
530 task syncResources(type: Sync) {
531 from "$jalviewDir/$resourceDir"
541 dependsOn syncResources
547 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
550 dependsOn compileJava
552 dependsOn cloverInstr
555 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
558 includeGroups testngGroups
560 useDefaultListeners=true
563 workingDir = jalviewDir
564 //systemProperties 'clover.jar' System.properties.clover.jar
565 sourceCompatibility = compile_source_compatibility
566 targetCompatibility = compile_target_compatibility
567 jvmArgs += additional_compiler_args
568 print ("Setting target compatibility to "+targetCompatibility+"\n")
571 task buildIndices(type: JavaExec) {
573 classpath = sourceSets.main.compileClasspath
574 main = "com.sun.java.help.search.Indexer"
575 workingDir = "$classes/$helpDir"
578 inputs.dir("$workingDir/$argDir")
580 outputs.dir("$classes/doc")
581 outputs.dir("$classes/help")
582 outputs.file("$workingDir/JavaHelpSearch/DOCS")
583 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
584 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
585 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
586 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
587 outputs.file("$workingDir/JavaHelpSearch/TMAP")
590 task compileLinkCheck(type: JavaCompile) {
592 classpath = files("$jalviewDir/$utilsDir")
593 destinationDir = file("$jalviewDir/$utilsDir")
594 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
596 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
597 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
598 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
599 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
602 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
603 task linkCheck(type: JavaExec) {
604 dependsOn prepare, compileLinkCheck
605 classpath = files("$jalviewDir/$utilsDir")
606 main = "HelpLinksChecker"
607 workingDir = jalviewDir
608 def help = "$classes/$helpDir"
609 args = [ "$classes/$helpDir", "-nointernet" ]
612 helplinkscheckeroutputfile.createNewFile()
613 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
616 outputs.file(helplinkscheckeroutputfile)
619 task cleanPackageDir(type: Delete) {
620 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
625 dependsOn buildIndices
626 dependsOn createBuildProperties
629 attributes "Main-Class": mainClass,
630 "Permissions": "all-permissions",
631 "Application-Name": "Jalview Desktop",
632 "Codebase": application_codebase
635 destinationDir = file("$jalviewDir/$packageDir")
636 archiveName = rootProject.name+".jar"
644 inputs.dir("$classes")
645 outputs.file("$jalviewDir/$packageDir/$archiveName")
648 task copyJars(type: Copy) {
649 from fileTree("$classes").include("**/*.jar").include("*.jar").files
650 into "$jalviewDir/$packageDir"
653 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
654 task syncJars(type: Sync) {
655 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
656 into "$jalviewDir/$packageDir"
658 include jar.archiveName
664 description = "Put all required libraries in dist"
665 // order of "cleanPackageDir", "copyJars", "jar" important!
666 jar.mustRunAfter cleanPackageDir
667 syncJars.mustRunAfter cleanPackageDir
668 dependsOn cleanPackageDir
671 outputs.dir("$jalviewDir/$packageDir")
675 dependsOn cleanPackageDir
681 group = "distribution"
683 from ("$jalviewDir/$libDistDir") {
686 mainClassName = shadowJarMainClass
688 classifier = "all-"+JAVA_VERSION
692 task getdownWebsite() {
693 group = "distribution"
694 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
696 def getdownWebsiteResourceFilenames = []
697 def getdownTextString = ""
698 def getdownResourceDir = project.ext.getdownResourceDir
699 def getdownAppDir = project.ext.getdownAppDir
700 def getdownResourceFilenames = []
702 // go through properties looking for getdown_txt_...
703 def props = project.properties.sort { it.key }
704 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
705 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
707 if (getdown_local == "true") {
708 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
710 props.put("getdown_txt_appbase", getdown_app_base)
711 props.each{ prop, val ->
712 if (prop.startsWith("getdown_txt_") && val != null) {
713 if (prop.startsWith("getdown_txt_multi_")) {
714 def key = prop.substring(18)
715 val.split(",").each{ v ->
716 def line = key + " = " + v + "\n"
717 getdownTextString += line
720 // file values rationalised
721 if (val.indexOf('/') > -1) {
723 if (val.indexOf('/') == 0) {
726 } else if (val.indexOf('/') > 0) {
727 // relative path (relative to jalviewDir)
728 r = file( jalviewDir + '/' + val )
731 val = getdown_resource_dir + '/' + r.getName()
732 getdownWebsiteResourceFilenames += val
733 getdownResourceFilenames += r.getPath()
736 def line = prop.substring(12) + " = " + val + "\n"
737 getdownTextString += line
742 getdownWebsiteResourceFilenames.each{ filename ->
743 getdownTextString += "resource = "+filename+"\n"
745 getdownResourceFilenames.each{ filename ->
748 into project.ext.getdownResourceDir
753 makeDist.outputs.files.each{ f ->
754 if (f.isDirectory()) {
755 def files = fileTree(dir: f, include: ["*"]).getFiles()
757 } else if (f.exists()) {
761 codeFiles.sort().each{f ->
762 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
763 getdownTextString += line
766 into project.ext.getdownAppDir
770 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
772 if (JAVA_VERSION.equals("11")) {
773 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
774 j11libFiles.sort().each{f ->
775 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
776 getdownTextString += line
779 into project.ext.getdownJ11libDir
785 // 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.
786 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
787 getdownTextString += "resource = " + file(getdownLauncher).getName() + "\n"
788 getdownTextString += "class = " + mainClass + "\n"
790 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
791 getdown_txt.write(getdownTextString)
795 into project.ext.getdownFilesDir
800 into project.ext.getdownFilesDir
805 into project.ext.getdownWebsiteDir
809 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
810 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
811 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
812 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
813 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
814 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
818 inputs.dir(jalviewDir + '/' + packageDir)
819 outputs.dir(project.ext.getdownWebsiteDir)
820 outputs.dir(project.ext.getdownFilesDir)
823 task getdownDigest(type: JavaExec) {
824 group = "distribution"
825 description = "Digest the getdown website folder"
826 dependsOn getdownWebsite
827 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
828 main = "com.threerings.getdown.tools.Digester"
829 args project.ext.getdownWebsiteDir
830 inputs.dir(project.ext.getdownWebsiteDir)
831 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
835 group = "distribution"
836 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
837 dependsOn getdownDigest
841 delete project.ext.getdownWebsiteDir
842 delete project.ext.getdownFilesDir
846 def install4jHomeDir = "/opt/install4j"
847 def hostname = "hostname".execute().text.trim()
848 if (hostname.equals("jv-bamboo")) {
849 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
850 } else if (OperatingSystem.current().isMacOsX()) {
851 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
852 if (! file(install4jHomeDir).exists()) {
853 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
855 } else if (OperatingSystem.current().isLinux()) {
856 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
858 installDir = file(install4jHomeDir)
859 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
860 if (install4jFaster.equals("true")) {
870 def install4jDir = "$jalviewDir/$install4jResourceDir"
871 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
872 install4jConf = "$install4jDir/$install4jConfFile"
874 task copyInstall4jTemplate(type: Copy) {
875 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
876 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
877 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
878 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
879 from (install4jDir) {
880 include install4jTemplate
881 rename (install4jTemplate, install4jConfFile)
882 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
883 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
885 'JAVA_VERSION': JAVA_VERSION,
886 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
887 'VERSION': JALVIEW_VERSION,
888 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
889 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
890 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
891 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
892 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
893 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
894 'MACOS_BUNDLE_ID': install4jMacOSBundleId
897 if (OSX_KEYPASS=="") {
898 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
899 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
903 outputs.files(install4jConf)
906 // include file associations in installer
907 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
911 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
912 replace: installerFileAssociationsXml,
916 // include uninstaller applescript app files in dmg
917 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
921 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
922 replace: installerDMGUninstallerXml,
929 task installers(type: com.install4j.gradle.Install4jTask) {
930 group = "distribution"
931 description = "Create the install4j installers"
933 dependsOn copyInstall4jTemplate
934 projectFile = file(install4jConf)
935 println("Using projectFile "+projectFile)
936 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
937 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
941 macKeystorePassword=OSX_KEYPASS
945 inputs.dir(project.ext.getdownWebsiteDir)
946 inputs.file(install4jConf)
947 inputs.dir(macosJavaVMDir)
948 inputs.dir(windowsJavaVMDir)
949 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")