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.4.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 getdownWebsiteDir = jalviewDir + '/' + getdown_website_dir + '/' + JAVA_VERSION
56 reportRsyncCmd = false
58 buildProperties = buildPropertiesFile
59 getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher
63 // TODO: get bamboo build artifact URL for getdown artifacts
64 getdown_channel_base = bamboo_channelbase
65 getdown_channel_name = bamboo_planKey + '/'+JAVA_VERSION
66 getdown_app_base = bamboo_channelbase + '/'+ bamboo_planKey + bamboo_getdown_channel_suffix + '/'+JAVA_VERSION
67 getdown_app_dir = getdown_app_dir_alt
68 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
72 getdown_channel_name = CHANNEL.toLowerCase()
73 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
74 getdown_app_base = getdown_channel_base + "/" + getdownDir
75 getdown_app_dir = getdown_app_dir_release
76 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
77 reportRsyncCommand = true
81 getdown_channel_name = CHANNEL.toLowerCase()+"/"+JALVIEW_VERSION
82 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
83 getdown_app_base = getdown_channel_base + "/" + getdownDir
84 getdown_app_dir = getdown_app_dir_alt
85 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
86 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
89 packageDir = ARCHIVEDIR + "/" + packageDir
90 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
93 reportRsyncCommand = true
97 getdown_channel_name = "archive" + "/" + JALVIEW_VERSION
98 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
99 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
100 getdown_app_dir = getdown_app_dir_alt
101 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
102 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
105 packageDir = ARCHIVEDIR + "/" + packageDir
106 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
109 reportRsyncCommand = true
110 getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
114 getdown_channel_name = CHANNEL.toLowerCase()
115 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
116 getdown_app_base = getdown_channel_base + "/" + getdownDir
117 getdown_app_dir = getdown_app_dir_alt
118 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
119 reportRsyncCommand = true
123 getdown_channel_name = CHANNEL.toLowerCase()
124 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
125 getdown_app_base = getdown_channel_base + "/" + getdownDir
126 getdown_app_dir = getdown_app_dir_alt
127 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
128 reportRsyncCommand = true
131 case ~/^SCRATCH(|-[-\w]*)$/:
132 getdown_channel_name = CHANNEL
133 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
134 getdown_app_base = getdown_channel_base + "/" + getdownDir
135 getdown_app_dir = getdown_app_dir_alt
136 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
137 reportRsyncCommand = true
141 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
142 getdown_app_dir = getdown_app_dir_alt
143 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
144 getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
147 default: // something wrong specified
148 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
154 println("Using a "+CHANNEL+" profile. appbase="+getdown_app_base)
155 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
156 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
157 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
158 getdownInstallDir = getdownWebsiteDir + '/' + getdown_install_dir
159 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
160 getdownFilesInstallDir = getdownFilesDir+"/"+getdown_install_dir
161 /* compile without modules -- using classpath libraries
162 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
163 modules_runtimeClasspath = modules_compileClasspath
169 def JAVA_INTEGER_VERSION
170 def additional_compiler_args = []
171 // these are getdown.txt properties defined dependent on the JAVA_VERSION
172 def getdown_alt_java_min_version
173 def getdown_alt_java_max_version
174 // this property is assigned below and expanded to multiple lines in the getdown task
175 def getdown_alt_multi_java_location
176 // this property is for the Java library used in eclipse
177 def eclipse_java_runtime_name
178 if (JAVA_VERSION.equals("1.8")) {
179 JAVA_INTEGER_VERSION = "8"
182 libDistDir = j8libDir
183 compile_source_compatibility = 1.8
184 compile_target_compatibility = 1.8
185 getdown_alt_java_min_version = getdown_alt_java8_min_version
186 getdown_alt_java_max_version = getdown_alt_java8_max_version
187 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
188 eclipse_java_runtime_name = "JavaSE-1.8"
189 } else if (JAVA_VERSION.equals("11")) {
190 JAVA_INTEGER_VERSION = "11"
192 libDistDir = j11libDir
193 compile_source_compatibility = 11
194 compile_target_compatibility = 11
195 getdown_alt_java_min_version = getdown_alt_java11_min_version
196 getdown_alt_java_max_version = getdown_alt_java11_max_version
197 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
198 eclipse_java_runtime_name = "JavaSE-11"
199 /* compile without modules -- using classpath libraries
200 additional_compiler_args += [
201 '--module-path', ext.modules_compileClasspath.asPath,
202 '--add-modules', j11modules
205 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
206 JAVA_INTEGER_VERSION = JAVA_VERSION
208 libDistDir = j11libDir
209 compile_source_compatibility = JAVA_VERSION
210 compile_target_compatibility = JAVA_VERSION
211 getdown_alt_java_min_version = getdown_alt_java11_min_version
212 getdown_alt_java_max_version = getdown_alt_java11_max_version
213 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
214 eclipse_java_runtime_name = "JavaSE-11"
215 /* compile without modules -- using classpath libraries
216 additional_compiler_args += [
217 '--module-path', ext.modules_compileClasspath.asPath,
218 '--add-modules', j11modules
222 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
229 srcDirs "$jalviewDir/$sourceDir"
230 outputDir = file("$classes")
234 srcDirs "$jalviewDir/$resourceDir"
237 jar.destinationDir = file("$jalviewDir/$packageDir")
239 compileClasspath = files(sourceSets.main.java.outputDir)
240 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
242 runtimeClasspath = compileClasspath
246 srcDirs = [ cloverInstrDir ]
247 outputDir = file("${buildDir}/${cloverClassesDir}")
251 srcDirs = sourceSets.main.resources.srcDirs
253 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
254 compileClasspath += files(sourceSets.main.java.outputDir)
255 compileClasspath += sourceSets.main.compileClasspath
256 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
257 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
259 runtimeClasspath = compileClasspath
264 srcDirs "$jalviewDir/$testSourceDir"
265 outputDir = file("$jalviewDir/$testOutputDir")
269 srcDirs = sourceSets.main.resources.srcDirs
272 compileClasspath = files( sourceSets.test.java.outputDir )
275 compileClasspath = sourceSets.clover.compileClasspath
277 compileClasspath += files(sourceSets.main.java.outputDir)
280 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
281 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
283 runtimeClasspath = compileClasspath
290 cloverCompile 'org.openclover:clover:4.4.1'
291 testCompile 'org.openclover:clover:4.4.1'
297 cloverRuntime.extendsFrom cloverCompile
302 name = "Jalview with gradle build"
304 natures 'org.eclipse.jdt.core.javanature',
305 'org.eclipse.jdt.groovy.core.groovyNature',
306 'org.eclipse.buildship.core.gradleprojectnature'
308 buildCommand 'org.eclipse.jdt.core.javabuilder'
309 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
313 //defaultOutputDir = sourceSets.main.java.outputDir
315 configurations.each{ if (it.isCanBeResolved()) {
320 minusConfigurations += removeThese
321 plusConfigurations = [ ]
325 def removeTheseToo = []
326 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
327 cp.entries.each { entry ->
328 if (entry.kind == 'src') {
329 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
330 removeTheseToo += entry
332 addedSrcPath.putAt(entry.path, true)
336 cp.entries.removeAll(removeTheseToo)
338 print ("CP="+cp.inspect())
340 cp.entries += new Output("bin/main")
341 cp.entries += new Library(fileReference(helpParentDir))
342 cp.entries += new Library(fileReference(resourceDir))
344 HashMap<String, Boolean> addedLibPath = new HashMap<>();
346 // changing from sourcesets.main.classpath to specific Java version lib
347 //sourceSets.main.compileClasspath.each{
348 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
349 //don't want to add outputDir as eclipse is using its own output dir in bin/main
350 if (it.isDirectory() || ! it.exists()) {
351 // don't add dirs to classpath
354 def itPath = it.toString()
355 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
356 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
358 if (addedLibPath.get(itPath)) {
359 //println("Not adding duplicate entry "+itPath)
361 //println("Adding entry "+itPath)
362 cp.entries += new Library(fileReference(itPath))
363 addedLibPath.put(itPath, true)
367 // changing from sourcesets.main.classpath to specific Java version lib
368 //sourceSets.test.compileClasspath.each{
369 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
370 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
371 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
372 if (it.isDirectory() || ! it.exists()) {
373 // don't add dirs to classpath
374 return false // groovy "break" in .each loop
376 def itPath = it.toString()
377 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
378 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
380 if (addedLibPath.get(itPath)) {
383 def lib = new Library(fileReference(itPath))
384 // this doesn't work... yet. Adding test=true attribute using withXml below
385 //def attrs = new Node(null, 'attributes', ["test":"true"])
386 //lib.appendNode(attrs) //
388 addedLibPath.put(itPath, true)
393 // withXml changes ignored by buildship, these add the "test=true" attribute
395 def node = it.asNode()
397 def srcTestAttributes
398 node.children().each{ cpe ->
399 def attributes = cpe.attributes()
400 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
401 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
405 def addTestAttribute = true
406 srcTestAttributes.each{a ->
407 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
408 addTestAttribute = false
411 if (addTestAttribute) {
412 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
415 node.children().each{ cpe ->
416 def attributes = cpe.attributes()
417 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
418 cpe.appendNode('attributes')
419 .appendNode('attribute', [name:"test", value:"true"])
425 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
429 // for the IDE, use java 11 compatibility
430 sourceCompatibility = compile_source_compatibility
431 targetCompatibility = compile_target_compatibility
432 javaRuntimeName = eclipse_java_runtime_name
435 withProperties { props ->
436 def jalview_prefs = new Properties()
437 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
438 jalview_prefs.load(ins)
440 jalview_prefs.forEach { t, v ->
441 if (props.getAt(t) == null) {
449 //synchronizationTasks eclipseClasspath
450 //autoBuildTasks eclipseClasspath
454 // only instrument source, we build test classes as normal
455 inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
456 outputs.dir cloverInstrDir
459 delete cloverInstrDir
460 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
461 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
462 argsList.addAll(inputs.files.files.collect({ file ->
465 String[] args = argsList.toArray()
466 println("About to instrument "+args.length +" files")
467 com.atlassian.clover.CloverInstr.mainImpl(args)
472 task cloverReportHTML (type: JavaExec) {
473 inputs.dir "${buildDir}/clover"
474 outputs.dir "${reportsDir}/clover"
476 classpath configurations.cloverRuntime
477 maxHeapSize "${cloverReportJVMHeap}"
478 jvmArgs += "${cloverReportJVMArgs}"
479 main = "com.atlassian.clover.reporters.html.HtmlReporter"
480 args "--initstring", "${buildDir}/clover/clover.db", "-o", "${reportsDir}/clover"
481 "${cloverReportHTMLOptions}".split(",").each {
486 task cloverReportXML (type: JavaExec) {
487 inputs.dir "${buildDir}/clover"
488 outputs.dir "${reportsDir}/clover"
489 maxHeapSize "${cloverReportJVMHeap}"
490 jvmArgs "${cloverReportJVMArgs}"
491 classpath configurations.cloverRuntime
492 main = "com.atlassian.clover.reporters.xml.XMLReporter"
493 args "--initstring", "${buildDir}/clover/clover.db", "-o", "${reportsDir}/clover/clover.xml"
495 "${cloverReportXMLOptions}".split(",").each {
500 group = "Verification"
501 description = "Creates the Clover report"
502 inputs.dir "${buildDir}/clover"
503 outputs.dir "${reportsDir}/clover"
505 file("${buildDir}/clover/clover.db").exists()
507 dependsOn cloverReportXML
508 dependsOn cloverReportHTML
517 sourceCompatibility = compile_source_compatibility
518 targetCompatibility = compile_target_compatibility
519 options.compilerArgs = additional_compiler_args
520 print ("Setting target compatibility to "+targetCompatibility+"\n")
527 dependsOn compileCloverJava
528 classpath += configurations.cloverRuntime
530 classpath += sourceSets.main.runtimeClasspath
533 sourceCompatibility = compile_source_compatibility
534 targetCompatibility = compile_target_compatibility
535 options.compilerArgs = additional_compiler_args
536 print ("Setting target compatibility to "+targetCompatibility+"\n")
544 sourceCompatibility = compile_source_compatibility
545 targetCompatibility = compile_target_compatibility
546 options.compilerArgs += additional_compiler_args
547 print ("Setting target compatibility to "+targetCompatibility+"\n")
549 classpath += configurations.cloverRuntime
553 delete sourceSets.main.java.outputDir
557 delete sourceSets.test.java.outputDir
558 delete cloverInstrDir
561 // format is a string like date.format("dd MMMM yyyy")
562 def getDate(format) {
563 def date = new Date()
564 return date.format(format)
568 def hashStdOut = new ByteArrayOutputStream()
570 commandLine "git", "rev-parse", "--short", "HEAD"
571 standardOutput = hashStdOut
575 def branchStdOut = new ByteArrayOutputStream()
577 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
578 standardOutput = branchStdOut
582 project.ext.gitHash = hashStdOut.toString().trim()
583 project.ext.gitBranch = branchStdOut.toString().trim()
585 outputs.upToDateWhen { false }
588 task createBuildProperties(type: WriteProperties) {
590 inputs.dir("$jalviewDir/$sourceDir")
591 inputs.dir("$classes")
592 inputs.dir("$jalviewDir/$resourceDir")
593 outputFile (buildProperties)
594 // taking time specific comment out to allow better incremental builds
595 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
596 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
597 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
598 property "VERSION", JALVIEW_VERSION
599 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
600 outputs.file(outputFile)
603 def buildingHTML = "$jalviewDir/$docDir/building.html"
604 task deleteBuildingHTML(type: Delete) {
608 task convertBuildingMD(type: Exec) {
609 dependsOn deleteBuildingHTML
610 def buildingMD = "$jalviewDir/$docDir/building.md"
611 def css = "$jalviewDir/$docDir/github.css"
614 pandoc_exec.split(",").each {
615 if (file(it.trim()).exists()) {
621 def hostname = "hostname".execute().text.trim()
622 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
623 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
627 if (pandoc != null && file(pandoc).exists()) {
628 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
630 println("Cannot find pandoc. Skipping convert building.md to HTML")
631 throw new StopExecutionException()
637 inputs.file(buildingMD)
639 outputs.file(buildingHTML)
645 task syncDocs(type: Sync) {
646 dependsOn convertBuildingMD
647 def syncDir = "$classes/$docDir"
648 from fileTree("$jalviewDir/$docDir")
653 def helpFile = "$classes/$helpDir/help.jhm"
655 task copyHelp(type: Copy) {
656 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
657 def outputDir = "$classes/$helpDir"
662 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
672 outputs.files(helpFile)
673 outputs.dir(outputDir)
676 task syncLib(type: Sync) {
677 def syncDir = "$classes/$libDistDir"
678 from fileTree("$jalviewDir/$libDistDir")
682 task syncResources(type: Sync) {
683 from "$jalviewDir/$resourceDir"
693 dependsOn syncResources
699 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
702 dependsOn compileJava
704 dependsOn cloverInstr
708 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
712 includeGroups testngGroups
714 useDefaultListeners=true
717 workingDir = jalviewDir
718 //systemProperties 'clover.jar' System.properties.clover.jar
719 sourceCompatibility = compile_source_compatibility
720 targetCompatibility = compile_target_compatibility
721 jvmArgs += additional_compiler_args
722 print ("Setting target compatibility to "+targetCompatibility+"\n")
725 task buildIndices(type: JavaExec) {
727 classpath = sourceSets.main.compileClasspath
728 main = "com.sun.java.help.search.Indexer"
729 workingDir = "$classes/$helpDir"
732 inputs.dir("$workingDir/$argDir")
734 outputs.dir("$classes/doc")
735 outputs.dir("$classes/help")
736 outputs.file("$workingDir/JavaHelpSearch/DOCS")
737 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
738 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
739 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
740 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
741 outputs.file("$workingDir/JavaHelpSearch/TMAP")
744 task compileLinkCheck(type: JavaCompile) {
746 classpath = files("$jalviewDir/$utilsDir")
747 destinationDir = file("$jalviewDir/$utilsDir")
748 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
750 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
751 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
752 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
753 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
756 def helplinkscheckertouchfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.touch")
757 task linkCheck(type: JavaExec) {
758 dependsOn prepare, compileLinkCheck
759 classpath = files("$jalviewDir/$utilsDir")
760 main = "HelpLinksChecker"
761 workingDir = jalviewDir
762 def help = "$classes/$helpDir"
763 args = [ "$classes/$helpDir", "-nointernet" ]
766 helplinkscheckertouchfile.createNewFile()
769 inputs.dir("$classes/$helpDir")
770 outputs.file(helplinkscheckertouchfile)
773 // import the pubhtmlhelp target
774 ant.properties.basedir = "$jalviewDir"
775 ant.properties.helpBuildDir = jalviewDirAbsolutePath+"/$classes/$helpDir"
776 ant.importBuild "$utilsDir/publishHelp.xml"
779 task cleanPackageDir(type: Delete) {
780 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
785 dependsOn buildIndices
786 dependsOn createBuildProperties
789 attributes "Main-Class": mainClass,
790 "Permissions": "all-permissions",
791 "Application-Name": "Jalview Desktop",
792 "Codebase": application_codebase
795 destinationDir = file("$jalviewDir/$packageDir")
796 archiveName = rootProject.name+".jar"
804 inputs.dir("$classes")
805 outputs.file("$jalviewDir/$packageDir/$archiveName")
808 task copyJars(type: Copy) {
809 from fileTree("$classes").include("**/*.jar").include("*.jar").files
810 into "$jalviewDir/$packageDir"
813 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
814 task syncJars(type: Sync) {
815 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
816 into "$jalviewDir/$packageDir"
818 include jar.archiveName
824 description = "Put all required libraries in dist"
825 // order of "cleanPackageDir", "copyJars", "jar" important!
826 jar.mustRunAfter cleanPackageDir
827 syncJars.mustRunAfter cleanPackageDir
828 dependsOn cleanPackageDir
831 outputs.dir("$jalviewDir/$packageDir")
835 dependsOn cleanPackageDir
841 group = "distribution"
845 from ("$jalviewDir/$libDistDir") {
849 attributes 'Implementation-Version': JALVIEW_VERSION
851 mainClassName = shadowJarMainClass
853 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
857 task getdownWebsite() {
858 group = "distribution"
859 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
864 // clean the getdown website and files dir before creating getdown folders
865 delete project.ext.getdownWebsiteDir
866 delete project.ext.getdownFilesDir
868 def getdownWebsiteResourceFilenames = []
869 def getdownTextString = ""
870 def getdownResourceDir = project.ext.getdownResourceDir
871 def getdownAppDir = project.ext.getdownAppDir
872 def getdownResourceFilenames = []
877 rename(buildPropertiesFile, getdown_build_properties)
878 into project.ext.getdownAppDir
880 getdownWebsiteResourceFilenames += getdown_app_dir+"/"+getdown_build_properties
882 // go through properties looking for getdown_txt_...
883 def props = project.properties.sort { it.key }
884 if (getdown_alt_java_min_version.length() > 0) {
885 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
887 if (getdown_alt_java_max_version.length() > 0) {
888 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
890 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
892 props.put("getdown_txt_appbase", getdown_app_base)
893 props.each{ prop, val ->
894 if (prop.startsWith("getdown_txt_") && val != null) {
895 if (prop.startsWith("getdown_txt_multi_")) {
896 def key = prop.substring(18)
897 val.split(",").each{ v ->
898 def line = key + " = " + v + "\n"
899 getdownTextString += line
902 // file values rationalised
903 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
905 if (val.indexOf('/') == 0) {
908 } else if (val.indexOf('/') > 0) {
909 // relative path (relative to jalviewDir)
910 r = file( jalviewDir + '/' + val )
913 val = getdown_resource_dir + '/' + r.getName()
914 getdownWebsiteResourceFilenames += val
915 getdownResourceFilenames += r.getPath()
918 if (! prop.startsWith("getdown_txt_resource")) {
919 def line = prop.substring(12) + " = " + val + "\n"
920 getdownTextString += line
926 getdownWebsiteResourceFilenames.each{ filename ->
927 getdownTextString += "resource = "+filename+"\n"
929 getdownResourceFilenames.each{ filename ->
932 into project.ext.getdownResourceDir
937 fileTree(file(packageDir)).each{ f ->
938 if (f.isDirectory()) {
939 def files = fileTree(dir: f, include: ["*"]).getFiles()
941 } else if (f.exists()) {
945 codeFiles.sort().each{f ->
946 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
947 getdownTextString += line
950 into project.ext.getdownAppDir
954 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
956 if (JAVA_VERSION.equals("11")) {
957 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
958 j11libFiles.sort().each{f ->
959 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
960 getdownTextString += line
963 into project.ext.getdownJ11libDir
969 // 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.
970 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
971 getdownTextString += "resource = " + getdown_launcher_new + "\n"
972 getdownTextString += "class = " + mainClass + "\n"
974 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
975 getdown_txt.write(getdownTextString)
977 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
978 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
982 rename(file(getdownLauncher).getName(), getdown_launcher_new)
983 into project.ext.getdownWebsiteDir
988 if (file(getdownLauncher).getName() != getdown_launcher) {
989 rename(file(getdownLauncher).getName(), getdown_launcher)
991 into project.ext.getdownWebsiteDir
994 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
998 from getdownWebsiteDir+"/"+getdown_build_properties
999 if (file(getdownLauncher).getName() != getdown_launcher) {
1000 rename(file(getdownLauncher).getName(), getdown_launcher)
1002 into getdownInstallDir
1006 from getdownInstallDir
1007 into getdownFilesInstallDir
1014 from getdownLauncher
1015 from getdownWebsiteDir+"/"+getdown_build_properties
1016 if (file(getdownLauncher).getName() != getdown_launcher) {
1017 rename(file(getdownLauncher).getName(), getdown_launcher)
1019 into getdownFilesDir
1023 from getdownResourceDir
1024 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
1029 inputs.dir(jalviewDir + '/' + packageDir)
1031 outputs.dir(project.ext.getdownWebsiteDir)
1032 outputs.dir(project.ext.getdownFilesDir)
1035 task getdownDigest(type: JavaExec) {
1036 group = "distribution"
1037 description = "Digest the getdown website folder"
1038 dependsOn getdownWebsite
1040 classpath = files(getdownWebsiteDir + '/' + getdown_launcher)
1042 main = "com.threerings.getdown.tools.Digester"
1043 args project.ext.getdownWebsiteDir
1044 inputs.dir(project.ext.getdownWebsiteDir)
1045 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
1049 group = "distribution"
1050 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1051 dependsOn getdownDigest
1053 if (reportRsyncCommand) {
1054 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
1055 def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
1056 println "LIKELY RSYNC COMMAND:"
1057 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1058 if (RUNRSYNC == "true") {
1060 commandLine "mkdir", "-p", toDir
1063 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1071 delete project.ext.getdownWebsiteDir
1072 delete project.ext.getdownFilesDir
1076 def install4jHomeDir = "/opt/install4j"
1077 def hostname = "hostname".execute().text.trim()
1078 if (hostname.equals("jv-bamboo")) {
1079 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1080 } else if (OperatingSystem.current().isMacOsX()) {
1081 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1082 if (! file(install4jHomeDir).exists()) {
1083 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1085 } else if (OperatingSystem.current().isLinux()) {
1086 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1088 installDir = file(install4jHomeDir)
1089 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1090 if (install4jFaster.equals("true")) {
1098 def windowsJavaVMDir
1099 def windowsJavaVMTgz
1100 def install4jDir = "$jalviewDir/$install4jResourceDir"
1101 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
1102 install4jConf = "$install4jDir/$install4jConfFile"
1104 task copyInstall4jTemplate(type: Copy) {
1105 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
1106 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
1107 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
1108 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
1109 from (install4jDir) {
1110 include install4jTemplate
1111 rename (install4jTemplate, install4jConfFile)
1112 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1113 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1115 'JAVA_VERSION': JAVA_VERSION,
1116 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1117 'VERSION': JALVIEW_VERSION,
1118 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1119 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1120 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1121 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1122 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1123 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1124 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1125 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1126 'GETDOWN_DIST_DIR': getdown_app_dir,
1127 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1128 'GETDOWN_INSTALL_DIR': getdown_install_dir
1131 if (OSX_KEYPASS=="") {
1132 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1133 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1137 outputs.files(install4jConf)
1140 // include file associations in installer
1141 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
1145 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1146 replace: installerFileAssociationsXml,
1150 // include uninstaller applescript app files in dmg
1151 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1155 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1156 replace: installerDMGUninstallerXml,
1163 task installers(type: com.install4j.gradle.Install4jTask) {
1164 group = "distribution"
1165 description = "Create the install4j installers"
1167 dependsOn copyInstall4jTemplate
1168 projectFile = file(install4jConf)
1169 println("Using projectFile "+projectFile)
1170 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1171 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
1172 buildSelected = true
1175 macKeystorePassword=OSX_KEYPASS
1179 inputs.dir(project.ext.getdownWebsiteDir)
1180 inputs.file(install4jConf)
1181 inputs.dir(macosJavaVMDir)
1182 inputs.dir(windowsJavaVMDir)
1183 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1188 delete install4jConf
1191 task sourceDist (type: Tar) {
1193 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1194 def outputFileName = project.name + "_" + VERSION_UNDERSCORES + ".tar.gz"
1195 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1197 archiveFileName = outputFileName
1198 } catch (Exception e) {
1199 archiveName = outputFileName
1202 compression Compression.GZIP
1217 "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
1219 "utils/InstallAnywhere",
1234 "gradle.properties",
1245 ".settings/org.eclipse.jdt.core.jalview.prefs",
1249 exclude (EXCLUDE_FILES)
1250 include (PROCESS_FILES)
1251 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1254 exclude (EXCLUDE_FILES)
1255 exclude (PROCESS_FILES)
1256 exclude ("appletlib")
1257 exclude ("**/*locales")
1258 exclude ("*locales/**")
1259 exclude ("utils/InstallAnywhere")
1261 exclude (getdown_files_dir)
1262 exclude (getdown_website_dir)
1264 // exluding these as not using jars as modules yet
1265 exclude ("$j11modDir/**/*.jar")
1268 include(INCLUDE_FILES)
1270 // from (jalviewDir) {
1271 // // explicit includes for stuff that seemed to not get included
1272 // include(fileTree("test/**/*."))
1273 // exclude(EXCLUDE_FILES)
1274 // exclude(PROCESS_FILES)
1280 dependsOn pubhtmlhelp
1282 inputs.dir("$classes/$helpDir")
1283 outputs.dir("$helpOutputDir")