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
5 import java.security.MessageDigest
6 import groovy.transform.ExternalizeMethods
7 import groovy.util.XmlParser
8 import groovy.xml.XmlUtil
12 classpath 'org.openclover:clover:4.4.1'
20 id 'com.github.johnrengelman.shadow' version '4.0.3'
21 id 'com.install4j.gradle' version '8.0.2'
22 id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
38 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
39 def string(Object o) {
40 return o == null ? "" : o.toString()
45 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
46 jalviewDirRelativePath = jalviewDir
48 // local build environment properties
49 def localProps = "${jalviewDirAbsolutePath}/local.properties"
50 if (file(localProps).exists()) {
52 def p = new Properties()
53 def localPropsFIS = new FileInputStream(localProps)
58 def oldval = findProperty(key)
61 println("Overriding property '${key}' ('${oldval}') with local.properties value '${val}'")
63 println("Setting unknown property '${key}' with local.properties value '${val}'")
66 } catch (Exception e) {
67 System.out.println("Exception reading local.properties")
71 // this property set when running Eclipse headlessly
72 j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
73 // this property set by Eclipse
74 eclipseApplicationProperty = string("eclipse.application")
75 // CHECK IF RUNNING FROM WITHIN ECLIPSE
76 def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
77 IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
78 // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
79 if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
80 println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
84 println("WITHIN ECLIPSE IDE")
86 println("HEADLESS BUILD")
89 System.properties.sort { it.key }.each {
90 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
93 if (false && IN_ECLIPSE) {
94 jalviewDir = jalviewDirAbsolutePath
99 bareSourceDir = string(source_dir)
100 sourceDir = string("${jalviewDir}/${bareSourceDir}")
101 resourceDir = string("${jalviewDir}/${resource_dir}")
102 bareTestSourceDir = string(test_source_dir)
103 testSourceDir = string("${jalviewDir}/${bareTestSourceDir}")
106 cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
107 classesDir = string("${jalviewDir}/${classes_dir}")
108 if (clover.equals("true")) {
110 classesDir = string("${buildDir}/${cloverClassesDir}")
113 classesDir = string("${jalviewDir}/${classes_dir}")
118 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
121 // the following values might be overridden by the CHANNEL switch
122 getdownChannelName = CHANNEL.toLowerCase()
123 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
124 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
125 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
126 getdownAppDistDir = getdown_app_dir_alt
127 buildProperties = string("${classesDir}/${build_properties_file}")
128 reportRsyncCmd = false
132 // TODO: get bamboo build artifact URL for getdown artifacts
133 getdown_channel_base = bamboo_channelbase
134 getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
135 getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
139 getdownAppDistDir = getdown_app_dir_release
140 reportRsyncCommand = true
144 getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
145 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
146 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
147 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
148 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
150 packageDir = string("${ARCHIVEDIR}/${packageDir}")
151 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
154 reportRsyncCommand = true
158 getdownChannelName = string("archive/${JALVIEW_VERSION}")
159 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
160 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
161 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
162 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
164 packageDir = string("${ARCHIVEDIR}/${packageDir}")
165 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
168 reportRsyncCommand = true
169 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
173 reportRsyncCommand = true
177 reportRsyncCommand = true
180 case ~/^SCRATCH(|-[-\w]*)$/:
181 getdownChannelName = CHANNEL
182 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
183 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
184 reportRsyncCommand = true
188 if (!file("${LOCALDIR}").exists()) {
189 throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
191 getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
192 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
197 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
198 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
201 default: // something wrong specified
202 throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
206 // override getdownAppBase if requested
207 if (findProperty("getdown_appbase_override") != null) {
208 getdownAppBase = string(getProperty("getdown_appbase_override"))
209 println("Overriding getdown appbase with '${getdownAppBase}'")
212 getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
213 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
214 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
215 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
216 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
217 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
218 /* compile without modules -- using classpath libraries
219 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
220 modules_runtimeClasspath = modules_compileClasspath
223 gitBranch = string("")
225 println("Using a ${CHANNEL} profile.")
227 additional_compiler_args = []
228 // configure classpath/args for j8/j11 compilation
229 if (JAVA_VERSION.equals("1.8")) {
230 JAVA_INTEGER_VERSION = string("8")
233 libDistDir = j8libDir
234 compile_source_compatibility = 1.8
235 compile_target_compatibility = 1.8
236 // these are getdown.txt properties defined dependent on the JAVA_VERSION
237 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
238 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
239 // this property is assigned below and expanded to multiple lines in the getdown task
240 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
241 // this property is for the Java library used in eclipse
242 eclipseJavaRuntimeName = string("JavaSE-1.8")
243 } else if (JAVA_VERSION.equals("11")) {
244 JAVA_INTEGER_VERSION = string("11")
246 libDistDir = j11libDir
247 compile_source_compatibility = 11
248 compile_target_compatibility = 11
249 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
250 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
251 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
252 eclipseJavaRuntimeName = string("JavaSE-11")
253 /* compile without modules -- using classpath libraries
254 additional_compiler_args += [
255 '--module-path', modules_compileClasspath.asPath,
256 '--add-modules', j11modules
259 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
260 JAVA_INTEGER_VERSION = JAVA_VERSION
262 libDistDir = j11libDir
263 compile_source_compatibility = JAVA_VERSION
264 compile_target_compatibility = JAVA_VERSION
265 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
266 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
267 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
268 eclipseJavaRuntimeName = string("JavaSE-11")
269 /* compile without modules -- using classpath libraries
270 additional_compiler_args += [
271 '--module-path', modules_compileClasspath.asPath,
272 '--add-modules', j11modules
276 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
281 JAVA_MIN_VERSION = JAVA_VERSION
282 JAVA_MAX_VERSION = JAVA_VERSION
283 def jreInstallsDir = string(jre_installs_dir)
284 if (jreInstallsDir.startsWith("~/")) {
285 jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
287 macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
288 macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
289 windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
290 windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
291 linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
292 linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
293 install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
294 install4jConfFileName = string("jalview-install4j-conf.install4j")
295 install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
296 install4jHomeDir = install4j_home_dir
297 if (install4jHomeDir.startsWith("~/")) {
298 install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
303 buildingHTML = string("${jalviewDir}/${docDir}/building.html")
304 helpFile = string("${classesDir}/${help_dir}/help.jhm")
305 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
306 helpSourceDir = string("${helpParentDir}/${help_dir}")
309 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
310 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
311 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
313 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
315 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
317 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
318 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
319 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
320 jalviewjsJalviewCoreHtmlFile = string("")
321 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
322 jalviewjsCoreClasslists = []
323 jalviewjsJalviewTemplateName = string(jalviewjs_name)
324 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
325 jalviewjsJ2sProps = null
327 eclipseWorkspace = null
328 eclipseBinary = string("")
329 eclipseVersion = string("")
339 outputDir = file(classesDir)
344 srcDirs += helpParentDir
347 jar.destinationDir = file("${jalviewDir}/${packageDir}")
349 compileClasspath = files(sourceSets.main.java.outputDir)
350 //compileClasspath += files(sourceSets.main.resources.srcDirs)
351 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
353 runtimeClasspath = compileClasspath
358 srcDirs = [ cloverInstrDir ]
359 outputDir = file("${buildDir}/${cloverClassesDir}")
363 srcDirs = sourceSets.main.resources.srcDirs
365 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
366 compileClasspath += files(sourceSets.main.java.outputDir)
367 compileClasspath += sourceSets.main.compileClasspath
368 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
369 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
371 runtimeClasspath = compileClasspath
376 srcDirs testSourceDir
377 outputDir = file("${jalviewDir}/${testOutputDir}")
381 srcDirs = sourceSets.main.resources.srcDirs
384 compileClasspath = files( sourceSets.test.java.outputDir )
387 compileClasspath = sourceSets.clover.compileClasspath
389 compileClasspath += files(sourceSets.main.java.outputDir)
392 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
393 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
394 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
396 runtimeClasspath = compileClasspath
404 cloverCompile 'org.openclover:clover:4.4.1'
405 testCompile 'org.openclover:clover:4.4.1'
412 cloverRuntime.extendsFrom cloverCompile
417 name = eclipse_project_name
419 natures 'org.eclipse.jdt.core.javanature',
420 'org.eclipse.jdt.groovy.core.groovyNature',
421 'org.eclipse.buildship.core.gradleprojectnature'
423 buildCommand 'org.eclipse.jdt.core.javabuilder'
424 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
428 //defaultOutputDir = sourceSets.main.java.outputDir
431 if (it.isCanBeResolved()) {
436 minusConfigurations += removeThese
437 plusConfigurations = [ ]
441 def removeTheseToo = []
442 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
443 cp.entries.each { entry ->
444 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
445 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
446 // we add the resources and help/help dirs in as libs afterwards (see below)
447 if (entry.kind == 'src') {
448 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
449 removeTheseToo += entry
451 alreadyAddedSrcPath.putAt(entry.path, true)
456 cp.entries.removeAll(removeTheseToo)
458 //cp.entries += new Output("${eclipse_bin_dir}/main")
459 if (file(helpParentDir).isDirectory()) {
460 cp.entries += new Library(fileReference(helpParentDir))
462 if (file(resourceDir).isDirectory()) {
463 cp.entries += new Library(fileReference(resourceDir))
466 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
468 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
469 //don't want to add outputDir as eclipse is using its own output dir in bin/main
470 if (it.isDirectory() || ! it.exists()) {
471 // don't add dirs to classpath, especially if they don't exist
472 return false // groovy "continue" in .any closure
474 def itPath = it.toString()
475 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
476 // make relative path
477 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
479 if (alreadyAddedLibPath.get(itPath)) {
480 //println("Not adding duplicate entry "+itPath)
482 //println("Adding entry "+itPath)
483 cp.entries += new Library(fileReference(itPath))
484 alreadyAddedLibPath.put(itPath, true)
488 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
489 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
490 if (it.isDirectory() || ! it.exists()) {
491 // don't add dirs to classpath
492 return false // groovy "continue" in .any closure
495 def itPath = it.toString()
496 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
497 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
499 if (alreadyAddedLibPath.get(itPath)) {
502 def lib = new Library(fileReference(itPath))
503 lib.entryAttributes["test"] = "true"
505 alreadyAddedLibPath.put(itPath, true)
513 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
518 // for the IDE, use java 11 compatibility
519 sourceCompatibility = compile_source_compatibility
520 targetCompatibility = compile_target_compatibility
521 javaRuntimeName = eclipseJavaRuntimeName
523 // add in jalview project specific properties/preferences into eclipse core preferences
525 withProperties { props ->
526 def jalview_prefs = new Properties()
527 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
528 jalview_prefs.load(ins)
530 jalview_prefs.forEach { t, v ->
531 if (props.getAt(t) == null) {
541 // Don't want these to be activated if in headless build
542 synchronizationTasks "eclipseSynchronizationTask"
543 autoBuildTasks "eclipseAutoBuildTask"
550 // only instrument source, we build test classes as normal
551 inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
552 outputs.dir cloverInstrDir
555 delete cloverInstrDir
556 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
557 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
558 argsList.addAll(inputs.files.files.collect({ file ->
561 String[] args = argsList.toArray()
562 println("About to instrument "+args.length +" files")
563 com.atlassian.clover.CloverInstr.mainImpl(args)
569 group = "Verification"
570 description = "Createst the Clover report"
571 inputs.dir "${buildDir}/clover"
572 outputs.dir "${reportsDir}/clover"
574 file("${buildDir}/clover/clover.db").exists()
577 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
578 "-o", "${reportsDir}/clover"]
579 String[] args = argsList.toArray()
580 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
582 // and generate ${reportsDir}/clover/clover.xml
583 args = ["--initstring", "${buildDir}/clover/clover.db",
584 "-o", "${reportsDir}/clover/clover.xml"].toArray()
585 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
594 sourceCompatibility = compile_source_compatibility
595 targetCompatibility = compile_target_compatibility
596 options.compilerArgs = additional_compiler_args
597 print ("Setting target compatibility to "+targetCompatibility+"\n")
605 dependsOn compileCloverJava
606 classpath += configurations.cloverRuntime
608 classpath += sourceSets.main.runtimeClasspath
611 sourceCompatibility = compile_source_compatibility
612 targetCompatibility = compile_target_compatibility
613 options.compilerArgs = additional_compiler_args
614 print ("Setting target compatibility to "+targetCompatibility+"\n")
622 sourceCompatibility = compile_source_compatibility
623 targetCompatibility = compile_target_compatibility
624 options.compilerArgs += additional_compiler_args
625 print ("Setting target compatibility to "+targetCompatibility+"\n")
627 classpath += configurations.cloverRuntime
633 delete sourceSets.main.java.outputDir
640 delete sourceSets.test.java.outputDir
641 delete cloverInstrDir
646 // format is a string like date.format("dd MMMM yyyy")
647 def getDate(format) {
648 def date = new Date()
649 return date.format(format)
654 def hashStdOut = new ByteArrayOutputStream()
656 commandLine "git", "rev-parse", "--short", "HEAD"
657 standardOutput = hashStdOut
661 def branchStdOut = new ByteArrayOutputStream()
663 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
664 standardOutput = branchStdOut
668 gitHash = hashStdOut.toString().trim()
669 gitBranch = branchStdOut.toString().trim()
671 outputs.upToDateWhen { false }
675 task createBuildProperties(type: WriteProperties) {
677 inputs.dir(sourceDir)
678 inputs.dir(resourceDir)
679 file(buildProperties).getParentFile().mkdirs()
680 outputFile (buildProperties)
681 // taking time specific comment out to allow better incremental builds
682 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
683 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
684 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
685 property "VERSION", JALVIEW_VERSION
686 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
687 outputs.file(outputFile)
691 task cleanBuildingHTML(type: Delete) {
698 task convertBuildingMD(type: Exec) {
699 dependsOn cleanBuildingHTML
700 def buildingMD = "${jalviewDir}/${docDir}/building.md"
701 def css = "${jalviewDir}/${docDir}/github.css"
704 pandoc_exec.split(",").each {
705 if (file(it.trim()).exists()) {
711 def hostname = "hostname".execute().text.trim()
712 def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
713 if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
714 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
718 if (pandoc != null && file(pandoc).exists()) {
719 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
721 println("Cannot find pandoc. Skipping convert building.md to HTML")
722 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
728 inputs.file(buildingMD)
730 outputs.file(buildingHTML)
741 task syncDocs(type: Sync) {
742 dependsOn convertBuildingMD
743 def syncDir = "${classesDir}/${docDir}"
744 from fileTree("${jalviewDir}/${docDir}")
750 task copyHelp(type: Copy) {
751 def inputDir = helpSourceDir
752 def outputDir = "${classesDir}/${help_dir}"
757 filter(ReplaceTokens,
761 'Version-Rel': JALVIEW_VERSION,
762 'Year-Rel': getDate("yyyy")
774 outputs.files(helpFile)
775 outputs.dir(outputDir)
779 task syncLib(type: Sync) {
780 def syncDir = "${classesDir}/${libDistDir}"
781 from fileTree("${jalviewDir}/${libDistDir}")
786 task syncResources(type: Sync) {
797 dependsOn syncResources
803 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
806 dependsOn compileJava
808 dependsOn cloverInstr
812 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
816 includeGroups testngGroups
818 useDefaultListeners=true
821 workingDir = jalviewDir
822 //systemProperties 'clover.jar' System.properties.clover.jar
823 sourceCompatibility = compile_source_compatibility
824 targetCompatibility = compile_target_compatibility
825 jvmArgs += additional_compiler_args
830 task buildIndices(type: JavaExec) {
832 classpath = sourceSets.main.compileClasspath
833 main = "com.sun.java.help.search.Indexer"
834 workingDir = "${classesDir}/${help_dir}"
837 inputs.dir("${workingDir}/${argDir}")
839 outputs.dir("${classesDir}/doc")
840 outputs.dir("${classesDir}/help")
841 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
842 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
843 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
844 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
845 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
846 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
850 task compileLinkCheck(type: JavaCompile) {
852 classpath = files("${jalviewDir}/${utilsDir}")
853 destinationDir = file("${jalviewDir}/${utilsDir}")
854 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
856 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
857 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
858 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
859 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
863 task linkCheck(type: JavaExec) {
864 dependsOn prepare, compileLinkCheck
866 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
867 classpath = files("${jalviewDir}/${utilsDir}")
868 main = "HelpLinksChecker"
869 workingDir = jalviewDir
870 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
872 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
874 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
877 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
881 inputs.dir("${classesDir}/${help_dir}")
882 outputs.file(helpLinksCheckerOutFile)
885 // import the pubhtmlhelp target
886 ant.properties.basedir = "${jalviewDir}"
887 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
888 ant.importBuild "${utilsDir}/publishHelp.xml"
891 task cleanPackageDir(type: Delete) {
893 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
899 dependsOn buildIndices
900 dependsOn createBuildProperties
903 attributes "Main-Class": mainClass,
904 "Permissions": "all-permissions",
905 "Application-Name": "Jalview Desktop",
906 "Codebase": application_codebase
909 destinationDir = file("${jalviewDir}/${packageDir}")
910 archiveName = rootProject.name+".jar"
918 inputs.dir(classesDir)
919 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
923 task copyJars(type: Copy) {
924 from fileTree(dir: classesDir, include: "**/*.jar").files
925 into "${jalviewDir}/${packageDir}"
929 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
930 task syncJars(type: Sync) {
931 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
932 into "${jalviewDir}/${packageDir}"
934 include jar.archiveName
941 description = "Put all required libraries in dist"
942 // order of "cleanPackageDir", "copyJars", "jar" important!
943 jar.mustRunAfter cleanPackageDir
944 syncJars.mustRunAfter cleanPackageDir
945 dependsOn cleanPackageDir
948 outputs.dir("${jalviewDir}/${packageDir}")
953 dependsOn cleanPackageDir
959 group = "distribution"
963 from ("${jalviewDir}/${libDistDir}") {
967 attributes 'Implementation-Version': JALVIEW_VERSION
969 mainClassName = shadowJarMainClass
971 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
976 task getdownWebsite() {
977 group = "distribution"
978 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
983 def getdownWebsiteResourceFilenames = []
984 def getdownTextString = ""
985 def getdownResourceDir = getdownResourceDir
986 def getdownResourceFilenames = []
989 // clean the getdown website and files dir before creating getdown folders
990 delete getdownWebsiteDir
991 delete getdownFilesDir
995 rename(build_properties_file, getdown_build_properties)
998 getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1000 // go through properties looking for getdown_txt_...
1001 def props = project.properties.sort { it.key }
1002 if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
1003 props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
1005 if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
1006 props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
1008 if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
1009 props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
1012 props.put("getdown_txt_appbase", getdownAppBase)
1013 props.each{ prop, val ->
1014 if (prop.startsWith("getdown_txt_") && val != null) {
1015 if (prop.startsWith("getdown_txt_multi_")) {
1016 def key = prop.substring(18)
1017 val.split(",").each{ v ->
1018 def line = "${key} = ${v}\n"
1019 getdownTextString += line
1022 // file values rationalised
1023 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1025 if (val.indexOf('/') == 0) {
1028 } else if (val.indexOf('/') > 0) {
1029 // relative path (relative to jalviewDir)
1030 r = file( "${jalviewDir}/${val}" )
1033 val = "${getdown_resource_dir}/" + r.getName()
1034 getdownWebsiteResourceFilenames += val
1035 getdownResourceFilenames += r.getPath()
1038 if (! prop.startsWith("getdown_txt_resource")) {
1039 def line = prop.substring(12) + " = ${val}\n"
1040 getdownTextString += line
1046 getdownWebsiteResourceFilenames.each{ filename ->
1047 getdownTextString += "resource = ${filename}\n"
1049 getdownResourceFilenames.each{ filename ->
1052 into getdownResourceDir
1057 fileTree(file(packageDir)).each{ f ->
1058 if (f.isDirectory()) {
1059 def files = fileTree(dir: f, include: ["*"]).getFiles()
1061 } else if (f.exists()) {
1065 codeFiles.sort().each{f ->
1066 def name = f.getName()
1067 def line = "code = ${getdownAppDistDir}/${name}\n"
1068 getdownTextString += line
1075 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1077 if (JAVA_VERSION.equals("11")) {
1078 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1079 j11libFiles.sort().each{f ->
1080 def name = f.getName()
1081 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1082 getdownTextString += line
1085 into getdownJ11libDir
1091 // 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.
1092 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1093 getdownTextString += "resource = ${getdown_launcher_new}\n"
1094 getdownTextString += "class = ${mainClass}\n"
1096 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1097 getdown_txt.write(getdownTextString)
1099 def getdownLaunchJvl = ( (getdownChannelName != null && getdownChannelName.length() > 0)?"${getdownChannelName}_":"" ) + getdown_launch_jvl
1100 def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
1101 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
1104 from getdownLauncher
1105 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1106 into getdownWebsiteDir
1110 from getdownLauncher
1111 if (file(getdownLauncher).getName() != getdown_launcher) {
1112 rename(file(getdownLauncher).getName(), getdown_launcher)
1114 into getdownWebsiteDir
1117 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1120 from getdownLauncher
1121 from "${getdownWebsiteDir}/${getdown_build_properties}"
1122 if (file(getdownLauncher).getName() != getdown_launcher) {
1123 rename(file(getdownLauncher).getName(), getdown_launcher)
1125 into getdownInstallDir
1129 from getdownInstallDir
1130 into getdownFilesInstallDir
1137 from getdownLauncher
1138 from "${getdownWebsiteDir}/${getdown_build_properties}"
1139 if (file(getdownLauncher).getName() != getdown_launcher) {
1140 rename(file(getdownLauncher).getName(), getdown_launcher)
1142 into getdownFilesDir
1146 from getdownResourceDir
1147 into "${getdownFilesDir}/${getdown_resource_dir}"
1152 inputs.dir("${jalviewDir}/${packageDir}")
1154 outputs.dir(getdownWebsiteDir)
1155 outputs.dir(getdownFilesDir)
1159 task getdownDigest(type: JavaExec) {
1160 group = "distribution"
1161 description = "Digest the getdown website folder"
1162 dependsOn getdownWebsite
1164 classpath = files(getdownLauncher)
1166 main = "com.threerings.getdown.tools.Digester"
1167 args getdownWebsiteDir
1168 inputs.dir(getdownWebsiteDir)
1169 outputs.file("${getdownWebsiteDir}/digest2.txt")
1174 group = "distribution"
1175 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1176 dependsOn getdownDigest
1178 if (reportRsyncCommand) {
1179 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1180 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1181 println "LIKELY RSYNC COMMAND:"
1182 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1183 if (RUNRSYNC == "true") {
1185 commandLine "mkdir", "-p", toDir
1188 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1198 delete getdownWebsiteDir
1199 delete getdownFilesDir
1205 if (file(install4jHomeDir).exists()) {
1207 } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1208 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1209 } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1210 install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1212 installDir(file(install4jHomeDir))
1214 mediaTypes = Arrays.asList(install4j_media_types.split(","))
1218 task copyInstall4jTemplate {
1219 def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1220 def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1221 inputs.file(install4jTemplateFile)
1222 inputs.file(install4jFileAssociationsFile)
1223 outputs.file(install4jConfFile)
1226 def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1228 // turn off code signing if no OSX_KEYPASS
1229 if (OSX_KEYPASS == "") {
1230 install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1231 codeSigning.'@macEnabled' = "false"
1233 install4jConfigXml.'**'.windows.each { windows ->
1234 windows.'@runPostProcessor' = "false"
1238 // turn off checksum creation for LOCAL channel
1239 def e = install4jConfigXml.application[0]
1240 if (CHANNEL == "LOCAL") {
1241 e.'@createChecksums' = "false"
1243 e.'@createChecksums' = "true"
1246 // put file association actions where placeholder action is
1247 def install4jFileAssociationsText = install4jFileAssociationsFile.text
1248 def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1249 install4jConfigXml.'**'.action.any { a ->
1250 if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1251 def parent = a.parent()
1253 fileAssociationActions.each { faa ->
1256 // don't need to continue in .any loop once replacements have been made
1261 // write install4j file
1262 install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1269 delete install4jConfFile
1274 task installers(type: com.install4j.gradle.Install4jTask) {
1275 group = "distribution"
1276 description = "Create the install4j installers"
1277 dependsOn setGitVals
1279 dependsOn copyInstall4jTemplate
1281 projectFile = install4jConfFile
1283 // create an md5 for the input files to use as version for install4j conf file
1284 def digest = MessageDigest.getInstance("MD5")
1286 (file("${install4jDir}/${install4j_template}").text +
1287 file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1288 file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1289 def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1290 if (filesMd5.length() >= 8) {
1291 filesMd5 = filesMd5.substring(0,8)
1293 def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1294 // make install4jBuildDir relative to jalviewDir
1295 def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
1298 'JALVIEW_NAME': getdown_txt_title,
1299 'JALVIEW_DIR': "../..",
1300 'OSX_KEYSTORE': OSX_KEYSTORE,
1301 'JSIGN_SH': JSIGN_SH,
1302 'JRE_DIR': getdown_app_dir_java,
1303 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1304 'JALVIEW_VERSION': JALVIEW_VERSION,
1305 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1306 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1307 'JAVA_VERSION': JAVA_VERSION,
1308 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1309 'VERSION': JALVIEW_VERSION,
1310 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1311 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1312 'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
1313 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1314 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1315 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
1316 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1317 'MACOS_BUNDLE_ID': install4j_macOS_bundle_id,
1318 'INSTALLER_NAME': install4j_installer_name,
1319 'INSTALL4J_UTILS_DIR': install4j_utils_dir,
1320 'GETDOWN_WEBSITE_DIR': getdown_website_dir,
1321 'GETDOWN_FILES_DIR': getdown_files_dir,
1322 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1323 'GETDOWN_DIST_DIR': getdownAppDistDir,
1324 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1325 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1326 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1327 'BUILD_DIR': install4jBuildDir,
1330 destination = "${jalviewDir}/${install4jBuildDir}"
1331 buildSelected = true
1333 if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
1335 disableSigning = true
1339 macKeystorePassword = OSX_KEYPASS
1343 println("Using projectFile "+projectFile)
1346 inputs.dir(getdownWebsiteDir)
1347 inputs.file(install4jConfFile)
1348 inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1349 inputs.dir(macosJavaVMDir)
1350 inputs.dir(windowsJavaVMDir)
1351 outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1355 task sourceDist(type: Tar) {
1357 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1358 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1359 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1361 archiveFileName = outputFileName
1362 } catch (Exception e) {
1363 archiveName = outputFileName
1366 compression Compression.GZIP
1370 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1375 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1377 ,"utils/InstallAnywhere"]
1378 def PROCESS_FILES=[ "AUTHORS",
1386 "THIRDPARTYLIBS","TESTNG",
1388 "gradle.properties",
1399 exclude (EXCLUDE_FILES)
1400 include (PROCESS_FILES)
1401 filter(ReplaceTokens,
1405 'Version-Rel': JALVIEW_VERSION,
1406 'Year-Rel': getDate("yyyy")
1411 exclude (EXCLUDE_FILES)
1412 exclude (PROCESS_FILES)
1413 exclude ("appletlib")
1414 exclude ("**/*locales")
1415 exclude ("*locales/**")
1416 exclude ("utils/InstallAnywhere")
1418 exclude (getdown_files_dir)
1419 exclude (getdown_website_dir)
1421 // exluding these as not using jars as modules yet
1422 exclude ("${j11modDir}/**/*.jar")
1424 // from (jalviewDir) {
1425 // // explicit includes for stuff that seemed to not get included
1426 // include(fileTree("test/**/*."))
1427 // exclude(EXCLUDE_FILES)
1428 // exclude(PROCESS_FILES)
1435 dependsOn pubhtmlhelp
1437 inputs.dir("${classesDir}/${help_dir}")
1438 outputs.dir("${buildDir}/distributions/${help_dir}")
1441 // LARGE AMOUNT OF JALVIEWJS STUFF DELETED HERE
1442 task eclipseAutoBuildTask {}
1443 task eclipseSynchronizationTask {}