1 import org.apache.tools.ant.filters.ReplaceTokens
2 import org.gradle.internal.os.OperatingSystem
3 import org.gradle.plugins.ide.eclipse.model.Output
4 import org.gradle.plugins.ide.eclipse.model.Library
6 import groovy.transform.ExternalizeMethods
10 classpath 'org.openclover:clover:4.3.1'
18 id 'com.github.johnrengelman.shadow' version '4.0.3'
19 id 'com.install4j.gradle' version '7.0.9'
22 // local build environment properties
23 def localProps = "${jalviewDir}/local.properties"
24 if (file(localProps).exists()) {
26 def p = new Properties()
27 def localPropsFIS = new FileInputStream(localProps)
32 def over = getProperty(key) != null
35 println("Overriding property '${key}' with local.properties value '${val}'")
38 } catch (Exception e) {
52 compile 'org.apache.commons:commons-compress:1.18'
55 mainClassName = launcherClass
56 def cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
57 def classes = "${jalviewDir}/${classesDir}"
59 if (clover.equals("true")) {
61 classes = "${buildDir}/${cloverClassesDir}"
64 classes = "${jalviewDir}/${classesDir}"
67 // configure classpath/args for j8/j11 compilation
69 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
72 def compile_source_compatibility
73 def compile_target_compatibility
76 getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
78 reportRsyncCmd = false
80 buildProperties = buildPropertiesFile
81 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}"
85 // TODO: get bamboo build artifact URL for getdown artifacts
86 getdown_channel_base = bamboo_channelbase
87 getdown_channel_name = "${bamboo_planKey}/${JAVA_VERSION}"
88 getdown_app_base = "${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}"
89 getdown_app_dir = getdown_app_dir_alt
90 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
94 getdown_channel_name = CHANNEL.toLowerCase()
95 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
96 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
97 getdown_app_dir = getdown_app_dir_release
98 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
99 reportRsyncCommand = true
103 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
104 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
105 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
106 getdown_app_dir = getdown_app_dir_alt
107 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
108 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
111 packageDir = "${ARCHIVEDIR}/${packageDir}"
112 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
115 reportRsyncCommand = true
119 getdown_channel_name = "archive/${JALVIEW_VERSION}"
120 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
121 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
122 getdown_app_dir = getdown_app_dir_alt
123 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
124 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
127 packageDir = "${ARCHIVEDIR}/${packageDir}"
128 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
131 reportRsyncCommand = true
132 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
136 getdown_channel_name = CHANNEL.toLowerCase()
137 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
138 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
139 getdown_app_dir = getdown_app_dir_alt
140 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
141 reportRsyncCommand = true
145 getdown_channel_name = CHANNEL.toLowerCase()
146 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
147 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
148 getdown_app_dir = getdown_app_dir_alt
149 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
150 reportRsyncCommand = true
153 case ~/^SCRATCH(|-[-\w]*)$/:
154 getdown_channel_name = CHANNEL
155 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
156 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
157 getdown_app_dir = getdown_app_dir_alt
158 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
159 reportRsyncCommand = true
163 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
164 getdown_app_dir = getdown_app_dir_alt
165 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
166 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
169 default: // something wrong specified
170 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
176 getdownAppDir = "${getdownWebsiteDir}/${getdown_app_dir}"
177 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
178 getdownResourceDir = "${getdownWebsiteDir}/${getdown_resource_dir}"
179 getdownInstallDir = "${getdownWebsiteDir}/${getdown_install_dir}"
180 getdownFilesDir = "${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/"
181 getdownFilesInstallDir = "${getdownFilesDir}/${getdown_install_dir}"
182 /* compile without modules -- using classpath libraries
183 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
184 modules_runtimeClasspath = modules_compileClasspath
189 println("Using a ${CHANNEL} profile.")
192 def JAVA_INTEGER_VERSION
193 def additional_compiler_args = []
194 // these are getdown.txt properties defined dependent on the JAVA_VERSION
195 def getdown_alt_java_min_version
196 def getdown_alt_java_max_version
197 // this property is assigned below and expanded to multiple lines in the getdown task
198 def getdown_alt_multi_java_location
199 // this property is for the Java library used in eclipse
200 def eclipse_java_runtime_name
201 if (JAVA_VERSION.equals("1.8")) {
202 JAVA_INTEGER_VERSION = "8"
205 libDistDir = j8libDir
206 compile_source_compatibility = 1.8
207 compile_target_compatibility = 1.8
208 getdown_alt_java_min_version = getdown_alt_java8_min_version
209 getdown_alt_java_max_version = getdown_alt_java8_max_version
210 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
211 eclipse_java_runtime_name = "JavaSE-1.8"
212 } else if (JAVA_VERSION.equals("11")) {
213 JAVA_INTEGER_VERSION = "11"
215 libDistDir = j11libDir
216 compile_source_compatibility = 11
217 compile_target_compatibility = 11
218 getdown_alt_java_min_version = getdown_alt_java11_min_version
219 getdown_alt_java_max_version = getdown_alt_java11_max_version
220 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
221 eclipse_java_runtime_name = "JavaSE-11"
222 /* compile without modules -- using classpath libraries
223 additional_compiler_args += [
224 '--module-path', ext.modules_compileClasspath.asPath,
225 '--add-modules', j11modules
228 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
229 JAVA_INTEGER_VERSION = JAVA_VERSION
231 libDistDir = j11libDir
232 compile_source_compatibility = JAVA_VERSION
233 compile_target_compatibility = JAVA_VERSION
234 getdown_alt_java_min_version = getdown_alt_java11_min_version
235 getdown_alt_java_max_version = getdown_alt_java11_max_version
236 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
237 eclipse_java_runtime_name = "JavaSE-11"
238 /* compile without modules -- using classpath libraries
239 additional_compiler_args += [
240 '--module-path', ext.modules_compileClasspath.asPath,
241 '--add-modules', j11modules
245 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
252 srcDirs "${jalviewDir}/${sourceDir}"
253 outputDir = file("${classes}")
257 srcDirs "${jalviewDir}/${resourceDir}"
260 jar.destinationDir = file("${jalviewDir}/${packageDir}")
262 compileClasspath = files(sourceSets.main.java.outputDir)
263 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
265 runtimeClasspath = compileClasspath
270 srcDirs = [ cloverInstrDir ]
271 outputDir = file("${buildDir}/${cloverClassesDir}")
275 srcDirs = sourceSets.main.resources.srcDirs
277 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
278 compileClasspath += files(sourceSets.main.java.outputDir)
279 compileClasspath += sourceSets.main.compileClasspath
280 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
281 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
283 runtimeClasspath = compileClasspath
288 srcDirs "${jalviewDir}/${testSourceDir}"
289 outputDir = file("${jalviewDir}/${testOutputDir}")
293 srcDirs = sourceSets.main.resources.srcDirs
296 compileClasspath = files( sourceSets.test.java.outputDir )
299 compileClasspath += sourceSets.clover.compileClasspath
301 compileClasspath += files(sourceSets.main.java.outputDir)
304 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
305 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
306 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
308 runtimeClasspath = compileClasspath
315 cloverCompile 'org.openclover:clover:4.3.1'
316 testCompile 'org.openclover:clover:4.3.1'
322 cloverRuntime.extendsFrom cloverCompile
327 name = eclipse_project_name
329 natures 'org.eclipse.jdt.core.javanature',
330 'org.eclipse.jdt.groovy.core.groovyNature',
331 'org.eclipse.buildship.core.gradleprojectnature'
333 buildCommand 'org.eclipse.jdt.core.javabuilder'
334 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
338 //defaultOutputDir = sourceSets.main.java.outputDir
341 if (it.isCanBeResolved()) {
346 minusConfigurations += removeThese
347 plusConfigurations = [ ]
351 def removeTheseToo = []
352 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
353 cp.entries.each { entry ->
354 if (entry.kind == 'src') {
355 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == testSourceDir)) {
356 removeTheseToo += entry
358 alreadyAddedSrcPath.putAt(entry.path, true)
362 cp.entries.removeAll(removeTheseToo)
364 if (file("${jalviewDir}/${eclipse_bin_dir}/main").isDirectory()) {
365 cp.entries += new Output("${eclipse_bin_dir}/main")
367 if (file(helpParentDir).isDirectory()) {
368 cp.entries += new Library(fileReference(helpParentDir))
370 if (file(resourceDir).isDirectory()) {
371 cp.entries += new Library(fileReference(resourceDir))
374 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
376 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
377 //don't want to add outputDir as eclipse is using its own output dir in bin/main
378 if (it.isDirectory() || ! it.exists()) {
379 // don't add dirs to classpath
382 def itPath = it.toString()
383 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
384 // make relative path
385 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
387 if (alreadyAddedLibPath.get(itPath)) {
388 //println("Not adding duplicate entry "+itPath)
390 //println("Adding entry "+itPath)
391 cp.entries += new Library(fileReference(itPath))
392 alreadyAddedLibPath.put(itPath, true)
396 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
397 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
398 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
399 if (it.isDirectory() || ! it.exists()) {
400 // don't add dirs to classpath
401 return false // groovy "break" in .each closure
403 def itPath = it.toString()
404 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
405 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
407 if (alreadyAddedLibPath.get(itPath)) {
410 def lib = new Library(fileReference(itPath))
411 lib.entryAttributes["test"] = "true"
413 alreadyAddedLibPath.put(itPath, true)
421 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
431 // add in jalview project specific properties/preferences into eclipse core preferences
433 withProperties { props ->
434 def jalview_prefs = new Properties()
435 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
436 jalview_prefs.load(ins)
438 jalview_prefs.forEach { t, v ->
439 if (props.getAt(t) == null) {
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
533 delete sourceSets.main.java.outputDir
539 delete sourceSets.test.java.outputDir
540 delete cloverInstrDir
544 // format is a string like date.format("dd MMMM yyyy")
545 def getDate(format) {
546 def date = new Date()
547 return date.format(format)
551 def hashStdOut = new ByteArrayOutputStream()
553 commandLine "git", "rev-parse", "--short", "HEAD"
554 standardOutput = hashStdOut
558 def branchStdOut = new ByteArrayOutputStream()
560 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
561 standardOutput = branchStdOut
565 project.ext.gitHash = hashStdOut.toString().trim()
566 project.ext.gitBranch = branchStdOut.toString().trim()
568 outputs.upToDateWhen { false }
571 task createBuildProperties(type: WriteProperties) {
573 inputs.dir("${jalviewDir}/${sourceDir}")
574 inputs.dir("${classes}")
575 inputs.dir("${jalviewDir}/${resourceDir}")
576 outputFile (buildProperties)
577 // taking time specific comment out to allow better incremental builds
578 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
579 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
580 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
581 property "VERSION", JALVIEW_VERSION
582 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
583 outputs.file(outputFile)
586 def buildingHTML = "${jalviewDir}/${docDir}/building.html"
587 task cleanBuildingHTML(type: Delete) {
593 task convertBuildingMD(type: Exec) {
594 dependsOn cleanBuildingHTML
595 def buildingMD = "${jalviewDir}/${docDir}/building.md"
596 def css = "${jalviewDir}/${docDir}/github.css"
599 pandoc_exec.split(",").each {
600 if (file(it.trim()).exists()) {
606 def hostname = "hostname".execute().text.trim()
607 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
608 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
612 if (pandoc != null && file(pandoc).exists()) {
613 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
615 println("Cannot find pandoc. Skipping convert building.md to HTML")
616 throw new StopExecutionException()
622 inputs.file(buildingMD)
624 outputs.file(buildingHTML)
633 task syncDocs(type: Sync) {
634 dependsOn convertBuildingMD
635 def syncDir = "${classes}/${docDir}"
636 from fileTree("${jalviewDir}/${docDir}")
641 def helpFile = "${classes}/${helpDir}/help.jhm"
643 task copyHelp(type: Copy) {
644 def inputDir = "${jalviewDir}/${helpParentDir}/${helpDir}"
645 def outputDir = "${classes}/${helpDir}"
650 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
660 outputs.files(helpFile)
661 outputs.dir(outputDir)
664 task syncLib(type: Sync) {
665 def syncDir = "${classes}/${libDistDir}"
666 from fileTree("${jalviewDir}/${libDistDir}")
670 task syncResources(type: Sync) {
671 from "${jalviewDir}/${resourceDir}"
680 dependsOn syncResources
686 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
689 dependsOn compileJava
691 dependsOn cloverInstr
695 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
699 includeGroups testngGroups
701 useDefaultListeners=true
704 workingDir = jalviewDir
705 //systemProperties 'clover.jar' System.properties.clover.jar
706 sourceCompatibility = compile_source_compatibility
707 targetCompatibility = compile_target_compatibility
708 jvmArgs += additional_compiler_args
712 task buildIndices(type: JavaExec) {
714 classpath = sourceSets.main.compileClasspath
715 main = "com.sun.java.help.search.Indexer"
716 workingDir = "${classes}/${helpDir}"
719 inputs.dir("${workingDir}/${argDir}")
721 outputs.dir("${classes}/doc")
722 outputs.dir("${classes}/help")
723 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
724 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
725 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
726 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
727 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
728 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
731 task compileLinkCheck(type: JavaCompile) {
733 classpath = files("${jalviewDir}/${utilsDir}")
734 destinationDir = file("${jalviewDir}/${utilsDir}")
735 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
737 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
738 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
739 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
740 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
743 task linkCheck(type: JavaExec) {
744 dependsOn prepare, compileLinkCheck
746 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
747 classpath = files("${jalviewDir}/${utilsDir}")
748 main = "HelpLinksChecker"
749 workingDir = jalviewDir
750 def help = "${classes}/${helpDir}"
751 args = [ "${classes}/${helpDir}", "-nointernet" ]
753 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
755 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
758 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
762 inputs.dir("${classes}/${helpDir}")
763 outputs.file(helpLinksCheckerOutFile)
766 // import the pubhtmlhelp target
767 ant.properties.basedir = "${jalviewDir}"
768 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
769 ant.importBuild "${utilsDir}/publishHelp.xml"
772 task cleanPackageDir(type: Delete) {
774 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
780 dependsOn buildIndices
781 dependsOn createBuildProperties
784 attributes "Main-Class": mainClass,
785 "Permissions": "all-permissions",
786 "Application-Name": "Jalview Desktop",
787 "Codebase": application_codebase
790 destinationDir = file("${jalviewDir}/${packageDir}")
791 archiveName = rootProject.name+".jar"
799 inputs.dir("${classes}")
800 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
803 task copyJars(type: Copy) {
804 from fileTree(dir: "${classes}", include: "**/*.jar").files
805 into "${jalviewDir}/${packageDir}"
808 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
809 task syncJars(type: Sync) {
810 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
811 into "${jalviewDir}/${packageDir}"
813 include jar.archiveName
819 description = "Put all required libraries in dist"
820 // order of "cleanPackageDir", "copyJars", "jar" important!
821 jar.mustRunAfter cleanPackageDir
822 syncJars.mustRunAfter cleanPackageDir
823 dependsOn cleanPackageDir
826 outputs.dir("${jalviewDir}/${packageDir}")
830 dependsOn cleanPackageDir
836 group = "distribution"
840 from ("${jalviewDir}/${libDistDir}") {
844 attributes 'Implementation-Version': JALVIEW_VERSION
846 mainClassName = shadowJarMainClass
848 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
852 task getdownWebsite() {
853 group = "distribution"
854 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
859 def getdownWebsiteResourceFilenames = []
860 def getdownTextString = ""
861 def getdownResourceDir = project.ext.getdownResourceDir
862 def getdownAppDir = project.ext.getdownAppDir
863 def getdownResourceFilenames = []
866 // clean the getdown website and files dir before creating getdown folders
867 delete project.ext.getdownWebsiteDir
868 delete project.ext.getdownFilesDir
872 rename(buildPropertiesFile, getdown_build_properties)
873 into project.ext.getdownAppDir
875 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
877 // go through properties looking for getdown_txt_...
878 def props = project.properties.sort { it.key }
879 if (getdown_alt_java_min_version.length() > 0) {
880 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
882 if (getdown_alt_java_max_version.length() > 0) {
883 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
885 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
887 props.put("getdown_txt_appbase", getdown_app_base)
888 props.each{ prop, val ->
889 if (prop.startsWith("getdown_txt_") && val != null) {
890 if (prop.startsWith("getdown_txt_multi_")) {
891 def key = prop.substring(18)
892 val.split(",").each{ v ->
893 def line = "${key} = ${v}\n"
894 getdownTextString += line
897 // file values rationalised
898 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
900 if (val.indexOf('/') == 0) {
903 } else if (val.indexOf('/') > 0) {
904 // relative path (relative to jalviewDir)
905 r = file( "${jalviewDir}/${val}" )
908 val = "${getdown_resource_dir}/" + r.getName()
909 getdownWebsiteResourceFilenames += val
910 getdownResourceFilenames += r.getPath()
913 if (! prop.startsWith("getdown_txt_resource")) {
914 def line = prop.substring(12) + " = ${val}\n"
915 getdownTextString += line
921 getdownWebsiteResourceFilenames.each{ filename ->
922 getdownTextString += "resource = ${filename}\n"
924 getdownResourceFilenames.each{ filename ->
927 into project.ext.getdownResourceDir
932 fileTree(file(packageDir)).each{ f ->
933 if (f.isDirectory()) {
934 def files = fileTree(dir: f, include: ["*"]).getFiles()
936 } else if (f.exists()) {
940 codeFiles.sort().each{f ->
941 def name = f.getName()
942 def line = "code = ${getdown_app_dir}/${name}\n"
943 getdownTextString += line
946 into project.ext.getdownAppDir
950 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
952 if (JAVA_VERSION.equals("11")) {
953 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
954 j11libFiles.sort().each{f ->
955 def name = f.getName()
956 def line = "code = ${getdown_j11lib_dir}/${name}\n"
957 getdownTextString += line
960 into project.ext.getdownJ11libDir
966 // 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.
967 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
968 getdownTextString += "resource = ${getdown_launcher_new}\n"
969 getdownTextString += "class = ${mainClass}\n"
971 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
972 getdown_txt.write(getdownTextString)
974 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
975 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
979 rename(file(getdownLauncher).getName(), getdown_launcher_new)
980 into project.ext.getdownWebsiteDir
985 if (file(getdownLauncher).getName() != getdown_launcher) {
986 rename(file(getdownLauncher).getName(), getdown_launcher)
988 into project.ext.getdownWebsiteDir
991 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
995 from "${getdownWebsiteDir}/${getdown_build_properties}"
996 if (file(getdownLauncher).getName() != getdown_launcher) {
997 rename(file(getdownLauncher).getName(), getdown_launcher)
999 into getdownInstallDir
1003 from getdownInstallDir
1004 into getdownFilesInstallDir
1011 from getdownLauncher
1012 from "${getdownWebsiteDir}/${getdown_build_properties}"
1013 if (file(getdownLauncher).getName() != getdown_launcher) {
1014 rename(file(getdownLauncher).getName(), getdown_launcher)
1016 into getdownFilesDir
1020 from getdownResourceDir
1021 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1026 inputs.dir("${jalviewDir}/${packageDir}")
1028 outputs.dir(project.ext.getdownWebsiteDir)
1029 outputs.dir(project.ext.getdownFilesDir)
1032 task getdownDigest(type: JavaExec) {
1033 group = "distribution"
1034 description = "Digest the getdown website folder"
1035 dependsOn getdownWebsite
1037 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1039 main = "com.threerings.getdown.tools.Digester"
1040 args project.ext.getdownWebsiteDir
1041 inputs.dir(project.ext.getdownWebsiteDir)
1042 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1046 group = "distribution"
1047 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1048 dependsOn getdownDigest
1050 if (reportRsyncCommand) {
1051 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1052 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1053 println "LIKELY RSYNC COMMAND:"
1054 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1055 if (RUNRSYNC == "true") {
1057 commandLine "mkdir", "-p", toDir
1060 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1069 delete project.ext.getdownWebsiteDir
1070 delete project.ext.getdownFilesDir
1075 def install4jHomeDir = "/opt/install4j"
1076 def hostname = "hostname".execute().text.trim()
1077 if (hostname.equals("jv-bamboo")) {
1078 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1079 } else if (OperatingSystem.current().isMacOsX()) {
1080 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1081 if (! file(install4jHomeDir).exists()) {
1082 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1084 } else if (OperatingSystem.current().isLinux()) {
1085 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1087 installDir = file(install4jHomeDir)
1088 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1089 if (install4jFaster.equals("true")) {
1097 def windowsJavaVMDir
1098 def windowsJavaVMTgz
1099 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1100 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1101 install4jConf = "${install4jDir}/${install4jConfFile}"
1103 task copyInstall4jTemplate(type: Copy) {
1104 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1105 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1106 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1107 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1108 from (install4jDir) {
1109 include install4jTemplate
1110 rename (install4jTemplate, install4jConfFile)
1111 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1112 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1114 'JAVA_VERSION': JAVA_VERSION,
1115 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1116 'VERSION': JALVIEW_VERSION,
1117 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1118 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1119 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1120 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1121 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1122 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1123 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1124 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1125 'GETDOWN_DIST_DIR': getdown_app_dir,
1126 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1127 'GETDOWN_INSTALL_DIR': getdown_install_dir
1130 if (OSX_KEYPASS=="") {
1131 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1132 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1136 outputs.files(install4jConf)
1139 // include file associations in installer
1140 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1144 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1145 replace: installerFileAssociationsXml,
1149 // include uninstaller applescript app files in dmg
1150 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1154 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1155 replace: installerDMGUninstallerXml,
1162 task installers(type: com.install4j.gradle.Install4jTask) {
1163 group = "distribution"
1164 description = "Create the install4j installers"
1166 dependsOn copyInstall4jTemplate
1167 projectFile = file(install4jConf)
1168 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1169 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1170 buildSelected = true
1173 macKeystorePassword=OSX_KEYPASS
1177 println("Using projectFile "+projectFile)
1180 inputs.dir(project.ext.getdownWebsiteDir)
1181 inputs.file(install4jConf)
1182 inputs.dir(macosJavaVMDir)
1183 inputs.dir(windowsJavaVMDir)
1184 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1189 delete install4jConf
1193 task sourceDist (type: Tar) {
1195 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1196 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1197 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1199 archiveFileName = outputFileName
1200 } catch (Exception e) {
1201 archiveName = outputFileName
1204 compression Compression.GZIP
1208 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1213 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1215 ,"utils/InstallAnywhere"]
1216 def PROCESS_FILES=[ "AUTHORS",
1224 "THIRDPARTYLIBS","TESTNG",
1226 "gradle.properties",
1237 exclude (EXCLUDE_FILES)
1238 include (PROCESS_FILES)
1239 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1242 exclude (EXCLUDE_FILES)
1243 exclude (PROCESS_FILES)
1244 exclude ("appletlib")
1245 exclude ("**/*locales")
1246 exclude ("*locales/**")
1247 exclude ("utils/InstallAnywhere")
1249 exclude (getdown_files_dir)
1250 exclude (getdown_website_dir)
1252 // exluding these as not using jars as modules yet
1253 exclude ("${j11modDir}/**/*.jar")
1255 // from (jalviewDir) {
1256 // // explicit includes for stuff that seemed to not get included
1257 // include(fileTree("test/**/*."))
1258 // exclude(EXCLUDE_FILES)
1259 // exclude(PROCESS_FILES)
1265 dependsOn pubhtmlhelp
1267 inputs.dir("${classes}/${helpDir}")
1268 outputs.dir("${helpOutputDir}")
1271 def jalviewjsBuildDir
1272 def jalviewjsSiteDir
1273 def jalviewjsTransferSiteDir
1274 task jalviewjsSitePath {
1275 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1276 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1277 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1278 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1281 def eclipseWorkspace
1282 task jalviewjsSetEclipseWorkspace {
1283 def propKey = "jalviewjs_eclipse_workspace"
1285 if (project.hasProperty(propKey)) {
1286 propVal = project.getProperty(propKey)
1287 if (propVal.startsWith("~/")) {
1288 propVal = System.getProperty("user.home") + propVal.substring(1)
1291 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1292 def propsFile = file(propsFileName)
1293 def eclipseWsDir = propVal
1294 def props = new Properties()
1296 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1297 def ins = new FileInputStream(propsFileName)
1300 if (props.getProperty(propKey, null) != null) {
1301 eclipseWsDir = props.getProperty(propKey)
1305 def writeProps = false
1306 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1307 def tempDir = File.createTempDir()
1308 eclipseWsDir = tempDir.getAbsolutePath()
1311 eclipseWorkspace = file(eclipseWsDir)
1315 props.setProperty(propKey, eclipseWsDir)
1316 propsFile.parentFile.mkdirs()
1317 def bytes = new ByteArrayOutputStream()
1318 props.store(bytes, null)
1319 def propertiesString = bytes.toString()
1320 propsFile.text = propertiesString
1323 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1326 inputs.property(propKey, eclipseWsDir)
1327 outputs.file(propsFileName)
1333 def eclipseDebug = false
1334 def eclipseVersionSuffix = ""
1335 task jalviewjsEclipsePaths {
1338 def eclipseRoot = jalviewjs_eclipse_root
1339 if (eclipseRoot.startsWith("~/")) {
1340 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1342 if (OperatingSystem.current().isMacOsX()) {
1343 eclipseRoot += "/Eclipse.app"
1344 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1345 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1346 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1347 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1348 eclipseRoot += "/eclipse"
1350 eclipseBinary = "${eclipseRoot}/eclipse"
1351 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1352 } else { // linux or unix
1353 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1354 eclipseRoot += "/eclipse"
1356 eclipseBinary = "${eclipseRoot}/eclipse"
1357 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1360 eclipseVersion = "4.12" // default
1361 def assumedVersion = true
1362 if (file(eclipseProduct).exists()) {
1363 def fis = new FileInputStream(eclipseProduct)
1364 def props = new Properties()
1366 eclipseVersion = props.getProperty("version")
1368 assumedVersion = false
1371 String[] v = eclipseVersion.split("\\.")
1372 def v0 = Integer.valueOf(v[0])
1373 def v1 = Integer.valueOf(v[1])
1374 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1375 eclipseVersionSuffix = "_4.12"
1377 eclipseVersionSuffix = "_4.13"
1382 def propKey = "eclipse_debug"
1383 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1386 if (!assumedVersion) {
1387 println("ECLIPSE VERSION=${eclipseVersion}")
1393 dependsOn eclipseProject
1394 dependsOn eclipseClasspath
1395 dependsOn eclipseJdt
1398 /* using the Copy task below
1399 task OLDjalviewjsEclipseCopyDropins {
1400 dependsOn jalviewjsEclipsePaths
1401 dependsOn jalviewjsCleanEclipse
1402 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1403 inputFiles += file(jalviewjs_j2s_plugin)
1404 def outputDir = "${buildDir}/jalviewjs
1406 inputs.files inputFiles
1407 inputFiles.each { file ->
1408 outputs.file("${outputDir}/${file.name}")
1412 inputFiles.each { file ->
1422 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1423 task jalviewjsEclipseCopyDropins(type: Copy) {
1424 dependsOn jalviewjsEclipsePaths
1426 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1427 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1428 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1434 // this eclipse -clean doesn't actually work
1435 task jalviewjsCleanEclipse(type: Exec) {
1436 dependsOn eclipseSetup
1437 dependsOn jalviewjsEclipsePaths
1438 dependsOn jalviewjsEclipseCopyDropins
1440 executable(eclipseBinary)
1441 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1447 def inputString = """exit
1450 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1451 standardInput = inputByteStream
1453 /* not really working yet
1454 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1457 task jalviewjsUnzipFiles {
1458 dependsOn jalviewjsSitePath
1460 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1461 zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
1464 zipFiles.each { file_zip ->
1466 from zipTree(file_zip)
1467 into "${jalviewDir}/${jalviewjsSiteDir}"
1472 inputs.files zipFiles
1473 outputs.dir "${jalviewDir}/${jalviewjsSiteDir}"
1476 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1478 description "Create the .j2s file from the j2s.* properties"
1480 dependsOn jalviewjsSitePath
1482 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1483 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1484 def siteDirProperty = "j2s.site.directory"
1485 def setSiteDir = false
1486 j2s_props.each { prop, val ->
1488 if (prop == siteDirProperty) {
1489 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1490 val = "${jalviewDir}/${jalviewjsTransferSiteDir}/${val}"
1496 if (!setSiteDir) { // default site location, don't override specifically set property
1497 property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteDir}")
1500 inputs.properties(j2s_props)
1501 outputs.file(outputFile)
1504 task jalviewjsEclipseSetup {
1505 dependsOn jalviewjsEclipseCopyDropins
1506 dependsOn jalviewjsSetEclipseWorkspace
1507 dependsOn jalviewjsCreateJ2sSettings
1510 task jalviewjsCopyResources (type: Sync) {
1511 dependsOn jalviewjsSitePath
1512 def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
1513 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1517 def outputFiles = []
1518 rename { filename ->
1519 outputFiles += "${outputDir}/${filename}"
1525 outputs.files outputFiles
1526 inputs.files inputFiles
1529 task jalviewjsCopySiteResources (type: Sync) {
1530 dependsOn jalviewjsSitePath
1531 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1532 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1536 def outputFiles = []
1537 rename { filename ->
1538 outputFiles += "${outputDir}/${filename}"
1544 outputs.files outputFiles
1545 inputs.files inputFiles
1548 task jalviewjsProjectImport(type: Exec) {
1549 dependsOn eclipseSetup
1550 dependsOn jalviewjsEclipsePaths
1551 dependsOn jalviewjsEclipseSetup
1553 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1554 executable(eclipseBinary)
1555 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1559 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1561 inputs.file("${jalviewDir}/.project")
1562 outputs.upToDateWhen { file(projdir).exists() }
1565 task jalviewjsTranspile(type: Exec) {
1566 dependsOn jalviewjsEclipseSetup
1567 dependsOn jalviewjsProjectImport
1568 dependsOn jalviewjsEclipsePaths
1570 executable(eclipseBinary)
1571 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1575 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1580 stdout = new ByteArrayOutputStream()
1581 stderr = new ByteArrayOutputStream()
1583 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1584 def logOutFile = file(logOutFileName)
1585 logOutFile.createNewFile()
1586 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1587 BINARY: ${eclipseBinary}
1588 VERSION: ${eclipseVersion}
1589 WORKSPACE: ${eclipseWorkspace}
1590 DEBUG: ${eclipseDebug}
1593 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1594 //def logErrFileName = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1595 //def logErrFile = file(logFileName)
1596 //logErrFile.createNewFile()
1597 //def logErrFOS = new FileErrputStream(logErrFile, false)
1598 // combine stdout and stderr
1599 def logErrFOS = logOutFOS
1601 if (jalviewjs_j2s_to_console.equals("true")) {
1602 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1603 new org.apache.tools.ant.util.TeeOutputStream(
1607 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1608 new org.apache.tools.ant.util.TeeOutputStream(
1613 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1616 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1623 if (stdout.toString().contains("Error processing ")) {
1624 // j2s did not complete transpile
1625 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1629 inputs.dir("${jalviewDir}/${sourceDir}")
1630 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteDir}")
1631 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() } )
1634 task jalviewjsCopyTransferSite(type: Copy) {
1635 dependsOn jalviewjsTranspile
1636 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1637 into "${jalviewDir}/${jalviewjsSiteDir}"
1640 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1641 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1642 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1644 task jalviewjsPrepareSite {
1646 description "Prepares the website folder including unzipping files and copying resources"
1647 dependsOn jalviewjsSitePath
1648 dependsOn jalviewjsUnzipFiles
1649 dependsOn jalviewjsCopyResources
1650 dependsOn jalviewjsCopySiteResources
1653 task jalviewjsBuildSite {
1655 description "Builds the whole website including transpiled code"
1656 dependsOn jalviewjsCopyTransferSite
1657 dependsOn jalviewjsPrepareSite
1660 task cleanJalviewjsSite {
1662 delete "${jalviewDir}/${jalviewjsTransferSiteDir}"
1663 delete "${jalviewDir}/${jalviewjsSiteDir}"
1667 task jalviewjsSiteTar(type: Tar) {
1669 description "Creates a tar.gz file for the website"
1670 dependsOn jalviewjsBuildSite
1671 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1673 archiveFileName = outputFilename
1674 } catch (Exception e) {
1675 archiveName = outputFilename
1678 compression Compression.GZIP
1680 from "${jalviewDir}/${jalviewjsSiteDir}"
1681 into jalviewjs_site_dir // this is inside the tar file
1683 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
1686 task jalviewjsServer {
1688 description "Starts a webserver on localhost to test the website"
1689 dependsOn jalviewjsSitePath
1690 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1693 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1694 def port = Integer.valueOf(jalviewjs_server_port)
1698 while(port < start+1000 && !running) {
1700 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1701 def jalviewjsServer = factory.start(doc_root, port)
1703 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1704 println("SERVER STARTED with document root ${doc_root}.")
1705 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1706 println("For debug: "+url+"?j2sdebug")
1708 file(htmlFile).text = """
1709 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1710 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1713 } catch (Exception e) {
1720 outputs.file(htmlFile)
1721 outputs.upToDateWhen({false})
1724 task cleanJalviewjsAll {
1726 description "Delete all configuration and build artifacts to do with JalviewJS build"
1727 dependsOn cleanJalviewjsSite
1728 dependsOn jalviewjsEclipsePaths
1731 delete "${jalviewDir}/${jalviewjsBuildDir}"
1732 delete "${jalviewDir}/${eclipse_bin_dir}"
1733 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1734 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1736 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1739 outputs.upToDateWhen( { false } )
1744 description "Build the site"
1745 dependsOn jalviewjsBuildSite
1749 task jalviewjsIDECopyTransferSite(type: Copy) {
1750 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1751 into "${jalviewDir}/${jalviewjsSiteDir}"
1754 task jalviewjsIDEj2s {
1755 group "JalviewJS in Eclipse"
1756 description "Creates the .j2s file"
1757 dependsOn jalviewjsCreateJ2sSettings
1760 task jalviewjsIDEBuildSite {
1761 group "JalviewJS in Eclipse"
1762 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1763 dependsOn jalviewjsIDECopyTransferSite
1764 dependsOn jalviewjsPrepareSite
1767 task jalviewjsIDESiteClean {
1768 group "JalviewJS in Eclipse"
1769 description "Deletes the Eclipse transpiled site"
1770 dependsOn cleanJalviewjsSite
1773 task jalviewjsIDEServer {
1774 group "JalviewJS in Eclipse"
1775 description "Starts a webserver on localhost to test the website"
1776 dependsOn jalviewjsServer