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 if (getdown_local == "true") {
55 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
56 getdown_channel_name = "local"
58 getdown_app_base = getdown_channel_base+"/"+getdown_channel_name+"/"+JAVA_VERSION+"/"
60 if (getdown_channel_name.equals("release") {
61 getdown_app_dir = getdown_channel_name
63 // where the getdown channel will be built.
64 getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION
65 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
66 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
67 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
68 getdownLauncher = jalviewDir + '/' + getdown_launcher
69 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
70 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
71 modules_runtimeClasspath = modules_compileClasspath
76 def JAVA_INTEGER_VERSION
77 def additional_compiler_args = []
78 // these are getdown.txt properties defined dependent on the JAVA_VERSION
79 def getdown_alt_java_min_version
80 // this property is assigned below and expanded to multiple lines in the getdown task
81 def getdown_alt_multi_java_location
82 // this property is for the Java library used in eclipse
83 def eclipse_java_runtime_name
84 if (JAVA_VERSION.equals("1.8")) {
85 JAVA_INTEGER_VERSION = "8"
89 compile_source_compatibility = 1.8
90 compile_target_compatibility = 1.8
91 getdown_alt_java_min_version = getdown_alt_java8_min_version
92 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
93 eclipse_java_runtime_name = "JavaSE-1.8"
94 } else if (JAVA_VERSION.equals("11")) {
95 JAVA_INTEGER_VERSION = "11"
97 libDistDir = j11libDir
98 compile_source_compatibility = 11
99 compile_target_compatibility = 11
100 getdown_alt_java_min_version = getdown_alt_java11_min_version
101 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
102 eclipse_java_runtime_name = "JavaSE-11"
103 additional_compiler_args += [
104 '--module-path', ext.modules_compileClasspath.asPath,
105 '--add-modules', j11modules
107 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
108 JAVA_INTEGER_VERSION = JAVA_VERSION
110 libDistDir = j11libDir
111 compile_source_compatibility = JAVA_VERSION
112 compile_target_compatibility = JAVA_VERSION
113 getdown_alt_java_min_version = getdown_alt_java11_min_version
114 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
115 eclipse_java_runtime_name = "JavaSE-11"
116 additional_compiler_args += [
117 '--module-path', ext.modules_compileClasspath.asPath,
118 '--add-modules', j11modules
121 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
128 srcDirs "$jalviewDir/$sourceDir"
129 outputDir = file("$classes")
133 srcDirs "$jalviewDir/$resourceDir"
136 jar.destinationDir = file("$jalviewDir/$packageDir")
138 compileClasspath = files(sourceSets.main.java.outputDir)
139 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
141 runtimeClasspath = compileClasspath
145 srcDirs = [ cloverInstrDir ]
146 outputDir = file("${buildDir}/${cloverClassesDir}")
150 srcDirs = sourceSets.main.resources.srcDirs
152 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
153 compileClasspath += files(sourceSets.main.java.outputDir)
154 compileClasspath += sourceSets.main.compileClasspath
155 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
156 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
158 runtimeClasspath = compileClasspath
163 srcDirs "$jalviewDir/$testSourceDir"
164 outputDir = file("$jalviewDir/$testOutputDir")
168 srcDirs = sourceSets.main.resources.srcDirs
171 compileClasspath = files( sourceSets.test.java.outputDir )
174 compileClasspath += sourceSets.clover.compileClasspath
176 compileClasspath += files(sourceSets.main.java.outputDir)
179 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
180 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
182 runtimeClasspath = compileClasspath
189 cloverCompile 'org.openclover:clover:4.3.1'
190 testCompile 'org.openclover:clover:4.3.1'
196 cloverRuntime.extendsFrom cloverCompile
201 name = "Jalview with gradle build"
203 natures 'org.eclipse.jdt.core.javanature',
204 'org.eclipse.jdt.groovy.core.groovyNature',
205 'org.eclipse.buildship.core.gradleprojectnature'
207 buildCommand 'org.eclipse.jdt.core.javabuilder'
208 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
212 //defaultOutputDir = sourceSets.main.java.outputDir
214 configurations.each{ if (it.isCanBeResolved()) {
219 minusConfigurations += removeThese
220 plusConfigurations = [ ]
224 def removeTheseToo = []
225 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
226 cp.entries.each { entry ->
227 if (entry.kind == 'src') {
228 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
229 removeTheseToo += entry
231 addedSrcPath.putAt(entry.path, true)
235 cp.entries.removeAll(removeTheseToo)
237 print ("CP="+cp.inspect())
239 cp.entries += new Output("bin/main")
240 cp.entries += new Library(fileReference(helpParentDir))
241 cp.entries += new Library(fileReference(resourceDir))
243 HashMap<String, Boolean> addedLibPath = new HashMap<>();
245 // changing from sourcesets.main.classpath to specific Java version lib
246 //sourceSets.main.compileClasspath.each{
247 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
248 //don't want to add outputDir as eclipse is using its own output dir in bin/main
249 if (it.isDirectory() || ! it.exists()) {
250 // don't add dirs to classpath
253 def itPath = it.toString()
254 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
255 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
257 if (addedLibPath.get(itPath)) {
258 //println("Not adding duplicate entry "+itPath)
260 //println("Adding entry "+itPath)
261 cp.entries += new Library(fileReference(itPath))
262 addedLibPath.put(itPath, true)
266 // changing from sourcesets.main.classpath to specific Java version lib
267 //sourceSets.test.compileClasspath.each{
268 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
269 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
270 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
271 if (it.isDirectory() || ! it.exists()) {
272 // don't add dirs to classpath
273 return false // groovy "break" in .each loop
275 def itPath = it.toString()
276 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
277 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
279 if (addedLibPath.get(itPath)) {
282 def lib = new Library(fileReference(itPath))
283 // this doesn't work... yet. Adding test=true attribute using withXml below
284 //def attrs = new Node(null, 'attributes', ["test":"true"])
285 //lib.appendNode(attrs) //
287 addedLibPath.put(itPath, true)
292 // withXml changes ignored by buildship, these add the "test=true" attribute
294 def node = it.asNode()
296 def srcTestAttributes
297 node.children().each{ cpe ->
298 def attributes = cpe.attributes()
299 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
300 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
304 def addTestAttribute = true
305 srcTestAttributes.each{a ->
306 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
307 addTestAttribute = false
310 if (addTestAttribute) {
311 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
314 node.children().each{ cpe ->
315 def attributes = cpe.attributes()
316 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
317 cpe.appendNode('attributes')
318 .appendNode('attribute', [name:"test", value:"true"])
324 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
328 // for the IDE, use java 11 compatibility
329 sourceCompatibility = compile_source_compatibility
330 targetCompatibility = compile_target_compatibility
331 javaRuntimeName = eclipse_java_runtime_name
334 withProperties { props ->
335 def jalview_prefs = new Properties()
336 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
337 jalview_prefs.load(ins)
339 jalview_prefs.forEach { t, v ->
340 if (props.getAt(t) == null) {
348 //synchronizationTasks eclipseClasspath
349 //autoBuildTasks eclipseClasspath
353 // only instrument source, we build test classes as normal
354 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
355 outputs.dir cloverInstrDir
358 delete cloverInstrDir
359 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
360 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
361 argsList.addAll(inputs.files.files.collect({ file ->
364 String[] args = argsList.toArray()
365 println("About to instrument "+args.length +" files")
366 com.atlassian.clover.CloverInstr.mainImpl(args)
372 group = "Verification"
373 description = "Createst the Clover report"
374 inputs.dir "${buildDir}/clover"
375 outputs.dir "${reportsDir}/clover"
377 file("${buildDir}/clover/clover.db").exists()
380 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
381 "-o", "${reportsDir}/clover"]
382 String[] args = argsList.toArray()
383 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
385 // and generate ${reportsDir}/clover/clover.xml
386 args = ["--initstring", "${buildDir}/clover/clover.db",
387 "-o", "${reportsDir}/clover/clover.xml"].toArray()
388 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
398 sourceCompatibility = compile_source_compatibility
399 targetCompatibility = compile_target_compatibility
400 options.compilerArgs = additional_compiler_args
401 print ("Setting target compatibility to "+targetCompatibility+"\n")
408 dependsOn compileCloverJava
409 classpath += configurations.cloverRuntime
411 classpath += sourceSets.main.runtimeClasspath
414 sourceCompatibility = compile_source_compatibility
415 targetCompatibility = compile_target_compatibility
416 options.compilerArgs = additional_compiler_args
417 print ("Setting target compatibility to "+targetCompatibility+"\n")
425 sourceCompatibility = compile_source_compatibility
426 targetCompatibility = compile_target_compatibility
427 options.compilerArgs += additional_compiler_args
428 print ("Setting target compatibility to "+targetCompatibility+"\n")
430 classpath += configurations.cloverRuntime
434 delete sourceSets.main.java.outputDir
438 delete sourceSets.test.java.outputDir
439 delete cloverInstrDir
442 // format is a string like date.format("dd MMMM yyyy")
443 def getDate(format) {
444 def date = new Date()
445 return date.format(format)
449 def hashStdOut = new ByteArrayOutputStream()
451 commandLine "git", "rev-parse", "--short", "HEAD"
452 standardOutput = hashStdOut
456 def branchStdOut = new ByteArrayOutputStream()
458 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
459 standardOutput = branchStdOut
463 project.ext.gitHash = hashStdOut.toString().trim()
464 project.ext.gitBranch = branchStdOut.toString().trim()
466 outputs.upToDateWhen { false }
469 task createBuildProperties(type: WriteProperties) {
471 inputs.dir("$jalviewDir/$sourceDir")
472 inputs.dir("$classes")
473 inputs.dir("$jalviewDir/$resourceDir")
474 outputFile "$classes/$buildPropertiesFile"
475 // taking time specific comment out to allow better incremental builds
476 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
477 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
478 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
479 property "VERSION", JALVIEW_VERSION
480 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
481 outputs.file(outputFile)
484 def buildingHTML = "$jalviewDir/$docDir/building.html"
485 task deleteBuildingHTML(type: Delete) {
489 task convertBuildingMD(type: Exec) {
490 dependsOn deleteBuildingHTML
491 def buildingMD = "$jalviewDir/$docDir/building.md"
492 def css = "$jalviewDir/$docDir/github.css"
495 pandoc_exec.split(",").each {
496 if (file(it.trim()).exists()) {
502 def hostname = "hostname".execute().text.trim()
503 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
504 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
507 if (pandoc != null && file(pandoc).exists()) {
508 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
515 inputs.file(buildingMD)
517 outputs.file(buildingHTML)
523 task syncDocs(type: Sync) {
524 dependsOn convertBuildingMD
525 def syncDir = "$classes/$docDir"
526 from fileTree("$jalviewDir/$docDir")
531 def helpFile = "$classes/$helpDir/help.jhm"
533 task copyHelp(type: Copy) {
534 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
535 def outputDir = "$classes/$helpDir"
540 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION])
550 outputs.files(helpFile)
551 outputs.dir(outputDir)
554 task syncLib(type: Sync) {
555 def syncDir = "$classes/$libDistDir"
556 from fileTree("$jalviewDir/$libDistDir")
560 task syncResources(type: Sync) {
561 from "$jalviewDir/$resourceDir"
571 dependsOn syncResources
577 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
580 dependsOn compileJava
582 dependsOn cloverInstr
585 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
588 includeGroups testngGroups
590 useDefaultListeners=true
593 workingDir = jalviewDir
594 //systemProperties 'clover.jar' System.properties.clover.jar
595 sourceCompatibility = compile_source_compatibility
596 targetCompatibility = compile_target_compatibility
597 jvmArgs += additional_compiler_args
598 print ("Setting target compatibility to "+targetCompatibility+"\n")
601 task buildIndices(type: JavaExec) {
603 classpath = sourceSets.main.compileClasspath
604 main = "com.sun.java.help.search.Indexer"
605 workingDir = "$classes/$helpDir"
608 inputs.dir("$workingDir/$argDir")
610 outputs.dir("$classes/doc")
611 outputs.dir("$classes/help")
612 outputs.file("$workingDir/JavaHelpSearch/DOCS")
613 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
614 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
615 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
616 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
617 outputs.file("$workingDir/JavaHelpSearch/TMAP")
620 task compileLinkCheck(type: JavaCompile) {
622 classpath = files("$jalviewDir/$utilsDir")
623 destinationDir = file("$jalviewDir/$utilsDir")
624 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
626 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
627 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
628 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
629 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
632 def helplinkscheckeroutputfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.out")
633 task linkCheck(type: JavaExec) {
634 dependsOn prepare, compileLinkCheck
635 classpath = files("$jalviewDir/$utilsDir")
636 main = "HelpLinksChecker"
637 workingDir = jalviewDir
638 def help = "$classes/$helpDir"
639 args = [ "$classes/$helpDir", "-nointernet" ]
642 helplinkscheckeroutputfile.createNewFile()
643 standardOutput new FileOutputStream(helplinkscheckeroutputfile, false)
646 outputs.file(helplinkscheckeroutputfile)
649 task cleanPackageDir(type: Delete) {
650 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
655 dependsOn buildIndices
656 dependsOn createBuildProperties
659 attributes "Main-Class": mainClass,
660 "Permissions": "all-permissions",
661 "Application-Name": "Jalview Desktop",
662 "Codebase": application_codebase
665 destinationDir = file("$jalviewDir/$packageDir")
666 archiveName = rootProject.name+".jar"
674 inputs.dir("$classes")
675 outputs.file("$jalviewDir/$packageDir/$archiveName")
678 task copyJars(type: Copy) {
679 from fileTree("$classes").include("**/*.jar").include("*.jar").files
680 into "$jalviewDir/$packageDir"
683 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
684 task syncJars(type: Sync) {
685 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
686 into "$jalviewDir/$packageDir"
688 include jar.archiveName
694 description = "Put all required libraries in dist"
695 // order of "cleanPackageDir", "copyJars", "jar" important!
696 jar.mustRunAfter cleanPackageDir
697 syncJars.mustRunAfter cleanPackageDir
698 dependsOn cleanPackageDir
701 outputs.dir("$jalviewDir/$packageDir")
705 dependsOn cleanPackageDir
711 group = "distribution"
713 from ("$jalviewDir/$libDistDir") {
716 mainClassName = shadowJarMainClass
718 classifier = "all-"+JAVA_VERSION
722 task getdownWebsite() {
723 group = "distribution"
724 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
726 def getdownWebsiteResourceFilenames = []
727 def getdownTextString = ""
728 def getdownResourceDir = project.ext.getdownResourceDir
729 def getdownAppDir = project.ext.getdownAppDir
730 def getdownResourceFilenames = []
733 from "$classes/$buildPropertiesFile"
734 rename(buildPropertiesFile, getdown_install_build_properties)
735 into project.ext.getdownWebsiteDir
737 getdownResourceFilenames += getdown_current_build_properties
740 // go through properties looking for getdown_txt_...
741 def props = project.properties.sort { it.key }
742 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
743 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
744 props.put("getdown_txt_resource", "$classes/$buildPropertiesFile")
746 props.put("getdown_txt_appbase", getdown_app_base)
747 props.each{ prop, val ->
748 if (prop.startsWith("getdown_txt_") && val != null) {
749 if (prop.startsWith("getdown_txt_multi_")) {
750 def key = prop.substring(18)
751 val.split(",").each{ v ->
752 def line = key + " = " + v + "\n"
753 getdownTextString += line
756 // file values rationalised
757 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
759 if (val.indexOf('/') == 0) {
762 } else if (val.indexOf('/') > 0) {
763 // relative path (relative to jalviewDir)
764 r = file( jalviewDir + '/' + val )
767 val = getdown_resource_dir + '/' + r.getName()
768 getdownWebsiteResourceFilenames += val
769 getdownResourceFilenames += r.getPath()
772 if (! prop.startsWith("getdown_txt_resource")) {
773 def line = prop.substring(12) + " = " + val + "\n"
774 getdownTextString += line
780 getdownWebsiteResourceFilenames.each{ filename ->
781 getdownTextString += "resource = "+filename+"\n"
783 getdownResourceFilenames.each{ filename ->
786 into project.ext.getdownResourceDir
791 makeDist.outputs.files.each{ f ->
792 if (f.isDirectory()) {
793 def files = fileTree(dir: f, include: ["*"]).getFiles()
795 } else if (f.exists()) {
799 codeFiles.sort().each{f ->
800 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
801 getdownTextString += line
804 into project.ext.getdownAppDir
808 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
810 if (JAVA_VERSION.equals("11")) {
811 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
812 j11libFiles.sort().each{f ->
813 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
814 getdownTextString += line
817 into project.ext.getdownJ11libDir
823 // 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.
824 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
825 getdownTextString += "resource = " + getdown_launcher_new + "\n"
826 getdownTextString += "class = " + mainClass + "\n"
828 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
829 getdown_txt.write(getdownTextString)
831 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
832 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
837 from project.ext.getdownWebsiteDir+"/"+getdown_current_build_properties
838 from project.ext.getdownWebsiteDir+"/"+getdown_install_build_properties
839 into project.ext.getdownFilesDir
844 into project.ext.getdownWebsiteDir
845 rename(file(getdownLauncher).getName(), getdown_launcher_new)
850 into project.ext.getdownFilesDir
855 into project.ext.getdownWebsiteDir
859 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.background_image')
860 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.error_background')
861 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.progress_image')
862 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.icon')
863 from jalviewDir + '/' + project.getProperty('getdown_txt_ui.mac_dock_icon')
864 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
868 inputs.dir(jalviewDir + '/' + packageDir)
869 outputs.dir(project.ext.getdownWebsiteDir)
870 outputs.dir(project.ext.getdownFilesDir)
873 task getdownDigest(type: JavaExec) {
874 group = "distribution"
875 description = "Digest the getdown website folder"
876 dependsOn getdownWebsite
877 classpath = files(jalviewDir + '/' + getdown_core, jalviewDir+'/'+getdown_launcher)
878 main = "com.threerings.getdown.tools.Digester"
879 args project.ext.getdownWebsiteDir
880 inputs.dir(project.ext.getdownWebsiteDir)
881 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
885 group = "distribution"
886 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
887 dependsOn getdownDigest
891 delete project.ext.getdownWebsiteDir
892 delete project.ext.getdownFilesDir
896 def install4jHomeDir = "/opt/install4j"
897 def hostname = "hostname".execute().text.trim()
898 if (hostname.equals("jv-bamboo")) {
899 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
900 } else if (OperatingSystem.current().isMacOsX()) {
901 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
902 if (! file(install4jHomeDir).exists()) {
903 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
905 } else if (OperatingSystem.current().isLinux()) {
906 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
908 installDir = file(install4jHomeDir)
909 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
910 if (install4jFaster.equals("true")) {
920 def install4jDir = "$jalviewDir/$install4jResourceDir"
921 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
922 install4jConf = "$install4jDir/$install4jConfFile"
924 task copyInstall4jTemplate(type: Copy) {
925 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
926 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
927 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
928 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
929 from (install4jDir) {
930 include install4jTemplate
931 rename (install4jTemplate, install4jConfFile)
932 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
933 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
935 'JAVA_VERSION': JAVA_VERSION,
936 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
937 'VERSION': JALVIEW_VERSION,
938 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
939 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
940 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
941 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
942 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
943 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
944 'MACOS_BUNDLE_ID': install4jMacOSBundleId
947 if (OSX_KEYPASS=="") {
948 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
949 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
953 outputs.files(install4jConf)
956 // include file associations in installer
957 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
961 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
962 replace: installerFileAssociationsXml,
966 // include uninstaller applescript app files in dmg
967 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
971 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
972 replace: installerDMGUninstallerXml,
979 task installers(type: com.install4j.gradle.Install4jTask) {
980 group = "distribution"
981 description = "Create the install4j installers"
983 dependsOn copyInstall4jTemplate
984 projectFile = file(install4jConf)
985 println("Using projectFile "+projectFile)
986 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
987 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
991 macKeystorePassword=OSX_KEYPASS
995 inputs.dir(project.ext.getdownWebsiteDir)
996 inputs.file(install4jConf)
997 inputs.dir(macosJavaVMDir)
998 inputs.dir(windowsJavaVMDir)
999 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1003 delete install4jConf