1 import org.apache.tools.ant.filters.ReplaceTokens
2 import org.gradle.internal.os.OperatingSystem
3 import org.gradle.plugins.ide.eclipse.model.Output
4 import org.gradle.plugins.ide.eclipse.model.Library
6 import groovy.transform.ExternalizeMethods
10 classpath 'org.openclover:clover:4.3.1'
18 id 'com.github.johnrengelman.shadow' version '4.0.3'
19 id 'com.install4j.gradle' version '7.0.9'
22 // local build environment properties
23 def localProps = "${jalviewDir}/local.properties"
24 if (file(localProps).exists()) {
26 def p = new Properties()
27 def localPropsFIS = new FileInputStream(localProps)
32 def over = getProperty(key) != null
35 println("Overriding property '${key}' with local.properties value '${val}'")
38 } catch (Exception e) {
39 System.out.println("Exception reading local.properties")
53 compile 'org.apache.commons:commons-compress:1.18'
56 mainClassName = launcherClass
57 def cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
58 def classes = "${jalviewDir}/${classesDir}"
60 if (clover.equals("true")) {
62 classes = "${buildDir}/${cloverClassesDir}"
65 classes = "${jalviewDir}/${classesDir}"
68 // configure classpath/args for j8/j11 compilation
70 def jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
73 def compile_source_compatibility
74 def compile_target_compatibility
77 getdownWebsiteDir = "${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}"
79 reportRsyncCmd = false
81 buildProperties = buildPropertiesFile
82 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}"
86 // TODO: get bamboo build artifact URL for getdown artifacts
87 getdown_channel_base = bamboo_channelbase
88 getdown_channel_name = "${bamboo_planKey}/${JAVA_VERSION}"
89 getdown_app_base = "${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}"
90 getdown_app_dir = getdown_app_dir_alt
91 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
95 getdown_channel_name = CHANNEL.toLowerCase()
96 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
97 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
98 getdown_app_dir = getdown_app_dir_release
99 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
100 reportRsyncCommand = true
104 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
105 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
106 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
107 getdown_app_dir = getdown_app_dir_alt
108 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
109 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
112 packageDir = "${ARCHIVEDIR}/${packageDir}"
113 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
116 reportRsyncCommand = true
120 getdown_channel_name = "archive/${JALVIEW_VERSION}"
121 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
122 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
123 getdown_app_dir = getdown_app_dir_alt
124 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
125 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
128 packageDir = "${ARCHIVEDIR}/${packageDir}"
129 buildProperties = "${ARCHIVEDIR}/${classesDir}/${buildPropertiesFile}"
132 reportRsyncCommand = true
133 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
137 getdown_channel_name = CHANNEL.toLowerCase()
138 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
139 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
140 getdown_app_dir = getdown_app_dir_alt
141 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
142 reportRsyncCommand = true
146 getdown_channel_name = CHANNEL.toLowerCase()
147 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
148 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
149 getdown_app_dir = getdown_app_dir_alt
150 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
151 reportRsyncCommand = true
154 case ~/^SCRATCH(|-[-\w]*)$/:
155 getdown_channel_name = CHANNEL
156 getdownDir = "${getdown_channel_name}/${JAVA_VERSION}"
157 getdown_app_base = "${getdown_channel_base}/${getdownDir}"
158 getdown_app_dir = getdown_app_dir_alt
159 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
160 reportRsyncCommand = true
164 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
165 getdown_app_dir = getdown_app_dir_alt
166 buildProperties = "${jalviewDir}/${classesDir}/${buildPropertiesFile}"
167 getdownLauncher = "${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}"
170 default: // something wrong specified
171 print("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
177 getdownAppDir = "${getdownWebsiteDir}/${getdown_app_dir}"
178 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
179 getdownResourceDir = "${getdownWebsiteDir}/${getdown_resource_dir}"
180 getdownInstallDir = "${getdownWebsiteDir}/${getdown_install_dir}"
181 getdownFilesDir = "${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/"
182 getdownFilesInstallDir = "${getdownFilesDir}/${getdown_install_dir}"
183 /* compile without modules -- using classpath libraries
184 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
185 modules_runtimeClasspath = modules_compileClasspath
190 println("Using a ${CHANNEL} profile.")
193 def JAVA_INTEGER_VERSION
194 def additional_compiler_args = []
195 // these are getdown.txt properties defined dependent on the JAVA_VERSION
196 def getdown_alt_java_min_version
197 def getdown_alt_java_max_version
198 // this property is assigned below and expanded to multiple lines in the getdown task
199 def getdown_alt_multi_java_location
200 // this property is for the Java library used in eclipse
201 def eclipse_java_runtime_name
202 if (JAVA_VERSION.equals("1.8")) {
203 JAVA_INTEGER_VERSION = "8"
206 libDistDir = j8libDir
207 compile_source_compatibility = 1.8
208 compile_target_compatibility = 1.8
209 getdown_alt_java_min_version = getdown_alt_java8_min_version
210 getdown_alt_java_max_version = getdown_alt_java8_max_version
211 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
212 eclipse_java_runtime_name = "JavaSE-1.8"
213 } else if (JAVA_VERSION.equals("11")) {
214 JAVA_INTEGER_VERSION = "11"
216 libDistDir = j11libDir
217 compile_source_compatibility = 11
218 compile_target_compatibility = 11
219 getdown_alt_java_min_version = getdown_alt_java11_min_version
220 getdown_alt_java_max_version = getdown_alt_java11_max_version
221 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
222 eclipse_java_runtime_name = "JavaSE-11"
223 /* compile without modules -- using classpath libraries
224 additional_compiler_args += [
225 '--module-path', ext.modules_compileClasspath.asPath,
226 '--add-modules', j11modules
229 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
230 JAVA_INTEGER_VERSION = JAVA_VERSION
232 libDistDir = j11libDir
233 compile_source_compatibility = JAVA_VERSION
234 compile_target_compatibility = JAVA_VERSION
235 getdown_alt_java_min_version = getdown_alt_java11_min_version
236 getdown_alt_java_max_version = getdown_alt_java11_max_version
237 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
238 eclipse_java_runtime_name = "JavaSE-11"
239 /* compile without modules -- using classpath libraries
240 additional_compiler_args += [
241 '--module-path', ext.modules_compileClasspath.asPath,
242 '--add-modules', j11modules
246 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
253 srcDirs "${jalviewDir}/${sourceDir}"
254 outputDir = file("${classes}")
258 srcDirs "${jalviewDir}/${resourceDir}"
261 jar.destinationDir = file("${jalviewDir}/${packageDir}")
263 compileClasspath = files(sourceSets.main.java.outputDir)
264 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
266 runtimeClasspath = compileClasspath
271 srcDirs = [ cloverInstrDir ]
272 outputDir = file("${buildDir}/${cloverClassesDir}")
276 srcDirs = sourceSets.main.resources.srcDirs
278 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
279 compileClasspath += files(sourceSets.main.java.outputDir)
280 compileClasspath += sourceSets.main.compileClasspath
281 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
282 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
284 runtimeClasspath = compileClasspath
289 srcDirs "${jalviewDir}/${testSourceDir}"
290 outputDir = file("${jalviewDir}/${testOutputDir}")
294 srcDirs = sourceSets.main.resources.srcDirs
297 compileClasspath = files( sourceSets.test.java.outputDir )
300 compileClasspath += sourceSets.clover.compileClasspath
302 compileClasspath += files(sourceSets.main.java.outputDir)
305 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
306 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
307 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
309 runtimeClasspath = compileClasspath
316 cloverCompile 'org.openclover:clover:4.3.1'
317 testCompile 'org.openclover:clover:4.3.1'
323 cloverRuntime.extendsFrom cloverCompile
328 name = eclipse_project_name
330 natures 'org.eclipse.jdt.core.javanature',
331 'org.eclipse.jdt.groovy.core.groovyNature',
332 'org.eclipse.buildship.core.gradleprojectnature'
334 buildCommand 'org.eclipse.jdt.core.javabuilder'
335 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
339 //defaultOutputDir = sourceSets.main.java.outputDir
342 if (it.isCanBeResolved()) {
347 minusConfigurations += removeThese
348 plusConfigurations = [ ]
352 def removeTheseToo = []
353 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
354 cp.entries.each { entry ->
355 if (entry.kind == 'src') {
356 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == sourceDir || entry.path == testSourceDir)) {
357 removeTheseToo += entry
359 alreadyAddedSrcPath.putAt(entry.path, true)
363 cp.entries.removeAll(removeTheseToo)
365 if (file("${jalviewDir}/${eclipse_bin_dir}/main").isDirectory()) {
366 cp.entries += new Output("${eclipse_bin_dir}/main")
368 if (file(helpParentDir).isDirectory()) {
369 cp.entries += new Library(fileReference(helpParentDir))
371 if (file(resourceDir).isDirectory()) {
372 cp.entries += new Library(fileReference(resourceDir))
375 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
377 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
378 //don't want to add outputDir as eclipse is using its own output dir in bin/main
379 if (it.isDirectory() || ! it.exists()) {
380 // don't add dirs to classpath
383 def itPath = it.toString()
384 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
385 // make relative path
386 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
388 if (alreadyAddedLibPath.get(itPath)) {
389 //println("Not adding duplicate entry "+itPath)
391 //println("Adding entry "+itPath)
392 cp.entries += new Library(fileReference(itPath))
393 alreadyAddedLibPath.put(itPath, true)
397 //fileTree(dir: "$jalviewDir/$utilsDir", include: ["test*/*.jar"]).each {
398 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.each {
399 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
400 if (it.isDirectory() || ! it.exists()) {
401 // don't add dirs to classpath
402 return false // groovy "break" in .each closure
404 def itPath = it.toString()
405 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
406 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
408 if (alreadyAddedLibPath.get(itPath)) {
411 def lib = new Library(fileReference(itPath))
412 lib.entryAttributes["test"] = "true"
414 alreadyAddedLibPath.put(itPath, true)
422 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
427 // for the IDE, use java 11 compatibility
428 sourceCompatibility = compile_source_compatibility
429 targetCompatibility = compile_target_compatibility
430 javaRuntimeName = eclipse_java_runtime_name
432 // add in jalview project specific properties/preferences into eclipse core preferences
434 withProperties { props ->
435 def jalview_prefs = new Properties()
436 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
437 jalview_prefs.load(ins)
439 jalview_prefs.forEach { t, v ->
440 if (props.getAt(t) == null) {
452 // only instrument source, we build test classes as normal
453 inputs.files files (sourceSets.main.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
454 outputs.dir cloverInstrDir
457 delete cloverInstrDir
458 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
459 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
460 argsList.addAll(inputs.files.files.collect({ file ->
463 String[] args = argsList.toArray()
464 println("About to instrument "+args.length +" files")
465 com.atlassian.clover.CloverInstr.mainImpl(args)
471 group = "Verification"
472 description = "Createst the Clover report"
473 inputs.dir "${buildDir}/clover"
474 outputs.dir "${reportsDir}/clover"
476 file("${buildDir}/clover/clover.db").exists()
479 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
480 "-o", "${reportsDir}/clover"]
481 String[] args = argsList.toArray()
482 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
484 // and generate ${reportsDir}/clover/clover.xml
485 args = ["--initstring", "${buildDir}/clover/clover.db",
486 "-o", "${reportsDir}/clover/clover.xml"].toArray()
487 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
497 sourceCompatibility = compile_source_compatibility
498 targetCompatibility = compile_target_compatibility
499 options.compilerArgs = additional_compiler_args
500 print ("Setting target compatibility to "+targetCompatibility+"\n")
507 dependsOn compileCloverJava
508 classpath += configurations.cloverRuntime
510 classpath += sourceSets.main.runtimeClasspath
513 sourceCompatibility = compile_source_compatibility
514 targetCompatibility = compile_target_compatibility
515 options.compilerArgs = additional_compiler_args
516 print ("Setting target compatibility to "+targetCompatibility+"\n")
524 sourceCompatibility = compile_source_compatibility
525 targetCompatibility = compile_target_compatibility
526 options.compilerArgs += additional_compiler_args
527 print ("Setting target compatibility to "+targetCompatibility+"\n")
529 classpath += configurations.cloverRuntime
534 delete sourceSets.main.java.outputDir
540 delete sourceSets.test.java.outputDir
541 delete cloverInstrDir
545 // format is a string like date.format("dd MMMM yyyy")
546 def getDate(format) {
547 def date = new Date()
548 return date.format(format)
552 def hashStdOut = new ByteArrayOutputStream()
554 commandLine "git", "rev-parse", "--short", "HEAD"
555 standardOutput = hashStdOut
559 def branchStdOut = new ByteArrayOutputStream()
561 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
562 standardOutput = branchStdOut
566 project.ext.gitHash = hashStdOut.toString().trim()
567 project.ext.gitBranch = branchStdOut.toString().trim()
569 outputs.upToDateWhen { false }
572 task createBuildProperties(type: WriteProperties) {
574 inputs.dir("${jalviewDir}/${sourceDir}")
575 inputs.dir("${classes}")
576 inputs.dir("${jalviewDir}/${resourceDir}")
577 outputFile (buildProperties)
578 // taking time specific comment out to allow better incremental builds
579 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
580 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
581 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
582 property "VERSION", JALVIEW_VERSION
583 property "INSTALLATION", INSTALLATION+" git-commit:"+project.ext.gitHash+" ["+project.ext.gitBranch+"]"
584 outputs.file(outputFile)
587 def buildingHTML = "${jalviewDir}/${docDir}/building.html"
588 task cleanBuildingHTML(type: Delete) {
594 task convertBuildingMD(type: Exec) {
595 dependsOn cleanBuildingHTML
596 def buildingMD = "${jalviewDir}/${docDir}/building.md"
597 def css = "${jalviewDir}/${docDir}/github.css"
600 pandoc_exec.split(",").each {
601 if (file(it.trim()).exists()) {
607 def hostname = "hostname".execute().text.trim()
608 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
609 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
613 if (pandoc != null && file(pandoc).exists()) {
614 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
616 println("Cannot find pandoc. Skipping convert building.md to HTML")
617 throw new StopExecutionException()
623 inputs.file(buildingMD)
625 outputs.file(buildingHTML)
634 task syncDocs(type: Sync) {
635 dependsOn convertBuildingMD
636 def syncDir = "${classes}/${docDir}"
637 from fileTree("${jalviewDir}/${docDir}")
642 def helpFile = "${classes}/${helpDir}/help.jhm"
644 task copyHelp(type: Copy) {
645 def inputDir = "${jalviewDir}/${helpParentDir}/${helpDir}"
646 def outputDir = "${classes}/${helpDir}"
651 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
661 outputs.files(helpFile)
662 outputs.dir(outputDir)
665 task syncLib(type: Sync) {
666 def syncDir = "${classes}/${libDistDir}"
667 from fileTree("${jalviewDir}/${libDistDir}")
671 task syncResources(type: Sync) {
672 from "${jalviewDir}/${resourceDir}"
681 dependsOn syncResources
687 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
690 dependsOn compileJava
692 dependsOn cloverInstr
696 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
700 includeGroups testngGroups
702 useDefaultListeners=true
705 workingDir = jalviewDir
706 //systemProperties 'clover.jar' System.properties.clover.jar
707 sourceCompatibility = compile_source_compatibility
708 targetCompatibility = compile_target_compatibility
709 jvmArgs += additional_compiler_args
713 task buildIndices(type: JavaExec) {
715 classpath = sourceSets.main.compileClasspath
716 main = "com.sun.java.help.search.Indexer"
717 workingDir = "${classes}/${helpDir}"
720 inputs.dir("${workingDir}/${argDir}")
722 outputs.dir("${classes}/doc")
723 outputs.dir("${classes}/help")
724 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
725 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
726 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
727 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
728 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
729 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
732 task compileLinkCheck(type: JavaCompile) {
734 classpath = files("${jalviewDir}/${utilsDir}")
735 destinationDir = file("${jalviewDir}/${utilsDir}")
736 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
738 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
739 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
740 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
741 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
744 task linkCheck(type: JavaExec) {
745 dependsOn prepare, compileLinkCheck
747 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
748 classpath = files("${jalviewDir}/${utilsDir}")
749 main = "HelpLinksChecker"
750 workingDir = jalviewDir
751 def help = "${classes}/${helpDir}"
752 args = [ "${classes}/${helpDir}", "-nointernet" ]
754 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
756 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
759 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
763 inputs.dir("${classes}/${helpDir}")
764 outputs.file(helpLinksCheckerOutFile)
767 // import the pubhtmlhelp target
768 ant.properties.basedir = "${jalviewDir}"
769 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes}/${helpDir}"
770 ant.importBuild "${utilsDir}/publishHelp.xml"
773 task cleanPackageDir(type: Delete) {
775 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
781 dependsOn buildIndices
782 dependsOn createBuildProperties
785 attributes "Main-Class": mainClass,
786 "Permissions": "all-permissions",
787 "Application-Name": "Jalview Desktop",
788 "Codebase": application_codebase
791 destinationDir = file("${jalviewDir}/${packageDir}")
792 archiveName = rootProject.name+".jar"
800 inputs.dir("${classes}")
801 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
804 task copyJars(type: Copy) {
805 from fileTree(dir: "${classes}", include: "**/*.jar").files
806 into "${jalviewDir}/${packageDir}"
809 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
810 task syncJars(type: Sync) {
811 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
812 into "${jalviewDir}/${packageDir}"
814 include jar.archiveName
820 description = "Put all required libraries in dist"
821 // order of "cleanPackageDir", "copyJars", "jar" important!
822 jar.mustRunAfter cleanPackageDir
823 syncJars.mustRunAfter cleanPackageDir
824 dependsOn cleanPackageDir
827 outputs.dir("${jalviewDir}/${packageDir}")
831 dependsOn cleanPackageDir
837 group = "distribution"
841 from ("${jalviewDir}/${libDistDir}") {
845 attributes 'Implementation-Version': JALVIEW_VERSION
847 mainClassName = shadowJarMainClass
849 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
853 task getdownWebsite() {
854 group = "distribution"
855 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
860 def getdownWebsiteResourceFilenames = []
861 def getdownTextString = ""
862 def getdownResourceDir = project.ext.getdownResourceDir
863 def getdownAppDir = project.ext.getdownAppDir
864 def getdownResourceFilenames = []
867 // clean the getdown website and files dir before creating getdown folders
868 delete project.ext.getdownWebsiteDir
869 delete project.ext.getdownFilesDir
873 rename(buildPropertiesFile, getdown_build_properties)
874 into project.ext.getdownAppDir
876 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
878 // go through properties looking for getdown_txt_...
879 def props = project.properties.sort { it.key }
880 if (getdown_alt_java_min_version.length() > 0) {
881 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
883 if (getdown_alt_java_max_version.length() > 0) {
884 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
886 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
888 props.put("getdown_txt_appbase", getdown_app_base)
889 props.each{ prop, val ->
890 if (prop.startsWith("getdown_txt_") && val != null) {
891 if (prop.startsWith("getdown_txt_multi_")) {
892 def key = prop.substring(18)
893 val.split(",").each{ v ->
894 def line = "${key} = ${v}\n"
895 getdownTextString += line
898 // file values rationalised
899 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
901 if (val.indexOf('/') == 0) {
904 } else if (val.indexOf('/') > 0) {
905 // relative path (relative to jalviewDir)
906 r = file( "${jalviewDir}/${val}" )
909 val = "${getdown_resource_dir}/" + r.getName()
910 getdownWebsiteResourceFilenames += val
911 getdownResourceFilenames += r.getPath()
914 if (! prop.startsWith("getdown_txt_resource")) {
915 def line = prop.substring(12) + " = ${val}\n"
916 getdownTextString += line
922 getdownWebsiteResourceFilenames.each{ filename ->
923 getdownTextString += "resource = ${filename}\n"
925 getdownResourceFilenames.each{ filename ->
928 into project.ext.getdownResourceDir
933 fileTree(file(packageDir)).each{ f ->
934 if (f.isDirectory()) {
935 def files = fileTree(dir: f, include: ["*"]).getFiles()
937 } else if (f.exists()) {
941 codeFiles.sort().each{f ->
942 def name = f.getName()
943 def line = "code = ${getdown_app_dir}/${name}\n"
944 getdownTextString += line
947 into project.ext.getdownAppDir
951 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
953 if (JAVA_VERSION.equals("11")) {
954 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
955 j11libFiles.sort().each{f ->
956 def name = f.getName()
957 def line = "code = ${getdown_j11lib_dir}/${name}\n"
958 getdownTextString += line
961 into project.ext.getdownJ11libDir
967 // 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.
968 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
969 getdownTextString += "resource = ${getdown_launcher_new}\n"
970 getdownTextString += "class = ${mainClass}\n"
972 def getdown_txt = file("${project.ext.getdownWebsiteDir}/getdown.txt")
973 getdown_txt.write(getdownTextString)
975 def launch_jvl = file("${project.ext.getdownWebsiteDir}/${getdown_launch_jvl}")
976 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
980 rename(file(getdownLauncher).getName(), getdown_launcher_new)
981 into project.ext.getdownWebsiteDir
986 if (file(getdownLauncher).getName() != getdown_launcher) {
987 rename(file(getdownLauncher).getName(), getdown_launcher)
989 into project.ext.getdownWebsiteDir
992 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
996 from "${getdownWebsiteDir}/${getdown_build_properties}"
997 if (file(getdownLauncher).getName() != getdown_launcher) {
998 rename(file(getdownLauncher).getName(), getdown_launcher)
1000 into getdownInstallDir
1004 from getdownInstallDir
1005 into getdownFilesInstallDir
1012 from getdownLauncher
1013 from "${getdownWebsiteDir}/${getdown_build_properties}"
1014 if (file(getdownLauncher).getName() != getdown_launcher) {
1015 rename(file(getdownLauncher).getName(), getdown_launcher)
1017 into getdownFilesDir
1021 from getdownResourceDir
1022 into "${project.ext.getdownFilesDir}/${getdown_resource_dir}"
1027 inputs.dir("${jalviewDir}/${packageDir}")
1029 outputs.dir(project.ext.getdownWebsiteDir)
1030 outputs.dir(project.ext.getdownFilesDir)
1033 task getdownDigest(type: JavaExec) {
1034 group = "distribution"
1035 description = "Digest the getdown website folder"
1036 dependsOn getdownWebsite
1038 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1040 main = "com.threerings.getdown.tools.Digester"
1041 args project.ext.getdownWebsiteDir
1042 inputs.dir(project.ext.getdownWebsiteDir)
1043 outputs.file("${project.ext.getdownWebsiteDir}/digest2.txt")
1047 group = "distribution"
1048 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1049 dependsOn getdownDigest
1051 if (reportRsyncCommand) {
1052 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1053 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1054 println "LIKELY RSYNC COMMAND:"
1055 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1056 if (RUNRSYNC == "true") {
1058 commandLine "mkdir", "-p", toDir
1061 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1070 delete project.ext.getdownWebsiteDir
1071 delete project.ext.getdownFilesDir
1076 def install4jHomeDir = "/opt/install4j"
1077 def hostname = "hostname".execute().text.trim()
1078 if (hostname.equals("jv-bamboo")) {
1079 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1080 } else if (OperatingSystem.current().isMacOsX()) {
1081 install4jHomeDir = '/Applications/install4j.app/Contents/Resources/app'
1082 if (! file(install4jHomeDir).exists()) {
1083 install4jHomeDir = System.getProperty("user.home")+install4jHomeDir
1085 } else if (OperatingSystem.current().isLinux()) {
1086 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1088 installDir = file(install4jHomeDir)
1089 mediaTypes = Arrays.asList(install4jMediaTypes.split(","))
1090 if (install4jFaster.equals("true")) {
1098 def windowsJavaVMDir
1099 def windowsJavaVMTgz
1100 def install4jDir = "${jalviewDir}/${install4jResourceDir}"
1101 def install4jConfFile = "jalview-installers-java${JAVA_VERSION}.install4j"
1102 install4jConf = "${install4jDir}/${install4jConfFile}"
1104 task copyInstall4jTemplate(type: Copy) {
1105 macosJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre"
1106 macosJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz"
1107 windowsJavaVMDir = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre"
1108 windowsJavaVMTgz = "${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz"
1109 from (install4jDir) {
1110 include install4jTemplate
1111 rename (install4jTemplate, install4jConfFile)
1112 filter(ReplaceTokens, beginToken: '', endToken: '', tokens: ['9999999999': JAVA_VERSION])
1113 filter(ReplaceTokens, beginToken: '$$', endToken: '$$',
1115 'JAVA_VERSION': JAVA_VERSION,
1116 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1117 'VERSION': JALVIEW_VERSION,
1118 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1119 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1120 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1121 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1122 'INSTALL4JINFOPLISTFILEASSOCIATIONS': install4jInfoPlistFileAssociations,
1123 'COPYRIGHT_MESSAGE': install4jCopyrightMessage,
1124 'MACOS_BUNDLE_ID': install4jMacOSBundleId,
1125 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1126 'GETDOWN_DIST_DIR': getdown_app_dir,
1127 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1128 'GETDOWN_INSTALL_DIR': getdown_install_dir
1131 if (OSX_KEYPASS=="") {
1132 filter(ReplaceTokens, beginToken: 'codeSigning macEnabled="', endToken: '"', tokens: ['true':'codeSigning macEnabled="false"'])
1133 filter(ReplaceTokens, beginToken: 'runPostProcessor="true" ',endToken: 'Processor', tokens: ['post':'runPostProcessor="false" postProcessor'])
1137 outputs.files(install4jConf)
1140 // include file associations in installer
1141 def installerFileAssociationsXml = file("${install4jDir}/${install4jInstallerFileAssociations}").text
1145 match: '<action name="EXTENSIONS_REPLACED_BY_GRADLE".*?</action>',
1146 replace: installerFileAssociationsXml,
1150 // include uninstaller applescript app files in dmg
1151 def installerDMGUninstallerXml = file("$install4jDir/$install4jDMGUninstallerAppFiles").text
1155 match: '<file name="UNINSTALL_OLD_JALVIEW_APP_REPLACED_IN_GRADLE" file=.*?>',
1156 replace: installerDMGUninstallerXml,
1163 task installers(type: com.install4j.gradle.Install4jTask) {
1164 group = "distribution"
1165 description = "Create the install4j installers"
1167 dependsOn copyInstall4jTemplate
1168 projectFile = file(install4jConf)
1169 variables = [majorVersion: version.substring(2, 11), build: 001, OSX_KEYSTORE: OSX_KEYSTORE, JSIGN_SH: JSIGN_SH]
1170 destination = "${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}"
1171 buildSelected = true
1174 macKeystorePassword=OSX_KEYPASS
1178 println("Using projectFile "+projectFile)
1181 inputs.dir(project.ext.getdownWebsiteDir)
1182 inputs.file(install4jConf)
1183 inputs.dir(macosJavaVMDir)
1184 inputs.dir(windowsJavaVMDir)
1185 outputs.dir("${jalviewDir}/${install4jBuildDir}/${JAVA_VERSION}")
1190 delete install4jConf
1194 task sourceDist (type: Tar) {
1196 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1197 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1198 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1200 archiveFileName = outputFileName
1201 } catch (Exception e) {
1202 archiveName = outputFileName
1205 compression Compression.GZIP
1209 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1214 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1216 ,"utils/InstallAnywhere"]
1217 def PROCESS_FILES=[ "AUTHORS",
1225 "THIRDPARTYLIBS","TESTNG",
1227 "gradle.properties",
1238 exclude (EXCLUDE_FILES)
1239 include (PROCESS_FILES)
1240 filter(ReplaceTokens, beginToken: '$$', endToken: '$$', tokens: ['Version-Rel': JALVIEW_VERSION,'Year-Rel': getDate("yyyy")])
1243 exclude (EXCLUDE_FILES)
1244 exclude (PROCESS_FILES)
1245 exclude ("appletlib")
1246 exclude ("**/*locales")
1247 exclude ("*locales/**")
1248 exclude ("utils/InstallAnywhere")
1250 exclude (getdown_files_dir)
1251 exclude (getdown_website_dir)
1253 // exluding these as not using jars as modules yet
1254 exclude ("${j11modDir}/**/*.jar")
1256 // from (jalviewDir) {
1257 // // explicit includes for stuff that seemed to not get included
1258 // include(fileTree("test/**/*."))
1259 // exclude(EXCLUDE_FILES)
1260 // exclude(PROCESS_FILES)
1266 dependsOn pubhtmlhelp
1268 inputs.dir("${classes}/${helpDir}")
1269 outputs.dir("${helpOutputDir}")
1272 def jalviewjsBuildDir
1273 def jalviewjsSiteDir
1274 def jalviewjsTransferSiteDir
1275 task jalviewjsSitePath {
1276 def relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
1277 jalviewjsBuildDir = "${relativeBuildDir}/jalviewjs"
1278 jalviewjsSiteDir = "${jalviewjsBuildDir}/${jalviewjs_site_dir}"
1279 jalviewjsTransferSiteDir = "${jalviewjsBuildDir}/tmp/site"
1282 def eclipseWorkspace
1283 task jalviewjsSetEclipseWorkspace {
1284 def propKey = "jalviewjs_eclipse_workspace"
1286 if (project.hasProperty(propKey)) {
1287 propVal = project.getProperty(propKey)
1288 if (propVal.startsWith("~/")) {
1289 propVal = System.getProperty("user.home") + propVal.substring(1)
1292 def propsFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_workspace_location_file}"
1293 def propsFile = file(propsFileName)
1294 def eclipseWsDir = propVal
1295 def props = new Properties()
1297 if (( eclipseWsDir == null || !file(eclipseWsDir).exists() ) && propsFile.exists()) {
1298 def ins = new FileInputStream(propsFileName)
1301 if (props.getProperty(propKey, null) != null) {
1302 eclipseWsDir = props.getProperty(propKey)
1306 def writeProps = false
1307 if (eclipseWsDir == null || !file(eclipseWsDir).exists()) {
1308 def tempDir = File.createTempDir()
1309 eclipseWsDir = tempDir.getAbsolutePath()
1312 eclipseWorkspace = file(eclipseWsDir)
1316 props.setProperty(propKey, eclipseWsDir)
1317 propsFile.parentFile.mkdirs()
1318 def bytes = new ByteArrayOutputStream()
1319 props.store(bytes, null)
1320 def propertiesString = bytes.toString()
1321 propsFile.text = propertiesString
1324 println("ECLIPSE WORKSPACE: "+eclipseWorkspace.getPath())
1327 inputs.property(propKey, eclipseWsDir)
1328 outputs.file(propsFileName)
1334 def eclipseDebug = false
1335 def eclipseVersionSuffix = ""
1336 task jalviewjsEclipsePaths {
1339 def eclipseRoot = jalviewjs_eclipse_root
1340 if (eclipseRoot.startsWith("~/")) {
1341 eclipseRoot = System.getProperty("user.home") + eclipseRoot.substring(1)
1343 if (OperatingSystem.current().isMacOsX()) {
1344 eclipseRoot += "/Eclipse.app"
1345 eclipseBinary = "${eclipseRoot}/Contents/MacOS/eclipse"
1346 eclipseProduct = "${eclipseRoot}/Contents/Eclipse/.eclipseproduct"
1347 } else if (OperatingSystem.current().isWindows()) { // check these paths!!
1348 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1349 eclipseRoot += "/eclipse"
1351 eclipseBinary = "${eclipseRoot}/eclipse"
1352 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1353 } else { // linux or unix
1354 if (file("${eclipseRoot}/eclipse").isDirectory() && file("${eclipseRoot}/eclipse/.eclipseproduct").exists()) {
1355 eclipseRoot += "/eclipse"
1357 eclipseBinary = "${eclipseRoot}/eclipse"
1358 eclipseProduct = "${eclipseRoot}/.eclipseproduct"
1361 eclipseVersion = "4.12" // default
1362 def assumedVersion = true
1363 if (file(eclipseProduct).exists()) {
1364 def fis = new FileInputStream(eclipseProduct)
1365 def props = new Properties()
1367 eclipseVersion = props.getProperty("version")
1369 assumedVersion = false
1372 String[] v = eclipseVersion.split("\\.")
1373 def v0 = Integer.valueOf(v[0])
1374 def v1 = Integer.valueOf(v[1])
1375 if (v0 < 4 || ( v0 == 4 && v1 < 13 )) {
1376 eclipseVersionSuffix = "_4.12"
1378 eclipseVersionSuffix = "_4.13"
1383 def propKey = "eclipse_debug"
1384 eclipseDebug = (project.hasProperty(propKey) && project.getProperty(propKey).equals("true"))
1387 if (!assumedVersion) {
1388 println("ECLIPSE VERSION=${eclipseVersion}")
1394 dependsOn eclipseProject
1395 dependsOn eclipseClasspath
1396 dependsOn eclipseJdt
1399 /* using the Copy task below
1400 task OLDjalviewjsEclipseCopyDropins {
1401 dependsOn jalviewjsEclipsePaths
1402 dependsOn jalviewjsCleanEclipse
1403 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1404 inputFiles += file(jalviewjs_j2s_plugin)
1405 def outputDir = "${buildDir}/jalviewjs
1407 inputs.files inputFiles
1408 inputFiles.each { file ->
1409 outputs.file("${outputDir}/${file.name}")
1413 inputFiles.each { file ->
1423 // this version (type: Copy) will delete anything in the eclipse dropins folder that isn't in fromDropinsDir
1424 task jalviewjsEclipseCopyDropins(type: Copy) {
1425 dependsOn jalviewjsEclipsePaths
1427 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar")
1428 inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}")
1429 def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}"
1435 // this eclipse -clean doesn't actually work
1436 task jalviewjsCleanEclipse(type: Exec) {
1437 dependsOn eclipseSetup
1438 dependsOn jalviewjsEclipsePaths
1439 dependsOn jalviewjsEclipseCopyDropins
1441 executable(eclipseBinary)
1442 args(["-nosplash", "--launcher.suppressErrors", "-data", eclipseWorkspace.getPath(), "-clean", "-console", "-consoleLog"])
1448 def inputString = """exit
1451 def inputByteStream = new ByteArrayInputStream(inputString.getBytes())
1452 standardInput = inputByteStream
1454 /* not really working yet
1455 jalviewjsEclipseCopyDropins.finalizedBy jalviewjsCleanEclipse
1458 task jalviewjsUnzipFiles {
1459 dependsOn jalviewjsSitePath
1461 def zipFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_libjs_dir}", include: "*.zip")
1462 zipFiles += "${jalviewDir}/${jalviewjs_swingjs_zip}"
1465 zipFiles.each { file_zip ->
1467 from zipTree(file_zip)
1468 into "${jalviewDir}/${jalviewjsSiteDir}"
1473 inputs.files zipFiles
1474 outputs.dir "${jalviewDir}/${jalviewjsSiteDir}"
1477 task jalviewjsCreateJ2sSettings(type: WriteProperties) {
1479 description "Create the .j2s file from the j2s.* properties"
1481 dependsOn jalviewjsSitePath
1483 outputFile ("${jalviewDir}/${jalviewjs_j2s_settings}")
1484 def j2s_props = project.properties.findAll { it.key.startsWith("j2s.") }.sort { it.key }
1485 def siteDirProperty = "j2s.site.directory"
1486 def setSiteDir = false
1487 j2s_props.each { prop, val ->
1489 if (prop == siteDirProperty) {
1490 if (!(val.startsWith('/') || val.startsWith("file://") )) {
1491 val = "${jalviewDir}/${jalviewjsTransferSiteDir}/${val}"
1497 if (!setSiteDir) { // default site location, don't override specifically set property
1498 property(siteDirProperty,"${jalviewDir}/${jalviewjsTransferSiteDir}")
1501 inputs.properties(j2s_props)
1502 outputs.file(outputFile)
1505 task jalviewjsEclipseSetup {
1506 dependsOn jalviewjsEclipseCopyDropins
1507 dependsOn jalviewjsSetEclipseWorkspace
1508 dependsOn jalviewjsCreateJ2sSettings
1511 task jalviewjsCopyResources (type: Sync) {
1512 dependsOn jalviewjsSitePath
1513 def inputFiles = fileTree(dir: "${jalviewDir}/${resourceDir}")
1514 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}/${jalviewjs_j2s_subdir}"
1518 def outputFiles = []
1519 rename { filename ->
1520 outputFiles += "${outputDir}/${filename}"
1526 outputs.files outputFiles
1527 inputs.files inputFiles
1530 task jalviewjsCopySiteResources (type: Sync) {
1531 dependsOn jalviewjsSitePath
1532 def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_site_resource_dir}")
1533 def outputDir = "${jalviewDir}/${jalviewjsSiteDir}"
1537 def outputFiles = []
1538 rename { filename ->
1539 outputFiles += "${outputDir}/${filename}"
1545 outputs.files outputFiles
1546 inputs.files inputFiles
1549 task jalviewjsProjectImport(type: Exec) {
1550 dependsOn eclipseSetup
1551 dependsOn jalviewjsEclipsePaths
1552 dependsOn jalviewjsEclipseSetup
1554 def projdir = eclipseWorkspace.getPath()+"/.metadata/.plugins/org.eclipse.core.resources/.projects/jalview/org.eclipse.jdt.core"
1555 executable(eclipseBinary)
1556 args(["-nosplash", "--launcher.suppressErrors", "-application", "com.seeq.eclipse.importprojects.headlessimport", "-data", eclipseWorkspace.getPath(), "-import", jalviewDirAbsolutePath])
1560 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1562 inputs.file("${jalviewDir}/.project")
1563 outputs.upToDateWhen { file(projdir).exists() }
1566 task jalviewjsTranspile(type: Exec) {
1567 dependsOn jalviewjsEclipseSetup
1568 dependsOn jalviewjsProjectImport
1569 dependsOn jalviewjsEclipsePaths
1571 executable(eclipseBinary)
1572 args(["-nosplash", "--launcher.suppressErrors", "-application", "org.eclipse.jdt.apt.core.aptBuild", "-data", eclipseWorkspace, "-${jalviewjs_eclipse_build_arg}", eclipse_project_name ])
1576 args += [ "--launcher.appendVmargs", "-vmargs", "-Dorg.eclipse.equinox.p2.reconciler.dropins.directory=${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" ]
1581 stdout = new ByteArrayOutputStream()
1582 stderr = new ByteArrayOutputStream()
1584 def logOutFileName = "${jalviewDirAbsolutePath}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}"
1585 def logOutFile = file(logOutFileName)
1586 logOutFile.createNewFile()
1587 logOutFile.text = """ROOT: ${jalviewjs_eclipse_root}
1588 BINARY: ${eclipseBinary}
1589 VERSION: ${eclipseVersion}
1590 WORKSPACE: ${eclipseWorkspace}
1591 DEBUG: ${eclipseDebug}
1594 def logOutFOS = new FileOutputStream(logOutFile, true) // true == append
1595 //def logErrFileName = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stderr}"
1596 //def logErrFile = file(logFileName)
1597 //logErrFile.createNewFile()
1598 //def logErrFOS = new FileErrputStream(logErrFile, false)
1599 // combine stdout and stderr
1600 def logErrFOS = logOutFOS
1602 if (jalviewjs_j2s_to_console.equals("true")) {
1603 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1604 new org.apache.tools.ant.util.TeeOutputStream(
1608 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1609 new org.apache.tools.ant.util.TeeOutputStream(
1614 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1617 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1624 if (stdout.toString().contains("Error processing ")) {
1625 // j2s did not complete transpile
1626 throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_stdout}'")
1630 inputs.dir("${jalviewDir}/${sourceDir}")
1631 outputs.dir("${jalviewDir}/${jalviewjsTransferSiteDir}")
1632 outputs.upToDateWhen( { file("${jalviewDir}/${jalviewjsTransferSiteDir}${jalviewjs_server_resource}").exists() } )
1635 task jalviewjsCopyTransferSite(type: Copy) {
1636 dependsOn jalviewjsTranspile
1637 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1638 into "${jalviewDir}/${jalviewjsSiteDir}"
1641 jalviewjsUnzipFiles.mustRunAfter jalviewjsCopyTransferSite
1642 jalviewjsCopyResources.mustRunAfter jalviewjsCopyTransferSite
1643 jalviewjsCopySiteResources.mustRunAfter jalviewjsCopyTransferSite
1645 task jalviewjsPrepareSite {
1647 description "Prepares the website folder including unzipping files and copying resources"
1648 dependsOn jalviewjsSitePath
1649 dependsOn jalviewjsUnzipFiles
1650 dependsOn jalviewjsCopyResources
1651 dependsOn jalviewjsCopySiteResources
1654 task jalviewjsBuildSite {
1656 description "Builds the whole website including transpiled code"
1657 dependsOn jalviewjsCopyTransferSite
1658 dependsOn jalviewjsPrepareSite
1661 task cleanJalviewjsSite {
1663 delete "${jalviewDir}/${jalviewjsTransferSiteDir}"
1664 delete "${jalviewDir}/${jalviewjsSiteDir}"
1668 task jalviewjsSiteTar(type: Tar) {
1670 description "Creates a tar.gz file for the website"
1671 dependsOn jalviewjsBuildSite
1672 def outputFilename = "jalviewjs-site-${JALVIEW_VERSION}.tar.gz"
1674 archiveFileName = outputFilename
1675 } catch (Exception e) {
1676 archiveName = outputFilename
1679 compression Compression.GZIP
1681 from "${jalviewDir}/${jalviewjsSiteDir}"
1682 into jalviewjs_site_dir // this is inside the tar file
1684 inputs.dir("${jalviewDir}/${jalviewjsSiteDir}")
1687 task jalviewjsServer {
1689 def filename = "jalviewjsTest.html"
1690 description "Starts a webserver on localhost to test the website. See ${filename} to access local site on most recently used port."
1691 dependsOn jalviewjsSitePath
1692 def htmlFile = "${jalviewDirAbsolutePath}/${filename}"
1695 SimpleHttpFileServerFactory factory = new SimpleHttpFileServerFactory()
1696 def port = Integer.valueOf(jalviewjs_server_port)
1700 while(port < start+1000 && !running) {
1702 def doc_root = new File("${jalviewDirAbsolutePath}/${jalviewjsSiteDir}")
1703 def jalviewjsServer = factory.start(doc_root, port)
1705 url = jalviewjsServer.getResourceUrl(jalviewjs_server_resource)
1706 println("SERVER STARTED with document root ${doc_root}.")
1707 println("Go to "+url+" . Run gradle --stop to stop (kills all gradle daemons).")
1708 println("For debug: "+url+"?j2sdebug")
1710 file(htmlFile).text = """
1711 <p><a href="${url}">Jalview JS Test. <${url}></a></p>
1712 <p><a href="${url}?j2sdebug">Jalview JS Test with debug. <${url}?j2sdebug<</a></p>
1715 } catch (Exception e) {
1722 outputs.file(htmlFile)
1723 outputs.upToDateWhen({false})
1726 task cleanJalviewjsAll {
1728 description "Delete all configuration and build artifacts to do with JalviewJS build"
1729 dependsOn cleanJalviewjsSite
1730 dependsOn jalviewjsEclipsePaths
1733 delete "${jalviewDir}/${jalviewjsBuildDir}"
1734 delete "${jalviewDir}/${eclipse_bin_dir}"
1735 if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) {
1736 delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata")
1738 delete "${jalviewDir}/${jalviewjs_j2s_settings}"
1741 outputs.upToDateWhen( { false } )
1746 description "Build the site"
1747 dependsOn jalviewjsBuildSite
1751 task jalviewjsIDE_CopyTransferSite(type: Copy) {
1752 from "${jalviewDir}/${jalviewjsTransferSiteDir}"
1753 into "${jalviewDir}/${jalviewjsSiteDir}"
1756 task jalviewjsIDE_j2s {
1757 group "00 JalviewJS in Eclipse"
1758 description "Creates the .j2s file"
1759 dependsOn jalviewjsCreateJ2sSettings
1762 task jalviewjsIDE_AssembleSite {
1763 group "00 JalviewJS in Eclipse"
1764 description "Assembles the Eclipse transpiled site and unzips supporting zipfiles"
1765 dependsOn jalviewjsIDE_CopyTransferSite
1766 dependsOn jalviewjsPrepareSite
1769 task jalviewjsIDE_SiteClean {
1770 group "00 JalviewJS in Eclipse"
1771 description "Deletes the Eclipse transpiled site"
1772 dependsOn cleanJalviewjsSite
1775 task jalviewjsIDE_Server {
1776 group "00 JalviewJS in Eclipse"
1777 description "Starts a webserver on localhost to test the website"
1778 dependsOn jalviewjsServer