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.3.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.4' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
35 compile 'org.apache.commons:commons-compress:1.18'
39 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
40 def string(Object o) {
46 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
47 jalviewDirRelativePath = jalviewDir
49 // local build environment properties
50 def localProps = "${jalviewDirAbsolutePath}/local.properties"
51 if (file(localProps).exists()) {
53 def p = new Properties()
54 def localPropsFIS = new FileInputStream(localProps)
59 def oldval = findProperty(key)
62 println("Overriding property '${key}' ('${oldval}') with local.properties value '${val}'")
64 println("Setting unknown property '${key}' with local.properties value '${val}'")
67 } catch (Exception e) {
68 System.out.println("Exception reading local.properties")
72 // this property set when running Eclipse headlessly
73 j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
74 // this property set by Eclipse
75 eclipseApplicationProperty = string("eclipse.application")
76 // CHECK IF RUNNING FROM WITHIN ECLIPSE
77 def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
78 IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
79 // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
80 if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
81 println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
85 println("WITHIN ECLIPSE IDE")
87 println("HEADLESS BUILD")
90 System.properties.sort { it.key }.each {
91 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
94 if (false && IN_ECLIPSE) {
95 jalviewDir = jalviewDirAbsolutePath
100 bareSourceDir = string(source_dir)
101 sourceDir = string("${jalviewDir}/${bareSourceDir}")
102 resourceDir = string("${jalviewDir}/${resource_dir}")
103 bareTestSourceDir = string(test_source_dir)
104 testSourceDir = string("${jalviewDir}/${bareTestSourceDir}")
107 cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
108 classesDir = string("${jalviewDir}/${classes_dir}")
109 if (clover.equals("true")) {
111 classesDir = string("${buildDir}/${cloverClassesDir}")
114 classesDir = string("${jalviewDir}/${classes_dir}")
119 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
120 getdownDir = string("")
121 reportRsyncCmd = false
123 buildProperties = build_properties_file
124 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
128 // TODO: get bamboo build artifact URL for getdown artifacts
129 getdown_channel_base = bamboo_channelbase
130 getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
131 getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
132 getdown_app_dir = getdown_app_dir_alt
133 buildProperties = string("${classesDir}/${build_properties_file}")
137 getdown_channel_name = CHANNEL.toLowerCase()
138 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
139 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
140 getdown_app_dir = getdown_app_dir_release
141 buildProperties = string("${classesDir}/${build_properties_file}")
142 reportRsyncCommand = true
146 getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
147 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
148 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
149 getdown_app_dir = getdown_app_dir_alt
150 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
151 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
154 packageDir = string("${ARCHIVEDIR}/${packageDir}")
155 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
158 reportRsyncCommand = true
162 getdown_channel_name = string("archive/${JALVIEW_VERSION}")
163 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
164 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
165 getdown_app_dir = getdown_app_dir_alt
166 if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
167 print "Must provide an ARCHIVEDIR value to produce an archive distribution"
170 packageDir = string("${ARCHIVEDIR}/${packageDir}")
171 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
174 reportRsyncCommand = true
175 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
179 getdown_channel_name = CHANNEL.toLowerCase()
180 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
181 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
182 getdown_app_dir = getdown_app_dir_alt
183 buildProperties = string("${classesDir}/${build_properties_file}")
184 reportRsyncCommand = true
188 getdown_channel_name = CHANNEL.toLowerCase()
189 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
190 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
191 getdown_app_dir = getdown_app_dir_alt
192 buildProperties = string("${classesDir}/${build_properties_file}")
193 reportRsyncCommand = true
196 case ~/^SCRATCH(|-[-\w]*)$/:
197 getdown_channel_name = CHANNEL
198 getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
199 getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
200 getdown_app_dir = getdown_app_dir_alt
201 buildProperties = string("${classesDir}/${build_properties_file}")
202 reportRsyncCommand = true
206 getdown_app_base = file(getdownWebsiteDir).toURI().toString()
207 getdown_app_dir = getdown_app_dir_alt
208 buildProperties = string("${classesDir}/${build_properties_file}")
209 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
212 default: // something wrong specified
213 println("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
218 // override getdown_app_base if requested
219 if (findProperty("getdown_appbase_override") != null) {
220 getdown_app_base = string(getProperty("getdown_appbase_override"))
221 println("Overriding getdown appbase with '${getdown_app_base}'")
224 getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
225 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
226 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
227 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
228 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
229 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
230 /* compile without modules -- using classpath libraries
231 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
232 modules_runtimeClasspath = modules_compileClasspath
235 gitBranch = string("")
237 println("Using a ${CHANNEL} profile.")
239 additional_compiler_args = []
240 // configure classpath/args for j8/j11 compilation
241 if (JAVA_VERSION.equals("1.8")) {
242 JAVA_INTEGER_VERSION = string("8")
245 libDistDir = j8libDir
246 compile_source_compatibility = 1.8
247 compile_target_compatibility = 1.8
248 // these are getdown.txt properties defined dependent on the JAVA_VERSION
249 getdown_alt_java_min_version = getdown_alt_java8_min_version
250 getdown_alt_java_max_version = getdown_alt_java8_max_version
251 // this property is assigned below and expanded to multiple lines in the getdown task
252 getdown_alt_multi_java_location = getdown_alt_java8_txt_multi_java_location
253 // this property is for the Java library used in eclipse
254 eclipse_java_runtime_name = string("JavaSE-1.8")
255 } else if (JAVA_VERSION.equals("11")) {
256 JAVA_INTEGER_VERSION = string("11")
258 libDistDir = j11libDir
259 compile_source_compatibility = 11
260 compile_target_compatibility = 11
261 getdown_alt_java_min_version = getdown_alt_java11_min_version
262 getdown_alt_java_max_version = getdown_alt_java11_max_version
263 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
264 eclipse_java_runtime_name = string("JavaSE-11")
265 /* compile without modules -- using classpath libraries
266 additional_compiler_args += [
267 '--module-path', modules_compileClasspath.asPath,
268 '--add-modules', j11modules
271 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
272 JAVA_INTEGER_VERSION = JAVA_VERSION
274 libDistDir = j11libDir
275 compile_source_compatibility = JAVA_VERSION
276 compile_target_compatibility = JAVA_VERSION
277 getdown_alt_java_min_version = getdown_alt_java11_min_version
278 getdown_alt_java_max_version = getdown_alt_java11_max_version
279 getdown_alt_multi_java_location = getdown_alt_java11_txt_multi_java_location
280 eclipse_java_runtime_name = string("JavaSE-11")
281 /* compile without modules -- using classpath libraries
282 additional_compiler_args += [
283 '--module-path', modules_compileClasspath.asPath,
284 '--add-modules', j11modules
288 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
293 JAVA_MIN_VERSION = JAVA_VERSION
294 JAVA_MAX_VERSION = JAVA_VERSION
295 macosJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/macos-jre${JAVA_VERSION}/jre")
296 macosJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/macos-jre${JAVA_VERSION}.tar.gz")
297 windowsJavaVMDir = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/getdown/windows-jre${JAVA_VERSION}/jre")
298 windowsJavaVMTgz = string("${System.env.HOME}/buildtools/jre/openjdk-java_vm/install4j/tgz/windows-jre${JAVA_VERSION}.tar.gz")
299 install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
300 install4jConfFileName = string("jalview-install4j-conf.install4j")
301 install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
302 install4jHomeDir = install4j_home_dir
303 if (install4jHomeDir.startsWith("~/")) {
304 install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
309 buildingHTML = string("${jalviewDir}/${docDir}/building.html")
310 helpFile = string("${classesDir}/${help_dir}/help.jhm")
311 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
312 helpSourceDir = string("${helpParentDir}/${help_dir}")
315 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
316 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
317 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
319 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
321 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
323 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
324 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
325 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
326 jalviewjsJalviewCoreHtmlFile = string("")
327 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
328 jalviewjsCoreClasslists = []
329 jalviewjsJalviewTemplateName = string(jalviewjs_name)
330 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
331 jalviewjsJ2sProps = null
333 eclipseWorkspace = null
334 eclipseBinary = string("")
335 eclipseVersion = string("")
345 outputDir = file(classesDir)
350 srcDirs += helpParentDir
353 jar.destinationDir = file("${jalviewDir}/${packageDir}")
355 compileClasspath = files(sourceSets.main.java.outputDir)
356 //compileClasspath += files(sourceSets.main.resources.srcDirs)
357 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
359 runtimeClasspath = compileClasspath
364 srcDirs = [ cloverInstrDir ]
365 outputDir = file("${buildDir}/${cloverClassesDir}")
369 srcDirs = sourceSets.main.resources.srcDirs
371 compileClasspath = configurations.cloverRuntime + files( sourceSets.clover.java.outputDir )
372 compileClasspath += files(sourceSets.main.java.outputDir)
373 compileClasspath += sourceSets.main.compileClasspath
374 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["**/*.jar"])
375 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
377 runtimeClasspath = compileClasspath
382 srcDirs testSourceDir
383 outputDir = file("${jalviewDir}/${testOutputDir}")
387 srcDirs = sourceSets.main.resources.srcDirs
390 compileClasspath = files( sourceSets.test.java.outputDir )
393 compileClasspath += sourceSets.clover.compileClasspath
395 compileClasspath += files(sourceSets.main.java.outputDir)
398 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
399 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testnglibs", include: ["**/*.jar"])
400 compileClasspath += fileTree(dir: "${jalviewDir}/${utilsDir}/testlibs", include: ["**/*.jar"])
402 runtimeClasspath = compileClasspath
410 cloverCompile 'org.openclover:clover:4.3.1'
411 testCompile 'org.openclover:clover:4.3.1'
418 cloverRuntime.extendsFrom cloverCompile
423 name = eclipse_project_name
425 natures 'org.eclipse.jdt.core.javanature',
426 'org.eclipse.jdt.groovy.core.groovyNature',
427 'org.eclipse.buildship.core.gradleprojectnature'
429 buildCommand 'org.eclipse.jdt.core.javabuilder'
430 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
434 //defaultOutputDir = sourceSets.main.java.outputDir
437 if (it.isCanBeResolved()) {
442 minusConfigurations += removeThese
443 plusConfigurations = [ ]
447 def removeTheseToo = []
448 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
449 cp.entries.each { entry ->
450 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
451 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
452 // we add the resources and help/help dirs in as libs afterwards (see below)
453 if (entry.kind == 'src') {
454 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
455 removeTheseToo += entry
457 alreadyAddedSrcPath.putAt(entry.path, true)
462 cp.entries.removeAll(removeTheseToo)
464 //cp.entries += new Output("${eclipse_bin_dir}/main")
465 if (file(helpParentDir).isDirectory()) {
466 cp.entries += new Library(fileReference(helpParentDir))
468 if (file(resourceDir).isDirectory()) {
469 cp.entries += new Library(fileReference(resourceDir))
472 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
474 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
475 //don't want to add outputDir as eclipse is using its own output dir in bin/main
476 if (it.isDirectory() || ! it.exists()) {
477 // don't add dirs to classpath, especially if they don't exist
478 return false // groovy "continue" in .any closure
480 def itPath = it.toString()
481 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
482 // make relative path
483 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
485 if (alreadyAddedLibPath.get(itPath)) {
486 //println("Not adding duplicate entry "+itPath)
488 //println("Adding entry "+itPath)
489 cp.entries += new Library(fileReference(itPath))
490 alreadyAddedLibPath.put(itPath, true)
494 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
495 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
496 if (it.isDirectory() || ! it.exists()) {
497 // don't add dirs to classpath
498 return false // groovy "continue" in .any closure
501 def itPath = it.toString()
502 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
503 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
505 if (alreadyAddedLibPath.get(itPath)) {
508 def lib = new Library(fileReference(itPath))
509 lib.entryAttributes["test"] = "true"
511 alreadyAddedLibPath.put(itPath, true)
519 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
524 // for the IDE, use java 11 compatibility
525 sourceCompatibility = compile_source_compatibility
526 targetCompatibility = compile_target_compatibility
527 javaRuntimeName = eclipse_java_runtime_name
529 // add in jalview project specific properties/preferences into eclipse core preferences
531 withProperties { props ->
532 def jalview_prefs = new Properties()
533 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
534 jalview_prefs.load(ins)
536 jalview_prefs.forEach { t, v ->
537 if (props.getAt(t) == null) {
547 // Don't want these to be activated if in headless build
548 synchronizationTasks "eclipseSynchronizationTask"
549 autoBuildTasks "eclipseAutoBuildTask"
556 // only instrument source, we build test classes as normal
557 inputs.files files (sourceSets.main.allJava) // , fileTree(dir: testSourceDir, include: ["**/*.java"]))
558 outputs.dir cloverInstrDir
561 delete cloverInstrDir
562 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
563 "-d", "${buildDir}/${cloverSourcesInstrDir}"]
564 argsList.addAll(inputs.files.files.collect({ file ->
567 String[] args = argsList.toArray()
568 println("About to instrument "+args.length +" files")
569 com.atlassian.clover.CloverInstr.mainImpl(args)
575 group = "Verification"
576 description = "Createst the Clover report"
577 inputs.dir "${buildDir}/clover"
578 outputs.dir "${reportsDir}/clover"
580 file("${buildDir}/clover/clover.db").exists()
583 def argsList = ["--initstring", "${buildDir}/clover/clover.db",
584 "-o", "${reportsDir}/clover"]
585 String[] args = argsList.toArray()
586 com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
588 // and generate ${reportsDir}/clover/clover.xml
589 args = ["--initstring", "${buildDir}/clover/clover.db",
590 "-o", "${reportsDir}/clover/clover.xml"].toArray()
591 com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
600 sourceCompatibility = compile_source_compatibility
601 targetCompatibility = compile_target_compatibility
602 options.compilerArgs = additional_compiler_args
603 print ("Setting target compatibility to "+targetCompatibility+"\n")
611 dependsOn compileCloverJava
612 classpath += configurations.cloverRuntime
614 classpath += sourceSets.main.runtimeClasspath
617 sourceCompatibility = compile_source_compatibility
618 targetCompatibility = compile_target_compatibility
619 options.compilerArgs = additional_compiler_args
620 print ("Setting target compatibility to "+targetCompatibility+"\n")
628 sourceCompatibility = compile_source_compatibility
629 targetCompatibility = compile_target_compatibility
630 options.compilerArgs += additional_compiler_args
631 print ("Setting target compatibility to "+targetCompatibility+"\n")
633 classpath += configurations.cloverRuntime
639 delete sourceSets.main.java.outputDir
646 delete sourceSets.test.java.outputDir
647 delete cloverInstrDir
652 // format is a string like date.format("dd MMMM yyyy")
653 def getDate(format) {
654 def date = new Date()
655 return date.format(format)
660 def hashStdOut = new ByteArrayOutputStream()
662 commandLine "git", "rev-parse", "--short", "HEAD"
663 standardOutput = hashStdOut
667 def branchStdOut = new ByteArrayOutputStream()
669 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
670 standardOutput = branchStdOut
674 gitHash = hashStdOut.toString().trim()
675 gitBranch = branchStdOut.toString().trim()
677 outputs.upToDateWhen { false }
681 task createBuildProperties(type: WriteProperties) {
683 inputs.dir(sourceDir)
684 inputs.dir(resourceDir)
685 file(buildProperties).getParentFile().mkdirs()
686 outputFile (buildProperties)
687 // taking time specific comment out to allow better incremental builds
688 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
689 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
690 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
691 property "VERSION", JALVIEW_VERSION
692 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
693 outputs.file(outputFile)
697 task cleanBuildingHTML(type: Delete) {
704 task convertBuildingMD(type: Exec) {
705 dependsOn cleanBuildingHTML
706 def buildingMD = "${jalviewDir}/${docDir}/building.md"
707 def css = "${jalviewDir}/${docDir}/github.css"
710 pandoc_exec.split(",").each {
711 if (file(it.trim()).exists()) {
717 def hostname = "hostname".execute().text.trim()
718 if ((pandoc == null || ! file(pandoc).exists()) && hostname.equals("jv-bamboo")) {
719 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
723 if (pandoc != null && file(pandoc).exists()) {
724 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
726 println("Cannot find pandoc. Skipping convert building.md to HTML")
727 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
733 inputs.file(buildingMD)
735 outputs.file(buildingHTML)
746 task syncDocs(type: Sync) {
747 dependsOn convertBuildingMD
748 def syncDir = "${classesDir}/${docDir}"
749 from fileTree("${jalviewDir}/${docDir}")
755 task copyHelp(type: Copy) {
756 def inputDir = helpSourceDir
757 def outputDir = "${classesDir}/${help_dir}"
762 filter(ReplaceTokens,
766 'Version-Rel': JALVIEW_VERSION,
767 'Year-Rel': getDate("yyyy")
779 outputs.files(helpFile)
780 outputs.dir(outputDir)
784 task syncLib(type: Sync) {
785 def syncDir = "${classesDir}/${libDistDir}"
786 from fileTree("${jalviewDir}/${libDistDir}")
791 task syncResources(type: Sync) {
802 dependsOn syncResources
808 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
811 dependsOn compileJava
813 dependsOn cloverInstr
817 print("Running tests " + (use_clover?"WITH":"WITHOUT") + " clover [clover="+use_clover+"]\n")
821 includeGroups testngGroups
823 useDefaultListeners=true
826 workingDir = jalviewDir
827 //systemProperties 'clover.jar' System.properties.clover.jar
828 sourceCompatibility = compile_source_compatibility
829 targetCompatibility = compile_target_compatibility
830 jvmArgs += additional_compiler_args
835 task buildIndices(type: JavaExec) {
837 classpath = sourceSets.main.compileClasspath
838 main = "com.sun.java.help.search.Indexer"
839 workingDir = "${classesDir}/${help_dir}"
842 inputs.dir("${workingDir}/${argDir}")
844 outputs.dir("${classesDir}/doc")
845 outputs.dir("${classesDir}/help")
846 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
847 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
848 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
849 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
850 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
851 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
855 task compileLinkCheck(type: JavaCompile) {
857 classpath = files("${jalviewDir}/${utilsDir}")
858 destinationDir = file("${jalviewDir}/${utilsDir}")
859 source = fileTree(dir: "${jalviewDir}/${utilsDir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
861 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
862 inputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.java")
863 outputs.file("${jalviewDir}/${utilsDir}/HelpLinksChecker.class")
864 outputs.file("${jalviewDir}/${utilsDir}/BufferedLineReader.class")
868 task linkCheck(type: JavaExec) {
869 dependsOn prepare, compileLinkCheck
871 def helpLinksCheckerOutFile = file("${jalviewDir}/${utilsDir}/HelpLinksChecker.out")
872 classpath = files("${jalviewDir}/${utilsDir}")
873 main = "HelpLinksChecker"
874 workingDir = jalviewDir
875 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
877 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
879 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
882 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
886 inputs.dir("${classesDir}/${help_dir}")
887 outputs.file(helpLinksCheckerOutFile)
890 // import the pubhtmlhelp target
891 ant.properties.basedir = "${jalviewDir}"
892 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
893 ant.importBuild "${utilsDir}/publishHelp.xml"
896 task cleanPackageDir(type: Delete) {
898 delete fileTree(dir: "${jalviewDir}/${packageDir}", include: "*.jar")
904 dependsOn buildIndices
905 dependsOn createBuildProperties
908 attributes "Main-Class": mainClass,
909 "Permissions": "all-permissions",
910 "Application-Name": "Jalview Desktop",
911 "Codebase": application_codebase
914 destinationDir = file("${jalviewDir}/${packageDir}")
915 archiveName = rootProject.name+".jar"
923 inputs.dir(classesDir)
924 outputs.file("${jalviewDir}/${packageDir}/${archiveName}")
928 task copyJars(type: Copy) {
929 from fileTree(dir: classesDir, include: "**/*.jar").files
930 into "${jalviewDir}/${packageDir}"
934 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
935 task syncJars(type: Sync) {
936 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
937 into "${jalviewDir}/${packageDir}"
939 include jar.archiveName
946 description = "Put all required libraries in dist"
947 // order of "cleanPackageDir", "copyJars", "jar" important!
948 jar.mustRunAfter cleanPackageDir
949 syncJars.mustRunAfter cleanPackageDir
950 dependsOn cleanPackageDir
953 outputs.dir("${jalviewDir}/${packageDir}")
958 dependsOn cleanPackageDir
964 group = "distribution"
968 from ("${jalviewDir}/${libDistDir}") {
972 attributes 'Implementation-Version': JALVIEW_VERSION
974 mainClassName = shadowJarMainClass
976 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
981 task getdownWebsite() {
982 group = "distribution"
983 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
988 def getdownWebsiteResourceFilenames = []
989 def getdownTextString = ""
990 def getdownResourceDir = getdownResourceDir
991 def getdownAppDir = getdownAppDir
992 def getdownResourceFilenames = []
995 // clean the getdown website and files dir before creating getdown folders
996 delete getdownWebsiteDir
997 delete getdownFilesDir
1000 from buildProperties
1001 rename(build_properties_file, getdown_build_properties)
1004 getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
1006 // go through properties looking for getdown_txt_...
1007 def props = project.properties.sort { it.key }
1008 if (getdown_alt_java_min_version.length() > 0) {
1009 props.put("getdown_txt_java_min_version", getdown_alt_java_min_version)
1011 if (getdown_alt_java_max_version.length() > 0) {
1012 props.put("getdown_txt_java_max_version", getdown_alt_java_max_version)
1014 props.put("getdown_txt_multi_java_location", getdown_alt_multi_java_location)
1016 props.put("getdown_txt_appbase", getdown_app_base)
1017 props.each{ prop, val ->
1018 if (prop.startsWith("getdown_txt_") && val != null) {
1019 if (prop.startsWith("getdown_txt_multi_")) {
1020 def key = prop.substring(18)
1021 val.split(",").each{ v ->
1022 def line = "${key} = ${v}\n"
1023 getdownTextString += line
1026 // file values rationalised
1027 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1029 if (val.indexOf('/') == 0) {
1032 } else if (val.indexOf('/') > 0) {
1033 // relative path (relative to jalviewDir)
1034 r = file( "${jalviewDir}/${val}" )
1037 val = "${getdown_resource_dir}/" + r.getName()
1038 getdownWebsiteResourceFilenames += val
1039 getdownResourceFilenames += r.getPath()
1042 if (! prop.startsWith("getdown_txt_resource")) {
1043 def line = prop.substring(12) + " = ${val}\n"
1044 getdownTextString += line
1050 getdownWebsiteResourceFilenames.each{ filename ->
1051 getdownTextString += "resource = ${filename}\n"
1053 getdownResourceFilenames.each{ filename ->
1056 into getdownResourceDir
1061 fileTree(file(packageDir)).each{ f ->
1062 if (f.isDirectory()) {
1063 def files = fileTree(dir: f, include: ["*"]).getFiles()
1065 } else if (f.exists()) {
1069 codeFiles.sort().each{f ->
1070 def name = f.getName()
1071 def line = "code = ${getdown_app_dir}/${name}\n"
1072 getdownTextString += line
1079 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1081 if (JAVA_VERSION.equals("11")) {
1082 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1083 j11libFiles.sort().each{f ->
1084 def name = f.getName()
1085 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1086 getdownTextString += line
1089 into getdownJ11libDir
1095 // 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.
1096 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1097 getdownTextString += "resource = ${getdown_launcher_new}\n"
1098 getdownTextString += "class = ${mainClass}\n"
1100 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1101 getdown_txt.write(getdownTextString)
1103 def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
1104 launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
1107 from getdownLauncher
1108 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1109 into getdownWebsiteDir
1113 from getdownLauncher
1114 if (file(getdownLauncher).getName() != getdown_launcher) {
1115 rename(file(getdownLauncher).getName(), getdown_launcher)
1117 into getdownWebsiteDir
1120 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1123 from getdownLauncher
1124 from "${getdownWebsiteDir}/${getdown_build_properties}"
1125 if (file(getdownLauncher).getName() != getdown_launcher) {
1126 rename(file(getdownLauncher).getName(), getdown_launcher)
1128 into getdownInstallDir
1132 from getdownInstallDir
1133 into getdownFilesInstallDir
1140 from getdownLauncher
1141 from "${getdownWebsiteDir}/${getdown_build_properties}"
1142 if (file(getdownLauncher).getName() != getdown_launcher) {
1143 rename(file(getdownLauncher).getName(), getdown_launcher)
1145 into getdownFilesDir
1149 from getdownResourceDir
1150 into "${getdownFilesDir}/${getdown_resource_dir}"
1155 inputs.dir("${jalviewDir}/${packageDir}")
1157 outputs.dir(getdownWebsiteDir)
1158 outputs.dir(getdownFilesDir)
1162 task getdownDigest(type: JavaExec) {
1163 group = "distribution"
1164 description = "Digest the getdown website folder"
1165 dependsOn getdownWebsite
1167 classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
1169 main = "com.threerings.getdown.tools.Digester"
1170 args getdownWebsiteDir
1171 inputs.dir(getdownWebsiteDir)
1172 outputs.file("${getdownWebsiteDir}/digest2.txt")
1177 group = "distribution"
1178 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1179 dependsOn getdownDigest
1181 if (reportRsyncCommand) {
1182 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1183 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1184 println "LIKELY RSYNC COMMAND:"
1185 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1186 if (RUNRSYNC == "true") {
1188 commandLine "mkdir", "-p", toDir
1191 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1201 delete getdownWebsiteDir
1202 delete getdownFilesDir
1208 if (file(install4jHomeDir).exists()) {
1210 } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1211 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1212 } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1213 install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1215 installDir(file(install4jHomeDir))
1217 mediaTypes = Arrays.asList(install4j_media_types.split(","))
1221 task copyInstall4jTemplate {
1222 def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1223 def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1224 inputs.file(install4jTemplateFile)
1225 inputs.file(install4jFileAssociationsFile)
1226 outputs.file(install4jConfFile)
1229 def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1231 // turn off code signing if no OSX_KEYPASS
1232 if (OSX_KEYPASS == "") {
1233 install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1234 codeSigning.'@macEnabled' = "false"
1236 install4jConfigXml.'**'.windows.each { windows ->
1237 windows.'@runPostProcessor' = "false"
1241 // put file association actions where placeholder action is
1242 def install4jFileAssociationsText = install4jFileAssociationsFile.text
1243 def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1244 install4jConfigXml.'**'.action.any { a ->
1245 if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1246 def parent = a.parent()
1248 fileAssociationActions.each { faa ->
1251 // don't need to continue in .any loop once replacements have been made
1256 // write install4j file
1257 install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1264 delete install4jConfFile
1269 task installers(type: com.install4j.gradle.Install4jTask) {
1270 group = "distribution"
1271 description = "Create the install4j installers"
1272 dependsOn setGitVals
1274 dependsOn copyInstall4jTemplate
1276 projectFile = install4jConfFile
1278 // create an md5 for the input files to use as version for install4j conf file
1279 def digest = MessageDigest.getInstance("MD5")
1281 (file("${install4jDir}/${install4j_template}").text +
1282 file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1283 file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1284 def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1285 if (filesMd5.length() >= 8) {
1286 filesMd5 = filesMd5.substring(0,8)
1288 def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1291 'OSX_KEYSTORE': OSX_KEYSTORE,
1292 'JSIGN_SH': JSIGN_SH,
1293 'JRE_DIR': getdown_app_dir_java,
1294 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1295 'JALVIEW_VERSION': JALVIEW_VERSION,
1296 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1297 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1298 'JAVA_VERSION': JAVA_VERSION,
1299 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1300 'VERSION': JALVIEW_VERSION,
1301 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1302 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1303 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1304 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1305 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1306 'MACOS_BUNDLE_ID': install4j_macOS_bundle_id,
1307 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1308 'GETDOWN_DIST_DIR': getdown_app_dir,
1309 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1310 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1311 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1314 destination = "${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}"
1315 buildSelected = true
1317 if (install4j_faster.equals("true") || CHANNEL.startsWith("DEVELOP") || CHANNEL.startsWith("LOCAL")) {
1318 // this doesn't seem to work
1320 disableSigning = true
1324 macKeystorePassword = OSX_KEYPASS
1328 println("Using projectFile "+projectFile)
1331 inputs.dir(getdownWebsiteDir)
1332 inputs.file(install4jConfFile)
1333 inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1334 inputs.dir(macosJavaVMDir)
1335 inputs.dir(windowsJavaVMDir)
1336 outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1340 task sourceDist(type: Tar) {
1342 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1343 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1344 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1346 archiveFileName = outputFileName
1347 } catch (Exception e) {
1348 archiveName = outputFileName
1351 compression Compression.GZIP
1355 def EXCLUDE_FILES=["build/*","bin/*","test-output/","test-reports","tests","clover*/*"
1360 ,"**/*.class","${j11modDir}/**/*.jar","appletlib","**/*locales"
1362 ,"utils/InstallAnywhere"]
1363 def PROCESS_FILES=[ "AUTHORS",
1371 "THIRDPARTYLIBS","TESTNG",
1373 "gradle.properties",
1384 exclude (EXCLUDE_FILES)
1385 include (PROCESS_FILES)
1386 filter(ReplaceTokens,
1390 'Version-Rel': JALVIEW_VERSION,
1391 'Year-Rel': getDate("yyyy")
1396 exclude (EXCLUDE_FILES)
1397 exclude (PROCESS_FILES)
1398 exclude ("appletlib")
1399 exclude ("**/*locales")
1400 exclude ("*locales/**")
1401 exclude ("utils/InstallAnywhere")
1403 exclude (getdown_files_dir)
1404 exclude (getdown_website_dir)
1406 // exluding these as not using jars as modules yet
1407 exclude ("${j11modDir}/**/*.jar")
1409 // from (jalviewDir) {
1410 // // explicit includes for stuff that seemed to not get included
1411 // include(fileTree("test/**/*."))
1412 // exclude(EXCLUDE_FILES)
1413 // exclude(PROCESS_FILES)
1420 dependsOn pubhtmlhelp
1422 inputs.dir("${classesDir}/${help_dir}")
1423 outputs.dir("${buildDir}/distributions/${help_dir}")
1426 // LARGE AMOUNT OF JALVIEWJS STUFF DELETED HERE
1427 task eclipseAutoBuildTask {}
1428 task eclipseSynchronizationTask {}