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 task linkCheck(type: JavaExec) {
741 dependsOn prepare, compileLinkCheck
743 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
744 classpath = files("${jalviewDir}/${utilsDir}")
745 main = "HelpLinksChecker"
746 workingDir = jalviewDir
747 def help = "${classes}/${helpDir}"
748 args = [ "${classes}/${helpDir}", "-nointernet" ]
750 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
752 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
755 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
759 inputs.dir("${classes}/${helpDir}")
760 outputs.file(helpLinksCheckerOutFile)
763 // import the pubhtmlhelp target
764 ant.properties.basedir = "${jalviewDir}"
765 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
766 ant.importBuild "${utilsDir}/publishHelp.xml"
769 task cleanPackageDir(type: Delete) {
771 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
777 dependsOn buildIndices
778 dependsOn createBuildProperties
781 attributes "Main-Class": mainClass,
782 "Permissions": "all-permissions",
783 "Application-Name": "Jalview Desktop",
784 "Codebase": application_codebase
787 destinationDir = file("${jalviewDir}/${packageDir}")
788 archiveName = rootProject.name+".jar"
796 inputs.dir("${classes}")
797 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
800 task copyJars(type: Copy) {
801 from fileTree(dir: "${classes}", include: "**/*.jar").files
802 into "${jalviewDir}/${packageDir}"
805 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
806 task syncJars(type: Sync) {
807 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
808 into "${jalviewDir}/${packageDir}"
810 include jar.archiveName
816 description = "Put all required libraries in dist"
817 // order of "cleanPackageDir", "copyJars", "jar" important!
818 jar.mustRunAfter cleanPackageDir
819 syncJars.mustRunAfter cleanPackageDir
820 dependsOn cleanPackageDir
823 outputs.dir("${jalviewDir}/${packageDir}")
827 dependsOn cleanPackageDir
833 group = "distribution"
837 from ("${jalviewDir}/${libDistDir}") {
841 attributes 'Implementation-Version': JALVIEW_VERSION
843 mainClassName = shadowJarMainClass
845 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
849 task getdownWebsite() {
850 group = "distribution"
851 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
856 def getdownWebsiteResourceFilenames = []
857 def getdownTextString = ""
858 def getdownResourceDir = project.ext.getdownResourceDir
859 def getdownAppDir = project.ext.getdownAppDir
860 def getdownResourceFilenames = []
863 // clean the getdown website and files dir before creating getdown folders
864 delete project.ext.getdownWebsiteDir
865 delete project.ext.getdownFilesDir
869 rename(buildPropertiesFile, getdown_build_properties)
870 into project.ext.getdownAppDir
872 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
874 // go through properties looking for getdown_txt_...
875 def props = project.properties.sort { it.key }
876 if (getdown_alt_java_min_version.length() > 0) {
877 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
879 if (getdown_alt_java_max_version.length() > 0) {
880 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
882 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
884 props.put("getdown_txt_appbase", getdown_app_base)
885 props.each{ prop, val ->
886 if (prop.startsWith("getdown_txt_") && val != null) {
887 if (prop.startsWith("getdown_txt_multi_")) {
888 def key = prop.substring(18)
889 val.split(",").each{ v ->
890 def line = "${key} = ${v}\n"
891 getdownTextString += line
894 // file values rationalised
895 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
897 if (val.indexOf('/') == 0) {
900 } else if (val.indexOf('/') > 0) {
901 // relative path (relative to jalviewDir)
902 r = file( "${jalviewDir}/${val}" )
905 val = "${getdown_resource_dir}/" + r.getName()
906 getdownWebsiteResourceFilenames += val
907 getdownResourceFilenames += r.getPath()
910 if (! prop.startsWith("getdown_txt_resource")) {
911 def line = prop.substring(12) + " = ${val}\n"
912 getdownTextString += line
918 getdownWebsiteResourceFilenames.each{ filename ->
919 getdownTextString += "resource = ${filename}\n"
921 getdownResourceFilenames.each{ filename ->
924 into project.ext.getdownResourceDir
929 fileTree(file(packageDir)).each{ f ->
930 if (f.isDirectory()) {
931 def files = fileTree(dir: f, include: ["*"]).getFiles()
933 } else if (f.exists()) {
937 codeFiles.sort().each{f ->
938 def name = f.getName()
939 def line = "code = ${getdown_app_dir}/${name}\n"
940 getdownTextString += line
943 into project.ext.getdownAppDir
947 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
949 if (JAVA_VERSION.equals("11")) {
950 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
951 j11libFiles.sort().each{f ->
952 def name = f.getName()
953 def line = "code = ${getdown_j11lib_dir}/${name}\n"
954 getdownTextString += line
957 into project.ext.getdownJ11libDir
963 // 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.
964 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
965 getdownTextString += "resource = ${getdown_launcher_new}\n"
966 getdownTextString += "class = ${mainClass}\n"
968 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
969 getdown_txt.write(getdownTextString)
971 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
972 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
976 rename(file(getdownLauncher).getName(), getdown_launcher_new)
977 into project.ext.getdownWebsiteDir
982 if (file(getdownLauncher).getName() != getdown_launcher) {
983 rename(file(getdownLauncher).getName(), getdown_launcher)
985 into project.ext.getdownWebsiteDir
988 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
992 from "${getdownWebsiteDir}/${getdown_build_properties}"
993 if (file(getdownLauncher).getName() != getdown_launcher) {
994 rename(file(getdownLauncher).getName(), getdown_launcher)
996 into getdownInstallDir
1000 from getdownInstallDir
1001 into getdownFilesInstallDir
1008 from getdownLauncher
1009 from "${getdownWebsiteDir}/${getdown_build_properties}"
1010 if (file(getdownLauncher).getName() != getdown_launcher) {
1011 rename(file(getdownLauncher).getName(), getdown_launcher)
1013 into getdownFilesDir
1017 from getdownResourceDir
1018 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1023 inputs.dir("${jalviewDir}/${packageDir}")
1025 outputs.dir(project.ext.getdownWebsiteDir)
1026 outputs.dir(project.ext.getdownFilesDir)
1029 task getdownDigest(type: JavaExec) {
1030 group = "distribution"
1031 description = "Digest the getdown website folder"
1032 dependsOn getdownWebsite
1034 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1036 main = "com.threerings.getdown.tools.Digester"
1037 args project.ext.getdownWebsiteDir
1038 inputs.dir(project.ext.getdownWebsiteDir)
1039 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1043 group = "distribution"
1044 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1045 dependsOn getdownDigest
1047 if (reportRsyncCommand) {
1048 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1049 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1050 println "LIKELY RSYNC COMMAND:"
1051 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1052 if (RUNRSYNC == "true") {
1054 commandLine "mkdir", "-p", toDir
1057 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1066 delete project.ext.getdownWebsiteDir
1067 delete project.ext.getdownFilesDir
1072 def install4jHomeDir = "/opt/install4j"
1073 def hostname = "hostname".execute().text.trim()
1074 if (hostname.equals("jv-bamboo")) {
1075 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1076 } else if (OperatingSystem.current().isMacOsX()) {
1077 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1078 if (! file(install4jHomeDir).exists()) {
1079 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1081 } else if (OperatingSystem.current().isLinux()) {
1082 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1084 installDir = file(install4jHomeDir)
1085 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1086 if (install4jFaster.equals("true")) {
1094 def windowsJavaVMDir
1095 def windowsJavaVMTgz
1096 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1097 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1098 install4jConf = "${install4jDir}/${install4jConfFile}"
1100 task copyInstall4jTemplate(type: Copy) {
1101 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1102 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1103 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1104 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1105 from (install4jDir) {
1106 include install4jTemplate
1107 rename (install4jTemplate, install4jConfFile)
1108 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1109 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1111 'JAVA_VERSION': JAVA_VERSION,
1112 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1113 'VERSION': JALVIEW_VERSION,
1114 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1115 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1116 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1117 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1118 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1119 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1120 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1121 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1122 'GETDOWN_DIST_DIR': getdown_app_dir,
1123 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1124 'GETDOWN_INSTALL_DIR': getdown_install_dir
1127 if (OSX_KEYPASS=="") {
1128 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1129 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1133 outputs.files(install4jConf)
1136 // include file associations in installer
1137 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1141 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1142 replace: installerFileAssociationsXml,
1146 // include uninstaller applescript app files in dmg
1147 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1151 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1152 replace: installerDMGUninstallerXml,
1159 task installers(type: com.install4j.gradle.Install4jTask) {
1160 group = "distribution"
1161 description = "Create the install4j installers"
1163 dependsOn copyInstall4jTemplate
1164 projectFile = file(install4jConf)
1165 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1166 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1167 buildSelected = true
1170 macKeystorePassword=OSX_KEYPASS
1174 println("Using projectFile "+projectFile)
1177 inputs.dir(project.ext.getdownWebsiteDir)
1178 inputs.file(install4jConf)
1179 inputs.dir(macosJavaVMDir)
1180 inputs.dir(windowsJavaVMDir)
1181 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1186 delete install4jConf
1190 task sourceDist (type: Tar) {
1192 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1193 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1194 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1196 archiveFileName = outputFileName
1197 } catch (Exception e) {
1198 archiveName = outputFileName
1201 compression Compression.GZIP
1205 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1210 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1212 ,"utils/InstallAnywhere"]
1213 def PROCESS_FILES=[ "AUTHORS",
1221 "THIRDPARTYLIBS","TESTNG",
1223 "gradle.properties",
1234 exclude (EXCLUDE_FILES)
1235 include (PROCESS_FILES)
1236 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1239 exclude (EXCLUDE_FILES)
1240 exclude (PROCESS_FILES)
1241 exclude ("appletlib")
1242 exclude ("**/*locales")
1243 exclude ("*locales/**")
1244 exclude ("utils/InstallAnywhere")
1246 exclude (getdown_files_dir)
1247 exclude (getdown_website_dir)
1249 // exluding these as not using jars as modules yet
1250 exclude ("${j11modDir}/**/*.jar")
1252 // from (jalviewDir) {
1253 // // explicit includes for stuff that seemed to not get included
1254 // include(fileTree("test/**/*."))
1255 // exclude(EXCLUDE_FILES)
1256 // exclude(PROCESS_FILES)
1262 dependsOn pubhtmlhelp
1264 inputs.dir("${classes}/${helpDir}")
1265 outputs.dir("${helpOutputDir}")
1268 def jalviewjsBuildDir
1269 def jalviewjsSiteDir
1270 def jalviewjsTransferSiteDir
1271 task jalviewjsSitePath {
1272 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1273 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1274 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1275 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1278 def eclipseWorkspace
1279 task jalviewjsSetEclipseWorkspace {
1280 def propKey = "jalviewjs_eclipse_workspace"
1282 if (project.hasProperty(propKey)) {
1283 propVal = project.getProperty(propKey)
1284 if (propVal.startsWith("~/")) {
1285 propVal = System.getProperty("user.home") + propVal.substring(1)
1288 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1289 def propsFile = file(propsFileName)
1290 def eclipseWsDir = propVal
1291 def props = new Properties()
1293 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1294 def ins = new FileInputStream(propsFileName)
1297 if (props.getProperty(propKey, null) != null) {
1298 eclipseWsDir = props.getProperty(propKey)
1302 def writeProps = false
1303 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1304 def tempDir = File.createTempDir()
1305 eclipseWsDir = tempDir.getAbsolutePath()
1308 eclipseWorkspace = file(eclipseWsDir)
1312 props.setProperty(propKey, eclipseWsDir)
1313 propsFile.parentFile.mkdirs()
1314 def bytes = new ByteArrayOutputStream()
1315 props.store(bytes, null)
1316 def propertiesString = bytes.toString()
1317 propsFile.text = propertiesString
1320 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1323 inputs.property(propKey, eclipseWsDir)
1324 outputs.file(propsFileName)
1330 def eclipseDebug = false
1331 def eclipseVersionSuffix = ""
1332 task jalviewjsEclipsePaths {
1335 def eclipseRoot = jalviewjs_eclipse_root
1336 if (eclipseRoot.startsWith("~/")) {
1337 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1339 if (OperatingSystem.current().isMacOsX()) {
1340 eclipseRoot += "/Eclipse.app"
1341 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1342 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1343 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1344 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1345 eclipseRoot += "/eclipse"
1347 eclipseBinary = "${eclipseRoot}/eclipse"
1348 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1349 } else { // linux or unix
1350 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1351 eclipseRoot += "/eclipse"
1353 eclipseBinary = "${eclipseRoot}/eclipse"
1354 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1357 eclipseVersion = "4.12" // default
1358 def assumedVersion = true
1359 if (file(eclipseProduct).exists()) {
1360 def fis = new FileInputStream(eclipseProduct)
1361 def props = new Properties()
1363 eclipseVersion = props.getProperty("version")
1365 assumedVersion = false
1368 String[] v = eclipseVersion.split("\\.")
1369 def v0 = Integer.valueOf(v[0])
1370 def v1 = Integer.valueOf(v[1])
1371 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1372 eclipseVersionSuffix = "_4.12"
1374 eclipseVersionSuffix = "_4.13"
1379 def propKey = "eclipse_debug"
1380 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1383 if (!assumedVersion) {
1384 println("ECLIPSE VERSION=${eclipseVersion}")
1390 dependsOn eclipseProject
1391 dependsOn eclipseClasspath
1392 dependsOn eclipseJdt
1395 /* using the Copy task below
1396 task OLDjalviewjsEclipseCopyDropins {
1397 dependsOn jalviewjsEclipsePaths
1398 dependsOn jalviewjsCleanEclipse
1399 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1400 inputFiles += file(jalviewjs_j2s_plugin)
1401 def outputDir = "${buildDir}/jalviewjs
1403 inputs.files inputFiles
1404 inputFiles.each { file ->
1405 outputs.file("${outputDir}/${file.name}")
1409 inputFiles.each { file ->
1419 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1420 task jalviewjsEclipseCopyDropins(type: Copy) {
1421 dependsOn jalviewjsEclipsePaths
1423 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1424 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1425 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1431 // this eclipse -clean doesn't actually work
1432 task jalviewjsCleanEclipse(type: Exec) {
1433 dependsOn eclipseSetup
1434 dependsOn jalviewjsEclipsePaths
1435 dependsOn jalviewjsEclipseCopyDropins
1437 executable(eclipseBinary)
1438 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1444 def inputString = """exit
1447 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1448 standardInput = inputByteStream
1450 /* not really working yet
1451 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1454 task jalviewjsUnzipFiles {
1455 dependsOn jalviewjsSitePath
1457 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1458 zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
1461 zipFiles.each { file_zip ->
1463 from zipTree(file_zip)
1464 into "${jalviewDir}/${jalviewjsSiteDir}"
1469 inputs.files zipFiles
1470 outputs.dir "${jalviewDir}/${jalviewjsSiteDir}"
1473 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1474 dependsOn jalviewjsSitePath
1475 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1476 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1477 def siteDirProperty = "j2s.site.directory"
1478 def setSiteDir = false
1479 j2s_props.each { prop, val ->
1481 if (prop == siteDirProperty) {
1482 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1483 val = "${jalviewDir}/${jalviewjsTransferSiteDir}/${val}"
1489 if (!setSiteDir) { // default site location, don't override specifically set property
1490 property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteDir}")
1493 inputs.properties(j2s_props)
1494 outputs.file(outputFile)
1497 task jalviewjsEclipseSetup {
1498 dependsOn jalviewjsEclipseCopyDropins
1499 dependsOn jalviewjsSetEclipseWorkspace
1500 dependsOn jalviewjsCreateJ2sSettings
1503 task jalviewjsCopyResources (type: Sync) {
1504 dependsOn jalviewjsSitePath
1505 def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
1506 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1510 def outputFiles = []
1511 rename { filename ->
1512 outputFiles += "${outputDir}/${filename}"
1518 outputs.files outputFiles
1519 inputs.files inputFiles
1522 task jalviewjsCopySiteResources (type: Sync) {
1523 dependsOn jalviewjsSitePath
1524 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1525 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1529 def outputFiles = []
1530 rename { filename ->
1531 outputFiles += "${outputDir}/${filename}"
1537 outputs.files outputFiles
1538 inputs.files inputFiles
1541 task jalviewjsProjectImport(type: Exec) {
1542 dependsOn eclipseSetup
1543 dependsOn jalviewjsEclipsePaths
1544 dependsOn jalviewjsEclipseSetup
1546 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1547 executable(eclipseBinary)
1548 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1552 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1554 inputs.file("${jalviewDir}/.project")
1555 outputs.upToDateWhen { file(projdir).exists() }
1558 task jalviewjsTranspile(type: Exec) {
1559 dependsOn jalviewjsEclipseSetup
1560 dependsOn jalviewjsProjectImport
1561 dependsOn jalviewjsEclipsePaths
1563 executable(eclipseBinary)
1564 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1568 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1573 stdout = new ByteArrayOutputStream()
1574 stderr = new ByteArrayOutputStream()
1576 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1577 def logOutFile = file(logOutFileName)
1578 logOutFile.createNewFile()
1579 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1580 BINARY: ${eclipseBinary}
1581 VERSION: ${eclipseVersion}
1582 WORKSPACE: ${eclipseWorkspace}
1583 DEBUG: ${eclipseDebug}
1586 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1587 //def logErrFileName = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1588 //def logErrFile = file(logFileName)
1589 //logErrFile.createNewFile()
1590 //def logErrFOS = new FileErrputStream(logErrFile, false)
1591 // combine stdout and stderr
1592 def logErrFOS = logOutFOS
1594 if (jalviewjs_j2s_to_console.equals("true")) {
1595 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1596 new org.apache.tools.ant.util.TeeOutputStream(
1600 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1601 new org.apache.tools.ant.util.TeeOutputStream(
1606 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1609 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1616 if (stdout.toString().contains("Error processing ")) {
1617 // j2s did not complete transpile
1618 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1622 inputs.dir("${jalviewDir}/${sourceDir}")
1623 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteDir}")
1624 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() } )
1627 task jalviewjsCopyTransferSite(type: Copy) {
1628 dependsOn jalviewjsTranspile
1629 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1630 into "${jalviewDir}/${jalviewjsSiteDir}"
1633 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1634 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1635 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1637 task jalviewjsPrepareSite {
1639 description "Prepares the website folder including unzipping files and copying resources"
1640 dependsOn jalviewjsSitePath
1641 dependsOn jalviewjsUnzipFiles
1642 dependsOn jalviewjsCopyResources
1643 dependsOn jalviewjsCopySiteResources
1646 task jalviewjsBuildSite {
1648 description "Builds the whole website including transpiled code"
1649 dependsOn jalviewjsCopyTransferSite
1650 dependsOn jalviewjsPrepareSite
1653 task cleanJalviewjsSite {
1655 delete "${jalviewDir}/${jalviewjsTransferSiteDir}"
1656 delete "${jalviewDir}/${jalviewjsSiteDir}"
1660 task jalviewjsSiteTar(type: Tar) {
1662 description "Creates a tar.gz file for the website"
1663 dependsOn jalviewjsBuildSite
1664 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1666 archiveFileName = outputFilename
1667 } catch (Exception e) {
1668 archiveName = outputFilename
1671 compression Compression.GZIP
1673 from "${jalviewDir}/${jalviewjsSiteDir}"
1674 into jalviewjs_site_dir // this is inside the tar file
1676 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
1679 task jalviewjsServer {
1681 description "Starts a webserver on localhost to test the website"
1682 dependsOn jalviewjsSitePath
1683 def htmlFile = "${jalviewDirAbsolutePath}/jalviewjsTest.html"
1686 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1687 def port = Integer.valueOf(jalviewjs_server_port)
1691 while(port < start+1000 && !running) {
1693 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1694 def jalviewjsServer = factory.start(doc_root, port)
1696 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1697 println("SERVER STARTED with document root ${doc_root}.")
1698 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1699 println("For debug: "+url+"?j2sdebug")
1701 file(htmlFile).text = """
1702 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1703 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1706 } catch (Exception e) {
1713 outputs.file(htmlFile)
1714 outputs.upToDateWhen({false})
1717 task cleanJalviewjsAll {
1719 description "Delete all configuration and build artifacts to do with JalviewJS build"
1720 dependsOn cleanJalviewjsSite
1721 dependsOn jalviewjsEclipsePaths
1724 delete "${jalviewDir}/${jalviewjsBuildDir}"
1725 delete "${jalviewDir}/${eclipse_bin_dir}"
1726 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1727 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1729 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1732 outputs.upToDateWhen( { false } )
1737 description "Build the site"
1738 dependsOn jalviewjsBuildSite
1742 task jalviewjsIDECopyTransferSite(type: Copy) {
1743 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1744 into "${jalviewDir}/${jalviewjsSiteDir}"
1747 task jalviewjsIDEj2s {
1748 group "JalviewJS in Eclipse"
1749 description "Creates the .j2s file"
1750 dependsOn jalviewjsCreateJ2sSettings
1753 task jalviewjsIDEBuildSite {
1754 group "JalviewJS in Eclipse"
1755 description "Copies the Eclipse transpiled site and unzips supporting zipfiles"
1756 dependsOn jalviewjsIDECopyTransferSite
1757 dependsOn jalviewjsPrepareSite
1760 task jalviewjsIDESiteClean {
1761 group "JalviewJS in Eclipse"
1762 description "Deletes the Eclipse transpiled site"
1763 dependsOn cleanJalviewjsSite
1766 task jalviewjsIDEServer {
1767 group "JalviewJS in Eclipse"
1768 description "Starts a webserver on localhost to test the website"
1769 dependsOn jalviewjsServer