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 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_app_dir = getdown_app_dir_alt
65 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
69 getdown_channel_name = CHANNEL.toLowerCase()
70 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
71 getdown_app_base = getdown_channel_base + "/" + getdownDir
72 getdown_app_dir = getdown_app_dir_release
73 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
74 reportRsyncCommand = true
78 getdown_channel_name = CHANNEL.toLowerCase()+"/"+JALVIEW_VERSION
79 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
80 getdown_app_base = getdown_channel_base + "/" + getdownDir
81 getdown_app_dir = getdown_app_dir_alt
82 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
83 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
86 packageDir = ARCHIVEDIR + "/" + packageDir
87 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
90 reportRsyncCommand = true
94 getdown_channel_name = "archive" + "/" + JALVIEW_VERSION
95 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
96 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
97 getdown_app_dir = getdown_app_dir_alt
98 if (!file(ARCHIVEDIR+"/"+packageDir).exists()) {
99 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
102 packageDir = ARCHIVEDIR + "/" + packageDir
103 buildProperties = ARCHIVEDIR +"/" + classesDir + "/" + buildPropertiesFile
106 reportRsyncCommand = true
107 getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
111 getdown_channel_name = CHANNEL.toLowerCase()
112 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
113 getdown_app_base = getdown_channel_base + "/" + getdownDir
114 getdown_app_dir = getdown_app_dir_alt
115 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
116 reportRsyncCommand = true
120 getdown_channel_name = CHANNEL.toLowerCase()
121 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
122 getdown_app_base = getdown_channel_base + "/" + getdownDir
123 getdown_app_dir = getdown_app_dir_alt
124 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
125 reportRsyncCommand = true
128 case ~/^SCRATCH(|-[-\w]*)$/:
129 getdown_channel_name = CHANNEL
130 getdownDir = getdown_channel_name + "/" + JAVA_VERSION
131 getdown_app_base = getdown_channel_base + "/" + getdownDir
132 getdown_app_dir = getdown_app_dir_alt
133 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
134 reportRsyncCommand = true
138 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
139 getdown_app_dir = getdown_app_dir_alt
140 buildProperties = jalviewDir + "/" + classesDir +"/" + buildPropertiesFile
141 getdownLauncher = jalviewDir + '/' + getdown_lib_dir + '/' + getdown_launcher_local
144 default: // something wrong specified
145 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
151 println("Using a "+CHANNEL+" profile. appbase="+getdown_app_base)
152 getdownAppDir = getdownWebsiteDir + '/' + getdown_app_dir
153 //getdownJ11libDir = getdownWebsiteDir + '/' + getdown_j11lib_dir
154 getdownResourceDir = getdownWebsiteDir + '/' + getdown_resource_dir
155 getdownInstallDir = getdownWebsiteDir + '/' + getdown_install_dir
156 getdownFilesDir = jalviewDir + '/' + getdown_files_dir + '/' + JAVA_VERSION + '/'
157 getdownFilesInstallDir = getdownFilesDir+"/"+getdown_install_dir
158 /* compile without modules -- using classpath libraries
159 modules_compileClasspath = fileTree(dir: "$jalviewDir/$j11modDir", include: ["*.jar"])
160 modules_runtimeClasspath = modules_compileClasspath
166 def JAVA_INTEGER_VERSION
167 def additional_compiler_args = []
168 // these are getdown.txt properties defined dependent on the JAVA_VERSION
169 def getdown_alt_java_min_version
170 def getdown_alt_java_max_version
171 // this property is assigned below and expanded to multiple lines in the getdown task
172 def getdown_alt_multi_java_location
173 // this property is for the Java library used in eclipse
174 def eclipse_java_runtime_name
175 if (JAVA_VERSION.equals("1.8")) {
176 JAVA_INTEGER_VERSION = "8"
179 libDistDir = j8libDir
180 compile_source_compatibility = 1.8
181 compile_target_compatibility = 1.8
182 getdown_alt_java_min_version = getdown_alt_java8_min_version
183 getdown_alt_java_max_version = getdown_alt_java8_max_version
184 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
185 eclipse_java_runtime_name = "JavaSE-1.8"
186 } else if (JAVA_VERSION.equals("11")) {
187 JAVA_INTEGER_VERSION = "11"
189 libDistDir = j11libDir
190 compile_source_compatibility = 11
191 compile_target_compatibility = 11
192 getdown_alt_java_min_version = getdown_alt_java11_min_version
193 getdown_alt_java_max_version = getdown_alt_java11_max_version
194 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
195 eclipse_java_runtime_name = "JavaSE-11"
196 /* compile without modules -- using classpath libraries
197 additional_compiler_args += [
198 '--module-path', ext.modules_compileClasspath.asPath,
199 '--add-modules', j11modules
202 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
203 JAVA_INTEGER_VERSION = JAVA_VERSION
205 libDistDir = j11libDir
206 compile_source_compatibility = JAVA_VERSION
207 compile_target_compatibility = JAVA_VERSION
208 getdown_alt_java_min_version = getdown_alt_java11_min_version
209 getdown_alt_java_max_version = getdown_alt_java11_max_version
210 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
211 eclipse_java_runtime_name = "JavaSE-11"
212 /* compile without modules -- using classpath libraries
213 additional_compiler_args += [
214 '--module-path', ext.modules_compileClasspath.asPath,
215 '--add-modules', j11modules
219 throw new GradleException("JAVA_VERSION=$JAVA_VERSION not currently supported by Jalview")
226 srcDirs "$jalviewDir/$sourceDir"
227 outputDir = file("$classes")
231 srcDirs "$jalviewDir/$resourceDir"
234 jar.destinationDir = file("$jalviewDir/$packageDir")
236 compileClasspath = files(sourceSets.main.java.outputDir)
237 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
239 runtimeClasspath = compileClasspath
243 srcDirs = [ cloverInstrDir ]
244 outputDir = file("${buildDir}/${cloverClassesDir}")
248 srcDirs = sourceSets.main.resources.srcDirs
250 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
251 compileClasspath += files(sourceSets.main.java.outputDir)
252 compileClasspath += sourceSets.main.compileClasspath
253 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
254 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
256 runtimeClasspath = compileClasspath
261 srcDirs "$jalviewDir/$testSourceDir"
262 outputDir = file("$jalviewDir/$testOutputDir")
266 srcDirs = sourceSets.main.resources.srcDirs
269 compileClasspath = files( sourceSets.test.java.outputDir )
272 compileClasspath += sourceSets.clover.compileClasspath
274 compileClasspath += files(sourceSets.main.java.outputDir)
277 compileClasspath += fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"])
278 compileClasspath += fileTree(dir: "$jalviewDir/$libDir", include: ["*.jar"])
280 runtimeClasspath = compileClasspath
287 cloverCompile 'org.openclover:clover:4.3.1'
288 testCompile 'org.openclover:clover:4.3.1'
294 cloverRuntime.extendsFrom cloverCompile
299 name = "Jalview with gradle build"
301 natures 'org.eclipse.jdt.core.javanature',
302 'org.eclipse.jdt.groovy.core.groovyNature',
303 'org.eclipse.buildship.core.gradleprojectnature'
305 buildCommand 'org.eclipse.jdt.core.javabuilder'
306 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
310 //defaultOutputDir = sourceSets.main.java.outputDir
312 configurations.each{ if (it.isCanBeResolved()) {
317 minusConfigurations += removeThese
318 plusConfigurations = [ ]
322 def removeTheseToo = []
323 HashMap<String, Boolean> addedSrcPath = new HashMap<>();
324 cp.entries.each { entry ->
325 if (entry.kind == 'src') {
326 if (addedSrcPath.getAt(entry.path) || !(entry.path == "src" || entry.path == "test")) {
327 removeTheseToo += entry
329 addedSrcPath.putAt(entry.path, true)
333 cp.entries.removeAll(removeTheseToo)
335 print ("CP="+cp.inspect())
337 cp.entries += new Output("bin/main")
338 cp.entries += new Library(fileReference(helpParentDir))
339 cp.entries += new Library(fileReference(resourceDir))
341 HashMap<String, Boolean> addedLibPath = new HashMap<>();
343 // changing from sourcesets.main.classpath to specific Java version lib
344 //sourceSets.main.compileClasspath.each{
345 fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").each {
346 //don't want to add outputDir as eclipse is using its own output dir in bin/main
347 if (it.isDirectory() || ! it.exists()) {
348 // don't add dirs to classpath
351 def itPath = it.toString()
352 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
353 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
355 if (addedLibPath.get(itPath)) {
356 //println("Not adding duplicate entry "+itPath)
358 //println("Adding entry "+itPath)
359 cp.entries += new Library(fileReference(itPath))
360 addedLibPath.put(itPath, true)
364 // changing from sourcesets.main.classpath to specific Java version lib
365 //sourceSets.test.compileClasspath.each{
366 fileTree(dir: "$jalviewDir/$utilsDir", include: ["**/*.jar"]).each {
367 //if ((it.isDirectory() || ! it.exists()) && ! (it.equals(sourceSets.main.java.outputDir))) {
368 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
369 if (it.isDirectory() || ! it.exists()) {
370 // don't add dirs to classpath
371 return false // groovy "break" in .each loop
373 def itPath = it.toString()
374 if (itPath.startsWith(jalviewDirAbsolutePath+"/")) {
375 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
377 if (addedLibPath.get(itPath)) {
380 def lib = new Library(fileReference(itPath))
381 // this doesn't work... yet. Adding test=true attribute using withXml below
382 //def attrs = new Node(null, 'attributes', ["test":"true"])
383 //lib.appendNode(attrs) //
385 addedLibPath.put(itPath, true)
390 // withXml changes ignored by buildship, these add the "test=true" attribute
392 def node = it.asNode()
394 def srcTestAttributes
395 node.children().each{ cpe ->
396 def attributes = cpe.attributes()
397 if (attributes.get("kind") == "src" && attributes.get("path") == "test") {
398 srcTestAttributes = cpe.find { a -> a.name() == "attributes" }
402 def addTestAttribute = true
403 srcTestAttributes.each{a ->
404 if (a.name() == "attribute" && a.attributes().getAt("name") == "test") {
405 addTestAttribute = false
408 if (addTestAttribute) {
409 srcTestAttributes.append(new Node(null, "attribute", [name:"test", value:"true"]))
412 node.children().each{ cpe ->
413 def attributes = cpe.attributes()
414 if (attributes.get("kind") == "lib" && attributes.get("path").startsWith("utils/")) {
415 cpe.appendNode('attributes')
416 .appendNode('attribute', [name:"test", value:"true"])
422 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
426 // for the IDE, use java 11 compatibility
427 sourceCompatibility = compile_source_compatibility
428 targetCompatibility = compile_target_compatibility
429 javaRuntimeName = eclipse_java_runtime_name
432 withProperties { props ->
433 def jalview_prefs = new Properties()
434 def ins = new FileInputStream(jalviewDirAbsolutePath+"/"+eclipse_extra_jdt_prefs_file)
435 jalview_prefs.load(ins)
437 jalview_prefs.forEach { t, v ->
438 if (props.getAt(t) == null) {
446 //synchronizationTasks eclipseClasspath
447 //autoBuildTasks eclipseClasspath
451 // only instrument source, we build test classes as normal
452 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
453 outputs.dir cloverInstrDir
456 delete cloverInstrDir
457 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
458 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
459 argsList.addAll(inputs.files.files.collect({ file ->
462 String[] args = argsList.toArray()
463 println("About to instrument "+args.length +" files")
464 com.atlassian.clover.CloverInstr.mainImpl(args)
470 group = "Verification"
471 description = "Createst the Clover report"
472 inputs.dir "${buildDir}/clover"
473 outputs.dir "${reportsDir}/clover"
475 file("${buildDir}/clover/clover.db").exists()
478 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
479 "-o", "${reportsDir}/clover"]
480 String[] args = argsList.toArray()
481 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
483 // and generate ${reportsDir}/clover/clover.xml
484 args = ["--initstring", "${buildDir}/clover/clover.db",
485 "-o", "${reportsDir}/clover/clover.xml"].toArray()
486 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
496 sourceCompatibility = compile_source_compatibility
497 targetCompatibility = compile_target_compatibility
498 options.compilerArgs = additional_compiler_args
499 print ("Setting target compatibility to "+targetCompatibility+"\n")
506 dependsOn compileCloverJava
507 classpath += configurations.cloverRuntime
509 classpath += sourceSets.main.runtimeClasspath
512 sourceCompatibility = compile_source_compatibility
513 targetCompatibility = compile_target_compatibility
514 options.compilerArgs = additional_compiler_args
515 print ("Setting target compatibility to "+targetCompatibility+"\n")
523 sourceCompatibility = compile_source_compatibility
524 targetCompatibility = compile_target_compatibility
525 options.compilerArgs += additional_compiler_args
526 print ("Setting target compatibility to "+targetCompatibility+"\n")
528 classpath += configurations.cloverRuntime
532 delete sourceSets.main.java.outputDir
536 delete sourceSets.test.java.outputDir
537 delete cloverInstrDir
540 // format is a string like date.format("dd MMMM yyyy")
541 def getDate(format) {
542 def date = new Date()
543 return date.format(format)
547 def hashStdOut = new ByteArrayOutputStream()
549 commandLine "git", "rev-parse", "--short", "HEAD"
550 standardOutput = hashStdOut
554 def branchStdOut = new ByteArrayOutputStream()
556 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
557 standardOutput = branchStdOut
561 project.ext.gitHash = hashStdOut.toString().trim()
562 project.ext.gitBranch = branchStdOut.toString().trim()
564 outputs.upToDateWhen { false }
567 task createBuildProperties(type: WriteProperties) {
569 inputs.dir("$jalviewDir/$sourceDir")
570 inputs.dir("$classes")
571 inputs.dir("$jalviewDir/$resourceDir")
572 outputFile (buildProperties)
573 // taking time specific comment out to allow better incremental builds
574 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
575 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
576 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
577 property "VERSION", JALVIEW_VERSION
578 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
579 outputs.file(outputFile)
582 def buildingHTML = "$jalviewDir/$docDir/building.html"
583 task deleteBuildingHTML(type: Delete) {
587 task convertBuildingMD(type: Exec) {
588 dependsOn deleteBuildingHTML
589 def buildingMD = "$jalviewDir/$docDir/building.md"
590 def css = "$jalviewDir/$docDir/github.css"
593 pandoc_exec.split(",").each {
594 if (file(it.trim()).exists()) {
600 def hostname = "hostname".execute().text.trim()
601 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
602 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
606 if (pandoc != null && file(pandoc).exists()) {
607 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
609 println("Cannot find pandoc. Skipping convert building.md to HTML")
610 throw new StopExecutionException()
616 inputs.file(buildingMD)
618 outputs.file(buildingHTML)
624 task syncDocs(type: Sync) {
625 dependsOn convertBuildingMD
626 def syncDir = "$classes/$docDir"
627 from fileTree("$jalviewDir/$docDir")
632 def helpFile = "$classes/$helpDir/help.jhm"
634 task copyHelp(type: Copy) {
635 def inputDir = "$jalviewDir/$helpParentDir/$helpDir"
636 def outputDir = "$classes/$helpDir"
641 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
651 outputs.files(helpFile)
652 outputs.dir(outputDir)
655 task syncLib(type: Sync) {
656 def syncDir = "$classes/$libDistDir"
657 from fileTree("$jalviewDir/$libDistDir")
661 task syncResources(type: Sync) {
662 from "$jalviewDir/$resourceDir"
672 dependsOn syncResources
678 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
681 dependsOn compileJava
683 dependsOn cloverInstr
687 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
691 includeGroups testngGroups
693 useDefaultListeners=true
696 workingDir = jalviewDir
697 //systemProperties 'clover.jar' System.properties.clover.jar
698 sourceCompatibility = compile_source_compatibility
699 targetCompatibility = compile_target_compatibility
700 jvmArgs += additional_compiler_args
701 print ("Setting target compatibility to "+targetCompatibility+"\n")
704 task buildIndices(type: JavaExec) {
706 classpath = sourceSets.main.compileClasspath
707 main = "com.sun.java.help.search.Indexer"
708 workingDir = "$classes/$helpDir"
711 inputs.dir("$workingDir/$argDir")
713 outputs.dir("$classes/doc")
714 outputs.dir("$classes/help")
715 outputs.file("$workingDir/JavaHelpSearch/DOCS")
716 outputs.file("$workingDir/JavaHelpSearch/DOCS.TAB")
717 outputs.file("$workingDir/JavaHelpSearch/OFFSETS")
718 outputs.file("$workingDir/JavaHelpSearch/POSITIONS")
719 outputs.file("$workingDir/JavaHelpSearch/SCHEMA")
720 outputs.file("$workingDir/JavaHelpSearch/TMAP")
723 task compileLinkCheck(type: JavaCompile) {
725 classpath = files("$jalviewDir/$utilsDir")
726 destinationDir = file("$jalviewDir/$utilsDir")
727 source = fileTree(dir: "$jalviewDir/$utilsDir", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
729 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
730 inputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.java")
731 outputs.file("$jalviewDir/$utilsDir/HelpLinksChecker.class")
732 outputs.file("$jalviewDir/$utilsDir/BufferedLineReader.class")
735 def helplinkscheckertouchfile = file("$jalviewDir/$utilsDir/HelpLinksChecker.touch")
736 task linkCheck(type: JavaExec) {
737 dependsOn prepare, compileLinkCheck
738 classpath = files("$jalviewDir/$utilsDir")
739 main = "HelpLinksChecker"
740 workingDir = jalviewDir
741 def help = "$classes/$helpDir"
742 args = [ "$classes/$helpDir", "-nointernet" ]
745 helplinkscheckertouchfile.createNewFile()
748 inputs.dir("$classes/$helpDir")
749 outputs.file(helplinkscheckertouchfile)
752 // import the pubhtmlhelp target
753 ant.properties.basedir = "$jalviewDir"
754 ant.properties.helpBuildDir = jalviewDirAbsolutePath+"/$classes/$helpDir"
755 ant.importBuild "$utilsDir/publishHelp.xml"
758 task cleanPackageDir(type: Delete) {
759 delete fileTree("$jalviewDir/$packageDir").include("*.jar")
764 dependsOn buildIndices
765 dependsOn createBuildProperties
768 attributes "Main-Class": mainClass,
769 "Permissions": "all-permissions",
770 "Application-Name": "Jalview Desktop",
771 "Codebase": application_codebase
774 destinationDir = file("$jalviewDir/$packageDir")
775 archiveName = rootProject.name+".jar"
783 inputs.dir("$classes")
784 outputs.file("$jalviewDir/$packageDir/$archiveName")
787 task copyJars(type: Copy) {
788 from fileTree("$classes").include("**/*.jar").include("*.jar").files
789 into "$jalviewDir/$packageDir"
792 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
793 task syncJars(type: Sync) {
794 from fileTree("$jalviewDir/$libDistDir").include("**/*.jar").include("*.jar").files
795 into "$jalviewDir/$packageDir"
797 include jar.archiveName
803 description = "Put all required libraries in dist"
804 // order of "cleanPackageDir", "copyJars", "jar" important!
805 jar.mustRunAfter cleanPackageDir
806 syncJars.mustRunAfter cleanPackageDir
807 dependsOn cleanPackageDir
810 outputs.dir("$jalviewDir/$packageDir")
814 dependsOn cleanPackageDir
820 group = "distribution"
824 from ("$jalviewDir/$libDistDir") {
828 attributes 'Implementation-Version': JALVIEW_VERSION
830 mainClassName = shadowJarMainClass
832 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
836 task getdownWebsite() {
837 group = "distribution"
838 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
843 // clean the getdown website and files dir before creating getdown folders
844 delete project.ext.getdownWebsiteDir
845 delete project.ext.getdownFilesDir
847 def getdownWebsiteResourceFilenames = []
848 def getdownTextString = ""
849 def getdownResourceDir = project.ext.getdownResourceDir
850 def getdownAppDir = project.ext.getdownAppDir
851 def getdownResourceFilenames = []
856 rename(buildPropertiesFile, getdown_build_properties)
857 into project.ext.getdownAppDir
859 getdownWebsiteResourceFilenames += getdown_app_dir+"/"+getdown_build_properties
861 // go through properties looking for getdown_txt_...
862 def props = project.properties.sort { it.key }
863 if (getdown_alt_java_min_version.length() > 0) {
864 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
866 if (getdown_alt_java_max_version.length() > 0) {
867 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
869 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
871 props.put("getdown_txt_appbase", getdown_app_base)
872 props.each{ prop, val ->
873 if (prop.startsWith("getdown_txt_") && val != null) {
874 if (prop.startsWith("getdown_txt_multi_")) {
875 def key = prop.substring(18)
876 val.split(",").each{ v ->
877 def line = key + " = " + v + "\n"
878 getdownTextString += line
881 // file values rationalised
882 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
884 if (val.indexOf('/') == 0) {
887 } else if (val.indexOf('/') > 0) {
888 // relative path (relative to jalviewDir)
889 r = file( jalviewDir + '/' + val )
892 val = getdown_resource_dir + '/' + r.getName()
893 getdownWebsiteResourceFilenames += val
894 getdownResourceFilenames += r.getPath()
897 if (! prop.startsWith("getdown_txt_resource")) {
898 def line = prop.substring(12) + " = " + val + "\n"
899 getdownTextString += line
905 getdownWebsiteResourceFilenames.each{ filename ->
906 getdownTextString += "resource = "+filename+"\n"
908 getdownResourceFilenames.each{ filename ->
911 into project.ext.getdownResourceDir
916 fileTree(file(packageDir)).each{ f ->
917 if (f.isDirectory()) {
918 def files = fileTree(dir: f, include: ["*"]).getFiles()
920 } else if (f.exists()) {
924 codeFiles.sort().each{f ->
925 def line = "code = " + getdown_app_dir + '/' + f.getName() + "\n"
926 getdownTextString += line
929 into project.ext.getdownAppDir
933 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
935 if (JAVA_VERSION.equals("11")) {
936 def j11libFiles = fileTree(dir: "$jalviewDir/$j11libDir", include: ["*.jar"]).getFiles()
937 j11libFiles.sort().each{f ->
938 def line = "code = " + getdown_j11lib_dir + '/' + f.getName() + "\n"
939 getdownTextString += line
942 into project.ext.getdownJ11libDir
948 // 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.
949 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
950 getdownTextString += "resource = " + getdown_launcher_new + "\n"
951 getdownTextString += "class = " + mainClass + "\n"
953 def getdown_txt = file(project.ext.getdownWebsiteDir + "/getdown.txt")
954 getdown_txt.write(getdownTextString)
956 def launch_jvl = file(project.ext.getdownWebsiteDir + "/" + getdown_launch_jvl)
957 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
961 rename(file(getdownLauncher).getName(), getdown_launcher_new)
962 into project.ext.getdownWebsiteDir
967 if (file(getdownLauncher).getName() != getdown_launcher) {
968 rename(file(getdownLauncher).getName(), getdown_launcher)
970 into project.ext.getdownWebsiteDir
973 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
977 from getdownWebsiteDir+"/"+getdown_build_properties
978 if (file(getdownLauncher).getName() != getdown_launcher) {
979 rename(file(getdownLauncher).getName(), getdown_launcher)
981 into getdownInstallDir
985 from getdownInstallDir
986 into getdownFilesInstallDir
994 from getdownWebsiteDir+"/"+getdown_build_properties
995 if (file(getdownLauncher).getName() != getdown_launcher) {
996 rename(file(getdownLauncher).getName(), getdown_launcher)
1002 from getdownResourceDir
1003 into project.ext.getdownFilesDir + '/' + getdown_resource_dir
1008 inputs.dir(jalviewDir + '/' + packageDir)
1010 outputs.dir(project.ext.getdownWebsiteDir)
1011 outputs.dir(project.ext.getdownFilesDir)
1014 task getdownDigest(type: JavaExec) {
1015 group = "distribution"
1016 description = "Digest the getdown website folder"
1017 dependsOn getdownWebsite
1019 classpath = files(getdownWebsiteDir + '/' + getdown_launcher)
1021 main = "com.threerings.getdown.tools.Digester"
1022 args project.ext.getdownWebsiteDir
1023 inputs.dir(project.ext.getdownWebsiteDir)
1024 outputs.file(project.ext.getdownWebsiteDir + '/' + "digest2.txt")
1028 group = "distribution"
1029 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1030 dependsOn getdownDigest
1032 if (reportRsyncCommand) {
1033 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith("/")?"":"/")
1034 def toDir = getdown_rsync_dest + "/" + getdownDir + (getdownDir.endsWith("/")?"":"/")
1035 println "LIKELY RSYNC COMMAND:"
1036 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1037 if (RUNRSYNC == "true") {
1039 commandLine "mkdir", "-p", toDir
1042 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1050 delete project.ext.getdownWebsiteDir
1051 delete project.ext.getdownFilesDir
1055 def install4jHomeDir = "/opt/install4j"
1056 def hostname = "hostname".execute().text.trim()
1057 if (hostname.equals("jv-bamboo")) {
1058 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1059 } else if (OperatingSystem.current().isMacOsX()) {
1060 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1061 if (! file(install4jHomeDir).exists()) {
1062 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1064 } else if (OperatingSystem.current().isLinux()) {
1065 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1067 installDir = file(install4jHomeDir)
1068 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1069 if (install4jFaster.equals("true")) {
1077 def windowsJavaVMDir
1078 def windowsJavaVMTgz
1079 def install4jDir = "$jalviewDir/$install4jResourceDir"
1080 def install4jConfFile = "jalview-installers-java"+JAVA_VERSION+".install4j"
1081 install4jConf = "$install4jDir/$install4jConfFile"
1083 task copyInstall4jTemplate(type: Copy) {
1084 macosJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/macos-jre"+JAVA_VERSION+"/jre"
1085 macosJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre"+JAVA_VERSION+".tar.gz"
1086 windowsJavaVMDir = System.env.HOME+"/buildtools/jre/openjdk-java_vm/getdown/windows-jre"+JAVA_VERSION+"/jre"
1087 windowsJavaVMTgz = System.env.HOME+"/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre"+JAVA_VERSION+".tar.gz"
1088 from (install4jDir) {
1089 include install4jTemplate
1090 rename (install4jTemplate, install4jConfFile)
1091 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1092 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1094 'JAVA_VERSION': JAVA_VERSION,
1095 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1096 'VERSION': JALVIEW_VERSION,
1097 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1098 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1099 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1100 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1101 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1102 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1103 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1104 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1105 'GETDOWN_DIST_DIR': getdown_app_dir,
1106 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1107 'GETDOWN_INSTALL_DIR': getdown_install_dir
1110 if (OSX_KEYPASS=="") {
1111 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1112 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1116 outputs.files(install4jConf)
1119 // include file associations in installer
1120 def installerFileAssociationsXml = file("$install4jDir/$install4jInstallerFileAssociations").text
1124 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1125 replace: installerFileAssociationsXml,
1129 // include uninstaller applescript app files in dmg
1130 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1134 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1135 replace: installerDMGUninstallerXml,
1142 task installers(type: com.install4j.gradle.Install4jTask) {
1143 group = "distribution"
1144 description = "Create the install4j installers"
1146 dependsOn copyInstall4jTemplate
1147 projectFile = file(install4jConf)
1148 println("Using projectFile "+projectFile)
1149 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1150 destination = "$jalviewDir/$install4jBuildDir/$JAVA_VERSION"
1151 buildSelected = true
1154 macKeystorePassword=OSX_KEYPASS
1158 inputs.dir(project.ext.getdownWebsiteDir)
1159 inputs.file(install4jConf)
1160 inputs.dir(macosJavaVMDir)
1161 inputs.dir(windowsJavaVMDir)
1162 outputs.dir("$jalviewDir/$install4jBuildDir/$JAVA_VERSION")
1167 delete install4jConf
1170 task sourceDist (type: Tar) {
1172 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1173 def outputFileName = project.name + "_" + VERSION_UNDERSCORES + ".tar.gz"
1174 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1176 archiveFileName = outputFileName
1177 } catch (Exception e) {
1178 archiveName = outputFileName
1181 compression Compression.GZIP
1185 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1190 ,"**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales"
1192 ,"utils/InstallAnywhere"]
1193 def PROCESS_FILES=[ "AUTHORS",
1201 "THIRDPARTYLIBS","TESTNG",
1203 "gradle.properties",
1214 exclude (EXCLUDE_FILES)
1215 include (PROCESS_FILES)
1216 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1219 exclude (EXCLUDE_FILES)
1220 exclude (PROCESS_FILES)
1221 exclude ("appletlib")
1222 exclude ("**/*locales")
1223 exclude ("*locales/**")
1224 exclude ("utils/InstallAnywhere")
1226 exclude (getdown_files_dir)
1227 exclude (getdown_website_dir)
1229 // exluding these as not using jars as modules yet
1230 exclude ("$j11modDir/**/*.jar")
1232 // from (jalviewDir) {
1233 // // explicit includes for stuff that seemed to not get included
1234 // include(fileTree("test/**/*."))
1235 // exclude(EXCLUDE_FILES)
1236 // exclude(PROCESS_FILES)
1242 dependsOn pubhtmlhelp
1244 inputs.dir("$classes/$helpDir")
1245 outputs.dir("$helpOutputDir")