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()) {
25 def p = new Properties()
26 def localPropsFIS = new FileInputStream(localProps)
31 def over = getProperty(key) != null
34 println("Overriding property '${key}' with local.properties value '${val}'")
49 compile 'org.apache.commons:commons-compress:1.18'
52 mainClassName = launcherClass
53 def cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
54 def classes = "${jalviewDir}/${classesDir}"
56 if (clover.equals("true")) {
58 classes = "${buildDir}/${cloverClassesDir}"
61 classes = "${jalviewDir}/${classesDir}"
64 // configure classpath/args for j8/j11 compilation
66 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
69 def compile_source_compatibility
70 def compile_target_compatibility
73 getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
75 reportRsyncCmd = false
77 buildProperties = buildPropertiesFile
78 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}"
82 // TODO: get bamboo build artifact URL for getdown artifacts
83 getdown_channel_base = bamboo_channelbase
84 getdown_channel_name = "${bamboo_planKey}/${JAVA_VERSION}"
85 getdown_app_base = "${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}"
86 getdown_app_dir = getdown_app_dir_alt
87 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
91 getdown_channel_name = CHANNEL.toLowerCase()
92 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
93 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
94 getdown_app_dir = getdown_app_dir_release
95 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
96 reportRsyncCommand = true
100 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
101 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
102 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
103 getdown_app_dir = getdown_app_dir_alt
104 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
105 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
108 packageDir = "${ARCHIVEDIR}/${packageDir}"
109 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
112 reportRsyncCommand = true
116 getdown_channel_name = "archive/${JALVIEW_VERSION}"
117 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
118 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
119 getdown_app_dir = getdown_app_dir_alt
120 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
121 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
124 packageDir = "${ARCHIVEDIR}/${packageDir}"
125 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
128 reportRsyncCommand = true
129 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
133 getdown_channel_name = CHANNEL.toLowerCase()
134 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
135 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
136 getdown_app_dir = getdown_app_dir_alt
137 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
138 reportRsyncCommand = true
142 getdown_channel_name = CHANNEL.toLowerCase()
143 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
144 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
145 getdown_app_dir = getdown_app_dir_alt
146 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
147 reportRsyncCommand = true
150 case ~/^SCRATCH(|-[-\w]*)$/:
151 getdown_channel_name = CHANNEL
152 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
153 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
154 getdown_app_dir = getdown_app_dir_alt
155 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
156 reportRsyncCommand = true
160 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
161 getdown_app_dir = getdown_app_dir_alt
162 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
163 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
166 default: // something wrong specified
167 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
173 getdownAppDir = "${getdownWebsiteDir}/${getdown_app_dir}"
174 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
175 getdownResourceDir = "${getdownWebsiteDir}/${getdown_resource_dir}"
176 getdownInstallDir = "${getdownWebsiteDir}/${getdown_install_dir}"
177 getdownFilesDir = "${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/"
178 getdownFilesInstallDir = "${getdownFilesDir}/${getdown_install_dir}"
179 /* compile without modules -- using classpath libraries
180 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
181 modules_runtimeClasspath = modules_compileClasspath
186 println("Using a ${CHANNEL} profile.")
189 def JAVA_INTEGER_VERSION
190 def additional_compiler_args = []
191 // these are getdown.txt properties defined dependent on the JAVA_VERSION
192 def getdown_alt_java_min_version
193 def getdown_alt_java_max_version
194 // this property is assigned below and expanded to multiple lines in the getdown task
195 def getdown_alt_multi_java_location
196 // this property is for the Java library used in eclipse
197 def eclipse_java_runtime_name
198 if (JAVA_VERSION.equals("1.8")) {
199 JAVA_INTEGER_VERSION = "8"
202 libDistDir = j8libDir
203 compile_source_compatibility = 1.8
204 compile_target_compatibility = 1.8
205 getdown_alt_java_min_version = getdown_alt_java8_min_version
206 getdown_alt_java_max_version = getdown_alt_java8_max_version
207 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
208 eclipse_java_runtime_name = "JavaSE-1.8"
209 } else if (JAVA_VERSION.equals("11")) {
210 JAVA_INTEGER_VERSION = "11"
212 libDistDir = j11libDir
213 compile_source_compatibility = 11
214 compile_target_compatibility = 11
215 getdown_alt_java_min_version = getdown_alt_java11_min_version
216 getdown_alt_java_max_version = getdown_alt_java11_max_version
217 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
218 eclipse_java_runtime_name = "JavaSE-11"
219 /* compile without modules -- using classpath libraries
220 additional_compiler_args += [
221 '--module-path', ext.modules_compileClasspath.asPath,
222 '--add-modules', j11modules
225 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
226 JAVA_INTEGER_VERSION = JAVA_VERSION
228 libDistDir = j11libDir
229 compile_source_compatibility = JAVA_VERSION
230 compile_target_compatibility = JAVA_VERSION
231 getdown_alt_java_min_version = getdown_alt_java11_min_version
232 getdown_alt_java_max_version = getdown_alt_java11_max_version
233 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
234 eclipse_java_runtime_name = "JavaSE-11"
235 /* compile without modules -- using classpath libraries
236 additional_compiler_args += [
237 '--module-path', ext.modules_compileClasspath.asPath,
238 '--add-modules', j11modules
242 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
249 srcDirs "${jalviewDir}/${sourceDir}"
250 outputDir = file("${classes}")
254 srcDirs "${jalviewDir}/${resourceDir}"
257 jar.destinationDir = file("${jalviewDir}/${packageDir}")
259 compileClasspath = files(sourceSets.main.java.outputDir)
260 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
262 runtimeClasspath = compileClasspath
267 srcDirs = [ cloverInstrDir ]
268 outputDir = file("${buildDir}/${cloverClassesDir}")
272 srcDirs = sourceSets.main.resources.srcDirs
274 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
275 compileClasspath += files(sourceSets.main.java.outputDir)
276 compileClasspath += sourceSets.main.compileClasspath
277 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
278 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
280 runtimeClasspath = compileClasspath
285 srcDirs "${jalviewDir}/${testSourceDir}"
286 outputDir = file("${jalviewDir}/${testOutputDir}")
290 srcDirs = sourceSets.main.resources.srcDirs
293 compileClasspath = files( sourceSets.test.java.outputDir )
296 compileClasspath += sourceSets.clover.compileClasspath
298 compileClasspath += files(sourceSets.main.java.outputDir)
301 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
302 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
303 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
305 runtimeClasspath = compileClasspath
312 cloverCompile 'org.openclover:clover:4.3.1'
313 testCompile 'org.openclover:clover:4.3.1'
319 cloverRuntime.extendsFrom cloverCompile
324 name = eclipse_project_name
326 natures 'org.eclipse.jdt.core.javanature',
327 'org.eclipse.jdt.groovy.core.groovyNature',
328 'org.eclipse.buildship.core.gradleprojectnature'
330 buildCommand 'org.eclipse.jdt.core.javabuilder'
331 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
335 //defaultOutputDir = sourceSets.main.java.outputDir
338 if (it.isCanBeResolved()) {
343 minusConfigurations += removeThese
344 plusConfigurations = [ ]
348 def removeTheseToo = []
349 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
350 cp.entries.each { entry ->
351 if (entry.kind == 'src') {
352 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == testSourceDir)) {
353 removeTheseToo += entry
355 alreadyAddedSrcPath.putAt(entry.path, true)
359 cp.entries.removeAll(removeTheseToo)
361 if (file("${jalviewDir}/${eclipse_bin_dir}/main").isDirectory()) {
362 cp.entries += new Output("${eclipse_bin_dir}/main")
364 if (file(helpParentDir).isDirectory()) {
365 cp.entries += new Library(fileReference(helpParentDir))
367 if (file(resourceDir).isDirectory()) {
368 cp.entries += new Library(fileReference(resourceDir))
371 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
373 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
374 //don't want to add outputDir as eclipse is using its own output dir in bin/main
375 if (it.isDirectory() || ! it.exists()) {
376 // don't add dirs to classpath
379 def itPath = it.toString()
380 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
381 // make relative path
382 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
384 if (alreadyAddedLibPath.get(itPath)) {
385 //println("Not adding duplicate entry "+itPath)
387 //println("Adding entry "+itPath)
388 cp.entries += new Library(fileReference(itPath))
389 alreadyAddedLibPath.put(itPath, true)
393 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
394 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
395 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
396 if (it.isDirectory() || ! it.exists()) {
397 // don't add dirs to classpath
398 return false // groovy "break" in .each closure
400 def itPath = it.toString()
401 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
402 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
404 if (alreadyAddedLibPath.get(itPath)) {
407 def lib = new Library(fileReference(itPath))
408 lib.entryAttributes["test"] = "true"
410 alreadyAddedLibPath.put(itPath, true)
418 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
423 // for the IDE, use java 11 compatibility
424 sourceCompatibility = compile_source_compatibility
425 targetCompatibility = compile_target_compatibility
426 javaRuntimeName = eclipse_java_runtime_name
428 // add in jalview project specific properties/preferences into eclipse core preferences
430 withProperties { props ->
431 def jalview_prefs = new Properties()
432 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
433 jalview_prefs.load(ins)
435 jalview_prefs.forEach { t, v ->
436 if (props.getAt(t) == null) {
448 // only instrument source, we build test classes as normal
449 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
450 outputs.dir cloverInstrDir
453 delete cloverInstrDir
454 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
455 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
456 argsList.addAll(inputs.files.files.collect({ file ->
459 String[] args = argsList.toArray()
460 println("About to instrument "+args.length +" files")
461 com.atlassian.clover.CloverInstr.mainImpl(args)
467 group = "Verification"
468 description = "Createst the Clover report"
469 inputs.dir "${buildDir}/clover"
470 outputs.dir "${reportsDir}/clover"
472 file("${buildDir}/clover/clover.db").exists()
475 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
476 "-o", "${reportsDir}/clover"]
477 String[] args = argsList.toArray()
478 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
480 // and generate ${reportsDir}/clover/clover.xml
481 args = ["--initstring", "${buildDir}/clover/clover.db",
482 "-o", "${reportsDir}/clover/clover.xml"].toArray()
483 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
493 sourceCompatibility = compile_source_compatibility
494 targetCompatibility = compile_target_compatibility
495 options.compilerArgs = additional_compiler_args
496 print ("Setting target compatibility to "+targetCompatibility+"\n")
503 dependsOn compileCloverJava
504 classpath += configurations.cloverRuntime
506 classpath += sourceSets.main.runtimeClasspath
509 sourceCompatibility = compile_source_compatibility
510 targetCompatibility = compile_target_compatibility
511 options.compilerArgs = additional_compiler_args
512 print ("Setting target compatibility to "+targetCompatibility+"\n")
520 sourceCompatibility = compile_source_compatibility
521 targetCompatibility = compile_target_compatibility
522 options.compilerArgs += additional_compiler_args
523 print ("Setting target compatibility to "+targetCompatibility+"\n")
525 classpath += configurations.cloverRuntime
530 delete sourceSets.main.java.outputDir
536 delete sourceSets.test.java.outputDir
537 delete cloverInstrDir
541 // format is a string like date.format("dd MMMM yyyy")
542 def getDate(format) {
543 def date = new Date()
544 return date.format(format)
548 def hashStdOut = new ByteArrayOutputStream()
550 commandLine "git", "rev-parse", "--short", "HEAD"
551 standardOutput = hashStdOut
555 def branchStdOut = new ByteArrayOutputStream()
557 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
558 standardOutput = branchStdOut
562 project.ext.gitHash = hashStdOut.toString().trim()
563 project.ext.gitBranch = branchStdOut.toString().trim()
565 outputs.upToDateWhen { false }
568 task createBuildProperties(type: WriteProperties) {
570 inputs.dir("${jalviewDir}/${sourceDir}")
571 inputs.dir("${classes}")
572 inputs.dir("${jalviewDir}/${resourceDir}")
573 outputFile (buildProperties)
574 // taking time specific comment out to allow better incremental builds
575 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
576 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
577 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
578 property "VERSION", JALVIEW_VERSION
579 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
580 outputs.file(outputFile)
583 def buildingHTML = "${jalviewDir}/${docDir}/building.html"
584 task cleanBuildingHTML(type: Delete) {
590 task convertBuildingMD(type: Exec) {
591 dependsOn cleanBuildingHTML
592 def buildingMD = "${jalviewDir}/${docDir}/building.md"
593 def css = "${jalviewDir}/${docDir}/github.css"
596 pandoc_exec.split(",").each {
597 if (file(it.trim()).exists()) {
603 def hostname = "hostname".execute().text.trim()
604 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
605 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
609 if (pandoc != null && file(pandoc).exists()) {
610 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
612 println("Cannot find pandoc. Skipping convert building.md to HTML")
613 throw new StopExecutionException()
619 inputs.file(buildingMD)
621 outputs.file(buildingHTML)
630 task syncDocs(type: Sync) {
631 dependsOn convertBuildingMD
632 def syncDir = "${classes}/${docDir}"
633 from fileTree("${jalviewDir}/${docDir}")
638 def helpFile = "${classes}/${helpDir}/help.jhm"
640 task copyHelp(type: Copy) {
641 def inputDir = "${jalviewDir}/${helpParentDir}/${helpDir}"
642 def outputDir = "${classes}/${helpDir}"
647 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
657 outputs.files(helpFile)
658 outputs.dir(outputDir)
661 task syncLib(type: Sync) {
662 def syncDir = "${classes}/${libDistDir}"
663 from fileTree("${jalviewDir}/${libDistDir}")
667 task syncResources(type: Sync) {
668 from "${jalviewDir}/${resourceDir}"
677 dependsOn syncResources
683 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
686 dependsOn compileJava
688 dependsOn cloverInstr
692 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
696 includeGroups testngGroups
698 useDefaultListeners=true
701 workingDir = jalviewDir
702 //systemProperties 'clover.jar' System.properties.clover.jar
703 sourceCompatibility = compile_source_compatibility
704 targetCompatibility = compile_target_compatibility
705 jvmArgs += additional_compiler_args
709 task buildIndices(type: JavaExec) {
711 classpath = sourceSets.main.compileClasspath
712 main = "com.sun.java.help.search.Indexer"
713 workingDir = "${classes}/${helpDir}"
716 inputs.dir("${workingDir}/${argDir}")
718 outputs.dir("${classes}/doc")
719 outputs.dir("${classes}/help")
720 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
721 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
722 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
723 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
724 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
725 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
728 task compileLinkCheck(type: JavaCompile) {
730 classpath = files("${jalviewDir}/${utilsDir}")
731 destinationDir = file("${jalviewDir}/${utilsDir}")
732 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
734 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
735 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
736 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
737 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
740 def helplinkscheckertouchfile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.touch")
741 task linkCheck(type: JavaExec) {
742 dependsOn prepare, compileLinkCheck
743 classpath = files("${jalviewDir}/${utilsDir}")
744 main = "HelpLinksChecker"
745 workingDir = jalviewDir
746 def help = "${classes}/${helpDir}"
747 args = [ "${classes}/${helpDir}", "-nointernet" ]
750 helplinkscheckertouchfile.createNewFile()
753 inputs.dir("${classes}/${helpDir}")
754 outputs.file(helplinkscheckertouchfile)
757 // import the pubhtmlhelp target
758 ant.properties.basedir = "${jalviewDir}"
759 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
760 ant.importBuild "${utilsDir}/publishHelp.xml"
763 task cleanPackageDir(type: Delete) {
765 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
771 dependsOn buildIndices
772 dependsOn createBuildProperties
775 attributes "Main-Class": mainClass,
776 "Permissions": "all-permissions",
777 "Application-Name": "Jalview Desktop",
778 "Codebase": application_codebase
781 destinationDir = file("${jalviewDir}/${packageDir}")
782 archiveName = rootProject.name+".jar"
790 inputs.dir("${classes}")
791 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
794 task copyJars(type: Copy) {
795 from fileTree(dir: "${classes}", include: "**/*.jar").files
796 into "${jalviewDir}/${packageDir}"
799 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
800 task syncJars(type: Sync) {
801 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
802 into "${jalviewDir}/${packageDir}"
804 include jar.archiveName
810 description = "Put all required libraries in dist"
811 // order of "cleanPackageDir", "copyJars", "jar" important!
812 jar.mustRunAfter cleanPackageDir
813 syncJars.mustRunAfter cleanPackageDir
814 dependsOn cleanPackageDir
817 outputs.dir("${jalviewDir}/${packageDir}")
821 dependsOn cleanPackageDir
827 group = "distribution"
831 from ("${jalviewDir}/${libDistDir}") {
835 attributes 'Implementation-Version': JALVIEW_VERSION
837 mainClassName = shadowJarMainClass
839 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
843 task getdownWebsite() {
844 group = "distribution"
845 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
850 def getdownWebsiteResourceFilenames = []
851 def getdownTextString = ""
852 def getdownResourceDir = project.ext.getdownResourceDir
853 def getdownAppDir = project.ext.getdownAppDir
854 def getdownResourceFilenames = []
857 // clean the getdown website and files dir before creating getdown folders
858 delete project.ext.getdownWebsiteDir
859 delete project.ext.getdownFilesDir
863 rename(buildPropertiesFile, getdown_build_properties)
864 into project.ext.getdownAppDir
866 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
868 // go through properties looking for getdown_txt_...
869 def props = project.properties.sort { it.key }
870 if (getdown_alt_java_min_version.length() > 0) {
871 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
873 if (getdown_alt_java_max_version.length() > 0) {
874 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
876 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
878 props.put("getdown_txt_appbase", getdown_app_base)
879 props.each{ prop, val ->
880 if (prop.startsWith("getdown_txt_") && val != null) {
881 if (prop.startsWith("getdown_txt_multi_")) {
882 def key = prop.substring(18)
883 val.split(",").each{ v ->
884 def line = "${key} = ${v}\n"
885 getdownTextString += line
888 // file values rationalised
889 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
891 if (val.indexOf('/') == 0) {
894 } else if (val.indexOf('/') > 0) {
895 // relative path (relative to jalviewDir)
896 r = file( "${jalviewDir}/${val}" )
899 val = "${getdown_resource_dir}/" + r.getName()
900 getdownWebsiteResourceFilenames += val
901 getdownResourceFilenames += r.getPath()
904 if (! prop.startsWith("getdown_txt_resource")) {
905 def line = prop.substring(12) + " = ${val}\n"
906 getdownTextString += line
912 getdownWebsiteResourceFilenames.each{ filename ->
913 getdownTextString += "resource = ${filename}\n"
915 getdownResourceFilenames.each{ filename ->
918 into project.ext.getdownResourceDir
923 fileTree(file(packageDir)).each{ f ->
924 if (f.isDirectory()) {
925 def files = fileTree(dir: f, include: ["*"]).getFiles()
927 } else if (f.exists()) {
931 codeFiles.sort().each{f ->
932 def name = f.getName()
933 def line = "code = ${getdown_app_dir}/${name}\n"
934 getdownTextString += line
937 into project.ext.getdownAppDir
941 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
943 if (JAVA_VERSION.equals("11")) {
944 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
945 j11libFiles.sort().each{f ->
946 def name = f.getName()
947 def line = "code = ${getdown_j11lib_dir}/${name}\n"
948 getdownTextString += line
951 into project.ext.getdownJ11libDir
957 // 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.
958 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
959 getdownTextString += "resource = ${getdown_launcher_new}\n"
960 getdownTextString += "class = ${mainClass}\n"
962 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
963 getdown_txt.write(getdownTextString)
965 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
966 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
970 rename(file(getdownLauncher).getName(), getdown_launcher_new)
971 into project.ext.getdownWebsiteDir
976 if (file(getdownLauncher).getName() != getdown_launcher) {
977 rename(file(getdownLauncher).getName(), getdown_launcher)
979 into project.ext.getdownWebsiteDir
982 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
986 from "${getdownWebsiteDir}/${getdown_build_properties}"
987 if (file(getdownLauncher).getName() != getdown_launcher) {
988 rename(file(getdownLauncher).getName(), getdown_launcher)
990 into getdownInstallDir
994 from getdownInstallDir
995 into getdownFilesInstallDir
1002 from getdownLauncher
1003 from "${getdownWebsiteDir}/${getdown_build_properties}"
1004 if (file(getdownLauncher).getName() != getdown_launcher) {
1005 rename(file(getdownLauncher).getName(), getdown_launcher)
1007 into getdownFilesDir
1011 from getdownResourceDir
1012 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1017 inputs.dir("${jalviewDir}/${packageDir}")
1019 outputs.dir(project.ext.getdownWebsiteDir)
1020 outputs.dir(project.ext.getdownFilesDir)
1023 task getdownDigest(type: JavaExec) {
1024 group = "distribution"
1025 description = "Digest the getdown website folder"
1026 dependsOn getdownWebsite
1028 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1030 main = "com.threerings.getdown.tools.Digester"
1031 args project.ext.getdownWebsiteDir
1032 inputs.dir(project.ext.getdownWebsiteDir)
1033 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1037 group = "distribution"
1038 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1039 dependsOn getdownDigest
1041 if (reportRsyncCommand) {
1042 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1043 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1044 println "LIKELY RSYNC COMMAND:"
1045 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1046 if (RUNRSYNC == "true") {
1048 commandLine "mkdir", "-p", toDir
1051 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1060 delete project.ext.getdownWebsiteDir
1061 delete project.ext.getdownFilesDir
1066 def install4jHomeDir = "/opt/install4j"
1067 def hostname = "hostname".execute().text.trim()
1068 if (hostname.equals("jv-bamboo")) {
1069 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1070 } else if (OperatingSystem.current().isMacOsX()) {
1071 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1072 if (! file(install4jHomeDir).exists()) {
1073 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1075 } else if (OperatingSystem.current().isLinux()) {
1076 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1078 installDir = file(install4jHomeDir)
1079 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1080 if (install4jFaster.equals("true")) {
1088 def windowsJavaVMDir
1089 def windowsJavaVMTgz
1090 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1091 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1092 install4jConf = "${install4jDir}/${install4jConfFile}"
1094 task copyInstall4jTemplate(type: Copy) {
1095 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1096 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1097 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1098 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1099 from (install4jDir) {
1100 include install4jTemplate
1101 rename (install4jTemplate, install4jConfFile)
1102 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1103 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1105 'JAVA_VERSION': JAVA_VERSION,
1106 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1107 'VERSION': JALVIEW_VERSION,
1108 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1109 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1110 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1111 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1112 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1113 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1114 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1115 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1116 'GETDOWN_DIST_DIR': getdown_app_dir,
1117 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1118 'GETDOWN_INSTALL_DIR': getdown_install_dir
1121 if (OSX_KEYPASS=="") {
1122 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1123 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1127 outputs.files(install4jConf)
1130 // include file associations in installer
1131 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1135 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1136 replace: installerFileAssociationsXml,
1140 // include uninstaller applescript app files in dmg
1141 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1145 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1146 replace: installerDMGUninstallerXml,
1153 task installers(type: com.install4j.gradle.Install4jTask) {
1154 group = "distribution"
1155 description = "Create the install4j installers"
1157 dependsOn copyInstall4jTemplate
1158 projectFile = file(install4jConf)
1159 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1160 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1161 buildSelected = true
1164 macKeystorePassword=OSX_KEYPASS
1168 println("Using projectFile "+projectFile)
1171 inputs.dir(project.ext.getdownWebsiteDir)
1172 inputs.file(install4jConf)
1173 inputs.dir(macosJavaVMDir)
1174 inputs.dir(windowsJavaVMDir)
1175 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1180 delete install4jConf
1184 task sourceDist (type: Tar) {
1186 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1187 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1188 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1190 archiveFileName = outputFileName
1191 } catch (Exception e) {
1192 archiveName = outputFileName
1195 compression Compression.GZIP
1199 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1204 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1206 ,"utils/InstallAnywhere"]
1207 def PROCESS_FILES=[ "AUTHORS",
1215 "THIRDPARTYLIBS","TESTNG",
1217 "gradle.properties",
1228 exclude (EXCLUDE_FILES)
1229 include (PROCESS_FILES)
1230 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1233 exclude (EXCLUDE_FILES)
1234 exclude (PROCESS_FILES)
1235 exclude ("appletlib")
1236 exclude ("**/*locales")
1237 exclude ("*locales/**")
1238 exclude ("utils/InstallAnywhere")
1240 exclude (getdown_files_dir)
1241 exclude (getdown_website_dir)
1243 // exluding these as not using jars as modules yet
1244 exclude ("${j11modDir}/**/*.jar")
1246 // from (jalviewDir) {
1247 // // explicit includes for stuff that seemed to not get included
1248 // include(fileTree("test/**/*."))
1249 // exclude(EXCLUDE_FILES)
1250 // exclude(PROCESS_FILES)
1256 dependsOn pubhtmlhelp
1258 inputs.dir("${classes}/${helpDir}")
1259 outputs.dir("${helpOutputDir}")
1262 def jalviewjsBuildDir
1263 def jalviewjsSiteDir
1264 def jalviewjsTransferSiteDir
1265 task jalviewjsSitePath {
1266 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1267 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1268 if (jalviewjs_site_dir.startsWith('/')) {
1269 jalviewjsSiteDir = jalviewjs_site_dir
1271 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1273 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1276 def eclipseWorkspace
1277 task jalviewjsSetEclipseWorkspace {
1278 def propKey = "jalviewjs_eclipse_workspace"
1280 if (project.hasProperty(propKey)) {
1281 propVal = project.getProperty(propKey)
1282 if (propVal.startsWith("~/")) {
1283 propVal = System.getProperty("user.home") + propVal.substring(1)
1286 def propsFileName = "${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1287 def eclipseWsDir = propVal
1288 def props = new Properties()
1290 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && file(propsFileName).exists()) {
1291 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${propsFileName}")
1294 if (props.getProperty(propKey, null) != null) {
1295 eclipseWsDir = props.getProperty(propKey)
1299 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1300 def tempDir = File.createTempDir()
1301 eclipseWsDir = tempDir.getAbsolutePath()
1302 props.setProperty(propKey, eclipseWsDir)
1303 def propsFile = file(propsFileName)
1304 propsFile.parentFile.mkdirs()
1305 propsFile.createNewFile() // doesn't affect existing file
1306 def outs = new FileOutputStream(propsFile, false)
1307 props.store(outs, null)
1311 eclipseWorkspace = file(eclipseWsDir)
1314 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1316 inputs.property(propKey, eclipseWsDir)
1317 outputs.file(propsFileName)
1321 def eclipseDropinsDir
1325 def eclipseDebug = false
1326 def eclipseVersionSuffix = ""
1327 task jalviewjsEclipsePaths {
1330 def eclipseRoot = jalviewjs_eclipse_root
1331 if (eclipseRoot.startsWith("~/")) {
1332 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1334 if (OperatingSystem.current().isMacOsX()) {
1335 eclipseRoot += "/Eclipse.app"
1336 eclipseDropinsDir = "${eclipseRoot}/Contents/Eclipse/dropins"
1337 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1338 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1339 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1340 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1341 eclipseRoot += "/eclipse"
1343 eclipseDropinsDir = "${eclipseRoot}/dropins"
1344 eclipseBinary = "${eclipseRoot}/eclipse"
1345 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1346 } else { // linux or unix
1347 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1348 eclipseRoot += "/eclipse"
1350 eclipseDropinsDir = "${eclipseRoot}/dropins"
1351 eclipseBinary = "${eclipseRoot}/eclipse"
1352 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1355 eclipseVersion = "4.12" // default
1356 def assumedVersion = true
1357 if (file(eclipseProduct).exists()) {
1358 def fis = new FileInputStream(eclipseProduct)
1359 def props = new Properties()
1361 eclipseVersion = props.getProperty("version")
1363 assumedVersion = false
1366 String[] v = eclipseVersion.split("\\.")
1367 def v0 = Integer.valueOf(v[0])
1368 def v1 = Integer.valueOf(v[1])
1369 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1370 eclipseVersionSuffix = "_4.12"
1372 eclipseVersionSuffix = "_4.13"
1374 utilsDropinsDir = "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}${eclipseVersionSuffix}"
1377 utilsDropinsDir = "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}"
1378 def propKey = "eclipse_debug"
1379 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1382 if (!assumedVersion) {
1383 println("ECLIPSE_VERSION=${eclipseVersion}")
1389 dependsOn eclipseProject
1390 dependsOn eclipseClasspath
1391 dependsOn eclipseJdt
1394 /* using the Copy task below
1395 task OLDjalviewjsEclipseCopyDropins {
1396 dependsOn jalviewjsEclipsePaths
1397 dependsOn jalviewjsCleanEclipse
1398 def inputFiles = fileTree(dir: utilsDropinsDir, include: "*.jar")
1399 inputFiles += file(jalviewjs_j2s_plugin)
1400 def outputDir = eclipseDropinsDir
1402 inputs.files inputFiles
1403 inputFiles.each { file ->
1404 outputs.file("${outputDir}/${file.name}")
1408 inputFiles.each { file ->
1418 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1419 task jalviewjsEclipseCopyDropins(type: Copy) {
1420 dependsOn jalviewjsEclipsePaths
1422 from utilsDropinsDir
1423 into eclipseDropinsDir
1427 from jalviewjs_j2s_plugin
1428 into eclipseDropinsDir
1433 // this eclipse -clean doesn't actually work
1434 task jalviewjsCleanEclipse(type: Exec) {
1435 dependsOn eclipseSetup
1436 dependsOn jalviewjsEclipsePaths
1437 dependsOn jalviewjsEclipseCopyDropins
1439 executable(eclipseBinary)
1440 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1446 def inputString = """exit
1449 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1450 standardInput = inputByteStream
1453 println("CLEAN ECLIPSE_DEBUG=${eclipseDebug}")
1456 /* not really working yet
1457 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1460 task jalviewjsUnzipFiles {
1461 dependsOn jalviewjsSitePath
1463 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1464 zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
1467 zipFiles.each { file_zip ->
1469 from zipTree(file_zip)
1470 into "${jalviewDir}/${jalviewjsSiteDir}"
1475 inputs.files zipFiles
1476 outputs.dir "${jalviewDir}/${jalviewjsSiteDir}"
1479 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1480 dependsOn jalviewjsSitePath
1481 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1482 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1483 def siteDirProperty = "j2s.site.directory"
1484 def setSiteDir = false
1485 j2s_props.each { prop, val ->
1487 if (prop == siteDirProperty) {
1488 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1489 val = "${jalviewjsTransferSiteDir}/${val}"
1495 if (!setSiteDir) { // default site location, don't override specifically set property
1496 property(siteDirProperty,jalviewjsTransferSiteDir)
1499 inputs.properties(j2s_props)
1500 outputs.file(outputFile)
1503 task jalviewjsEclipseSetup {
1504 dependsOn jalviewjsEclipseCopyDropins
1505 dependsOn jalviewjsSetEclipseWorkspace
1506 dependsOn jalviewjsCreateJ2sSettings
1509 task jalviewjsCopyResources (type: Sync) {
1510 dependsOn jalviewjsSitePath
1511 def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
1512 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1516 def outputFiles = []
1517 rename { filename ->
1518 outputFiles += "${outputDir}/${filename}"
1524 outputs.files outputFiles
1525 inputs.files inputFiles
1528 task jalviewjsCopySiteResources (type: Sync) {
1529 dependsOn jalviewjsSitePath
1530 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1531 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1535 def outputFiles = []
1536 rename { filename ->
1537 outputFiles += "${outputDir}/${filename}"
1543 outputs.files outputFiles
1544 inputs.files inputFiles
1547 task jalviewjsProjectImport(type: Exec) {
1548 dependsOn eclipseSetup
1549 dependsOn jalviewjsEclipsePaths
1550 dependsOn jalviewjsEclipseSetup
1552 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1553 executable(eclipseBinary)
1554 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1558 // can we use args += ["--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=utils/jalviewjs/eclipse/dropins"] here? (instead of copying plugins to eclipse dropins dir)
1561 println("IMPORT ECLIPSE_DEBUG=${eclipseDebug}")
1564 inputs.file("${jalviewDir}/.project")
1565 outputs.dir(projdir)
1566 outputs.upToDateWhen { file(projdir).exists() }
1569 task jalviewjsTranspile(type: Exec) {
1570 dependsOn jalviewjsEclipseSetup
1571 dependsOn jalviewjsProjectImport
1572 dependsOn jalviewjsEclipsePaths
1574 executable(eclipseBinary)
1575 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1579 // can we use args += ["--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=swingjs"] here? (instead of copying plugins to eclipse dropins dir)
1583 stdout = new ByteArrayOutputStream()
1584 stderr = new ByteArrayOutputStream()
1586 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1587 def logOutFile = file(logOutFileName)
1588 logOutFile.createNewFile()
1589 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1590 BINARY: ${eclipseBinary}
1591 VERSION: ${eclipseVersion}
1592 WORKSPACE: ${eclipseWorkspace}
1593 DEBUG: ${eclipseDebug}
1596 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1597 //def logErrFileName = "${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1598 //def logErrFile = file(logFileName)
1599 //logErrFile.createNewFile()
1600 //def logErrFOS = new FileErrputStream(logErrFile, false)
1601 // combine stdout and stderr
1602 def logErrFOS = logOutFOS
1604 if (jalviewjs_j2s_to_console.equals("true")) {
1605 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1606 new org.apache.tools.ant.util.TeeOutputStream(
1610 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1611 new org.apache.tools.ant.util.TeeOutputStream(
1616 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1619 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1625 if (stdout.toString().contains("Error processing ")) {
1626 // j2s did not complete transpile
1627 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1632 println("TRANSPILE ECLIPSE_DEBUG=${eclipseDebug}")
1635 inputs.dir("${jalviewDir}/${sourceDir}")
1636 outputs.dir("${jalviewDir}/${eclipse_bin_dir}/main")
1637 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteDir}")
1638 outputs.upToDateWhen { file("${jalviewDir}/${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() }
1642 task jalviewjsCopyTransferSite(type: Copy) {
1643 dependsOn jalviewjsTranspile
1644 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1645 into "${jalviewDir}/${jalviewjsSiteDir}"
1648 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1649 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1650 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1652 task jalviewjsPrepareSite {
1654 description "Prepares the website folder including unzipping files and copying resources"
1655 dependsOn jalviewjsSitePath
1656 dependsOn jalviewjsUnzipFiles
1657 dependsOn jalviewjsCopyResources
1658 dependsOn jalviewjsCopySiteResources
1661 task jalviewjsBuildSite {
1663 description "Builds the whole website including transpiled code"
1664 dependsOn jalviewjsCopyTransferSite
1665 dependsOn jalviewjsPrepareSite
1668 task cleanJalviewjsSite {
1670 delete jalviewjsTransferSiteDir
1671 delete jalviewjsSiteDir
1675 task jalviewjsSiteTar(type: Tar) {
1677 description "Creates a tar.gz file for the website"
1678 dependsOn jalviewjsBuildSite
1679 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1681 archiveFileName = outputFilename
1682 } catch (Exception e) {
1683 archiveName = outputFilename
1686 compression Compression.GZIP
1688 from jalviewjsSiteDir
1689 into jalviewjs_site_dir // this is inside the tar file
1691 inputs.dir(jalviewjsSiteDir)
1694 task jalviewjsServer {
1696 description "Starts a webserver on localhost to test the website"
1697 dependsOn jalviewjsSitePath
1698 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1701 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1702 def port = Integer.valueOf(jalviewjs_server_port)
1706 while(port < start+1000 && !running) {
1708 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1709 def jalviewjsServer = factory.start(doc_root, port)
1711 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1712 println("SERVER STARTED with document root ${doc_root}.")
1713 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1714 println("For debug: "+url+"?j2sdebug")
1716 file(htmlFile).text = """
1717 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1718 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1721 } catch (Exception e) {
1728 outputs.file(htmlFile)
1729 outputs.upToDateWhen({false})
1732 task cleanJalviewjsAll {
1734 description "Delete all configuration and build artifacts to do with JalviewJS build"
1735 dependsOn cleanJalviewjsSite
1736 dependsOn jalviewjsEclipsePaths
1739 delete jalviewjsBuildDir
1740 delete "${jalviewDir}/${eclipse_bin_dir}"
1741 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1742 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1744 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1750 description "Build the site"
1751 dependsOn jalviewjsBuildSite
1755 task jalviewjsIDECopyTransferSite(type: Copy) {
1756 from jalviewjsTransferSiteDir
1757 into jalviewjsSiteDir
1760 task jalviewjsIDEj2s {
1761 group "JalviewJS in Eclipse"
1762 description "Creates the .j2s file"
1763 dependsOn jalviewjsCreateJ2sSettings
1766 task jalviewjsIDEBuildSite {
1767 group "JalviewJS in Eclipse"
1768 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1769 dependsOn jalviewjsIDECopyTransferSite
1770 dependsOn jalviewjsPrepareSite
1773 task jalviewjsIDESiteClean {
1774 group "JalviewJS in Eclipse"
1775 description "Deletes the Eclipse transpiled site"
1776 dependsOn cleanJalviewjsSite
1779 task jalviewjsIDEServer {
1780 group "JalviewJS in Eclipse"
1781 description "Starts a webserver on localhost to test the website"
1782 dependsOn jalviewjsServer