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
23 id 'com.github.johnrengelman.shadow' version '4.0.3'
24 id 'com.install4j.gradle' version '8.0.4'
25 id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
35 // in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
36 def string(Object o) {
37 return o == null ? "" : o.toString()
42 jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
43 jalviewDirRelativePath = jalviewDir
45 // local build environment properties
46 // can be "projectDir/local.properties"
47 def localProps = "${projectDir}/local.properties"
49 if (file(localProps).exists()) {
50 propsFile = localProps
52 // or "../projectDir_local.properties"
53 def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties"
54 if (file(dirLocalProps).exists()) {
55 propsFile = dirLocalProps
57 if (propsFile != null) {
59 def p = new Properties()
60 def localPropsFIS = new FileInputStream(propsFile)
65 def oldval = findProperty(key)
68 println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'")
70 println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'")
73 } catch (Exception e) {
74 System.out.println("Exception reading local.properties")
79 // Import releaseProps from the RELEASE file
80 // or a file specified via JALVIEW_RELEASE_FILE if defined
81 // Expect jalview.version and target release branch in jalview.release
82 def releaseProps = new Properties();
83 def releasePropFile = findProperty("JALVIEW_RELEASE_FILE");
84 def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE";
86 (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream {
89 } catch (Exception fileLoadError) {
90 throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError);
93 // Set JALVIEW_VERSION if it is not already set
94 if (findProperty(JALVIEW_VERSION)==null || "".equals(JALVIEW_VERSION)) {
95 JALVIEW_VERSION = releaseProps.get("jalview.version")
98 // this property set when running Eclipse headlessly
99 j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
100 // this property set by Eclipse
101 eclipseApplicationProperty = string("eclipse.application")
102 // CHECK IF RUNNING FROM WITHIN ECLIPSE
103 def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
104 IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
105 // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
106 if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
107 println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
111 println("WITHIN ECLIPSE IDE")
113 println("HEADLESS BUILD")
116 System.properties.sort { it.key }.each {
117 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
120 if (false && IN_ECLIPSE) {
121 jalviewDir = jalviewDirAbsolutePath
126 bareSourceDir = string(source_dir)
127 sourceDir = string("${jalviewDir}/${bareSourceDir}")
128 resourceDir = string("${jalviewDir}/${resource_dir}")
129 bareTestSourceDir = string(test_source_dir)
130 testDir = string("${jalviewDir}/${bareTestSourceDir}")
132 classesDir = string("${jalviewDir}/${classes_dir}")
135 useClover = clover.equals("true")
136 cloverBuildDir = "${buildDir}/clover"
137 cloverInstrDir = file("${cloverBuildDir}/clover-instr")
138 cloverClassesDir = file("${cloverBuildDir}/clover-classes")
139 cloverReportDir = file("${buildDir}/reports")
140 cloverTestInstrDir = file("${cloverBuildDir}/clover-test-instr")
141 cloverTestClassesDir = file("${cloverBuildDir}/clover-test-classes")
142 //cloverTestClassesDir = cloverClassesDir
143 cloverDb = string("${cloverBuildDir}/clover.db")
145 resourceClassesDir = useClover ? cloverClassesDir : classesDir
147 testSourceDir = useClover ? cloverTestInstrDir : testDir
148 testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}"
150 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
153 // the following values might be overridden by the CHANNEL switch
154 getdownChannelName = CHANNEL.toLowerCase()
155 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
156 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
157 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
158 getdownAppDistDir = getdown_app_dir_alt
159 buildProperties = string("${classesDir}/${build_properties_file}")
160 reportRsyncCommand = false
161 jvlChannelName = CHANNEL.toLowerCase()
162 install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
163 install4jDSStore = "DS_Store-NON-RELEASE"
164 install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png"
165 install4jInstallerName = "${jalview_name} Non-Release Installer"
166 install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase()
167 install4jExtraScheme = "jalviewx"
171 // TODO: get bamboo build artifact URL for getdown artifacts
172 getdown_channel_base = bamboo_channelbase
173 getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
174 getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
175 jvlChannelName += "_${getdownChannelName}"
176 // automatically add the test group Not-bamboo for exclusion
177 if ("".equals(testng_excluded_groups)) {
178 testng_excluded_groups = "Not-bamboo"
180 install4jExtraScheme = "jalviewb"
184 getdownAppDistDir = getdown_app_dir_release
185 reportRsyncCommand = true
187 install4jDSStore = "DS_Store"
188 install4jDMGBackgroundImage = "jalview_dmg_background.png"
189 install4jInstallerName = "${jalview_name} Installer"
193 getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
194 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
195 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
196 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
197 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
199 package_dir = string("${ARCHIVEDIR}/${package_dir}")
200 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
203 reportRsyncCommand = true
204 install4jExtraScheme = "jalviewa"
208 getdownChannelName = string("archive/${JALVIEW_VERSION}")
209 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
210 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
211 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
212 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
214 package_dir = string("${ARCHIVEDIR}/${package_dir}")
215 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
218 reportRsyncCommand = true
219 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
220 install4jSuffix = "Archive"
221 install4jExtraScheme = "jalviewa"
225 reportRsyncCommand = true
227 // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version
228 JALVIEW_VERSION=JALVIEW_VERSION+"-develop"
230 install4jSuffix = "Develop"
231 install4jDSStore = "DS_Store-DEVELOP"
232 install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png"
233 install4jExtraScheme = "jalviewd"
234 install4jInstallerName = "${jalview_name} Develop Installer"
238 reportRsyncCommand = true
240 // TEST-RELEASE is usually associated with a Jalview release series so set the version
241 JALVIEW_VERSION=JALVIEW_VERSION+"-test"
243 install4jSuffix = "Test"
244 install4jDSStore = "DS_Store-TEST-RELEASE"
245 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
246 install4jExtraScheme = "jalviewt"
247 install4jInstallerName = "${jalview_name} Test Installer"
250 case ~/^SCRATCH(|-[-\w]*)$/:
251 getdownChannelName = CHANNEL
252 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
253 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
254 reportRsyncCommand = true
255 install4jSuffix = "Scratch"
259 if (!file("${LOCALDIR}").exists()) {
260 throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
262 getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
263 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
265 JALVIEW_VERSION = "TEST"
266 install4jSuffix = "Test-Local"
267 install4jDSStore = "DS_Store-TEST-RELEASE"
268 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
269 install4jExtraScheme = "jalviewt"
270 install4jInstallerName = "${jalview_name} Test Installer"
274 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
275 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
276 install4jExtraScheme = "jalviewl"
279 default: // something wrong specified
280 throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
284 // override getdownAppBase if requested
285 if (findProperty("getdown_appbase_override") != null) {
286 getdownAppBase = string(getProperty("getdown_appbase_override"))
287 println("Overriding getdown appbase with '${getdownAppBase}'")
289 // sanitise file name for jalview launcher file for this channel
290 jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
291 // install4j application and folder names
292 if (install4jSuffix == "") {
293 install4jApplicationName = "${jalview_name}"
294 install4jBundleId = "${install4j_bundle_id}"
295 install4jWinApplicationId = install4j_release_win_application_id
297 install4jApplicationName = "${jalview_name} ${install4jSuffix}"
298 install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
299 // add int hash of install4jSuffix to the last part of the application_id
300 def id = install4j_release_win_application_id
301 def idsplitreverse = id.split("-").reverse()
302 idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
303 install4jWinApplicationId = idsplitreverse.reverse().join("-")
305 // sanitise folder and id names
306 // install4jApplicationFolder = e.g. "Jalview Build"
307 install4jApplicationFolder = install4jApplicationName
308 .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
309 .replaceAll("_+", "_") // collapse __
310 install4jInternalId = install4jApplicationName
312 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
313 .replaceAll("_+", "") // collapse __
314 //.replaceAll("_*-_*", "-") // collapse _-_
315 install4jUnixApplicationFolder = install4jApplicationName
317 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
318 .replaceAll("_+", "_") // collapse __
319 .replaceAll("_*-_*", "-") // collapse _-_
322 getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
323 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
324 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
325 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
326 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
327 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
328 /* compile without modules -- using classpath libraries
329 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
330 modules_runtimeClasspath = modules_compileClasspath
333 gitBranch = string("")
335 println("Using a ${CHANNEL} profile.")
337 additional_compiler_args = []
338 // configure classpath/args for j8/j11 compilation
339 if (JAVA_VERSION.equals("1.8")) {
340 JAVA_INTEGER_VERSION = string("8")
343 libDistDir = j8libDir
344 compile_source_compatibility = 1.8
345 compile_target_compatibility = 1.8
346 // these are getdown.txt properties defined dependent on the JAVA_VERSION
347 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
348 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
349 // this property is assigned below and expanded to multiple lines in the getdown task
350 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
351 // this property is for the Java library used in eclipse
352 eclipseJavaRuntimeName = string("JavaSE-1.8")
353 } else if (JAVA_VERSION.equals("11")) {
354 JAVA_INTEGER_VERSION = string("11")
356 libDistDir = j11libDir
357 compile_source_compatibility = 11
358 compile_target_compatibility = 11
359 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
360 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
361 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
362 eclipseJavaRuntimeName = string("JavaSE-11")
363 /* compile without modules -- using classpath libraries
364 additional_compiler_args += [
365 '--module-path', modules_compileClasspath.asPath,
366 '--add-modules', j11modules
369 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
370 JAVA_INTEGER_VERSION = JAVA_VERSION
372 libDistDir = j11libDir
373 compile_source_compatibility = JAVA_VERSION
374 compile_target_compatibility = JAVA_VERSION
375 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
376 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
377 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
378 eclipseJavaRuntimeName = string("JavaSE-11")
379 /* compile without modules -- using classpath libraries
380 additional_compiler_args += [
381 '--module-path', modules_compileClasspath.asPath,
382 '--add-modules', j11modules
386 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
391 JAVA_MIN_VERSION = JAVA_VERSION
392 JAVA_MAX_VERSION = JAVA_VERSION
393 def jreInstallsDir = string(jre_installs_dir)
394 if (jreInstallsDir.startsWith("~/")) {
395 jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
397 macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
398 macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
399 windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
400 windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
401 linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
402 linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
403 install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
404 install4jConfFileName = string("jalview-install4j-conf.install4j")
405 install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
406 install4jHomeDir = install4j_home_dir
407 if (install4jHomeDir.startsWith("~/")) {
408 install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
413 buildingHTML = string("${jalviewDir}/${doc_dir}/building.html")
414 helpFile = string("${resourceClassesDir}/${help_dir}/help.jhm")
415 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
416 helpSourceDir = string("${helpParentDir}/${help_dir}")
419 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
420 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
421 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
423 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
425 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
427 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
428 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
429 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
430 jalviewjsJalviewCoreHtmlFile = string("")
431 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
432 jalviewjsCoreClasslists = []
433 jalviewjsJalviewTemplateName = string(jalviewjs_name)
434 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
435 jalviewjsJ2sProps = null
437 eclipseWorkspace = null
438 eclipseBinary = string("")
439 eclipseVersion = string("")
449 outputDir = file(classesDir)
454 srcDirs += helpParentDir
457 jar.destinationDir = file("${jalviewDir}/${package_dir}")
459 compileClasspath = files(sourceSets.main.java.outputDir)
460 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
462 runtimeClasspath = compileClasspath
467 srcDirs cloverInstrDir
468 outputDir = cloverClassesDir
472 srcDirs = sourceSets.main.resources.srcDirs
475 compileClasspath = files( sourceSets.clover.java.outputDir )
476 //compileClasspath += files( testClassesDir )
477 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
478 compileClasspath += fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
479 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
481 runtimeClasspath = compileClasspath
486 srcDirs testSourceDir
487 outputDir = file(testClassesDir)
491 srcDirs = useClover ? sourceSets.clover.resources.srcDirs : sourceSets.main.resources.srcDirs
494 compileClasspath = files( sourceSets.test.java.outputDir )
495 compileClasspath += useClover ? sourceSets.clover.compileClasspath : sourceSets.main.compileClasspath
496 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
498 runtimeClasspath = compileClasspath
504 // eclipse project and settings files creation, also used by buildship
507 name = eclipse_project_name
509 natures 'org.eclipse.jdt.core.javanature',
510 'org.eclipse.jdt.groovy.core.groovyNature',
511 'org.eclipse.buildship.core.gradleprojectnature'
513 buildCommand 'org.eclipse.jdt.core.javabuilder'
514 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
518 //defaultOutputDir = sourceSets.main.java.outputDir
521 if (it.isCanBeResolved()) {
526 minusConfigurations += removeThese
527 plusConfigurations = [ ]
531 def removeTheseToo = []
532 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
533 cp.entries.each { entry ->
534 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
535 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
536 // we add the resources and help/help dirs in as libs afterwards (see below)
537 if (entry.kind == 'src') {
538 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
539 removeTheseToo += entry
541 alreadyAddedSrcPath.putAt(entry.path, true)
546 cp.entries.removeAll(removeTheseToo)
548 //cp.entries += new Output("${eclipse_bin_dir}/main")
549 if (file(helpParentDir).isDirectory()) {
550 cp.entries += new Library(fileReference(helpParentDir))
552 if (file(resourceDir).isDirectory()) {
553 cp.entries += new Library(fileReference(resourceDir))
556 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
558 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
559 //don't want to add outputDir as eclipse is using its own output dir in bin/main
560 if (it.isDirectory() || ! it.exists()) {
561 // don't add dirs to classpath, especially if they don't exist
562 return false // groovy "continue" in .any closure
564 def itPath = it.toString()
565 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
566 // make relative path
567 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
569 if (alreadyAddedLibPath.get(itPath)) {
570 //println("Not adding duplicate entry "+itPath)
572 //println("Adding entry "+itPath)
573 cp.entries += new Library(fileReference(itPath))
574 alreadyAddedLibPath.put(itPath, true)
578 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
579 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
580 if (it.isDirectory() || ! it.exists()) {
581 // don't add dirs to classpath
582 return false // groovy "continue" in .any closure
585 def itPath = it.toString()
586 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
587 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
589 if (alreadyAddedLibPath.get(itPath)) {
592 def lib = new Library(fileReference(itPath))
593 lib.entryAttributes["test"] = "true"
595 alreadyAddedLibPath.put(itPath, true)
603 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
608 // for the IDE, use java 11 compatibility
609 sourceCompatibility = compile_source_compatibility
610 targetCompatibility = compile_target_compatibility
611 javaRuntimeName = eclipseJavaRuntimeName
613 // add in jalview project specific properties/preferences into eclipse core preferences
615 withProperties { props ->
616 def jalview_prefs = new Properties()
617 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
618 jalview_prefs.load(ins)
620 jalview_prefs.forEach { t, v ->
621 if (props.getAt(t) == null) {
631 // Don't want these to be activated if in headless build
632 synchronizationTasks "eclipseSynchronizationTask"
633 autoBuildTasks "eclipseAutoBuildTask"
644 delete cloverBuildDir
649 task cloverInstrJava(type: JavaExec) {
650 group = "Verification"
651 description = "Create clover instrumented source java files"
653 dependsOn cleanClover
655 inputs.files(sourceSets.main.allJava)
656 outputs.dir(cloverInstrDir)
658 //classpath = fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
659 classpath = sourceSets.clover.compileClasspath
660 main = "com.atlassian.clover.CloverInstr"
668 cloverInstrDir.getPath(),
670 def srcFiles = sourceSets.main.allJava.files
673 { file -> file.absolutePath }
676 args argsList.toArray()
679 delete cloverInstrDir
680 println("Clover: About to instrument "+srcFiles.size() +" files")
685 task cloverInstrTests(type: JavaExec) {
686 group = "Verification"
687 description = "Create clover instrumented source test files"
689 dependsOn cleanClover
691 inputs.files(testDir)
692 outputs.dir(cloverTestInstrDir)
694 classpath = sourceSets.clover.compileClasspath
695 main = "com.atlassian.clover.CloverInstr"
705 cloverTestInstrDir.getPath(),
707 args argsList.toArray()
710 delete cloverTestInstrDir
711 println("Clover: About to instrument test files")
717 group = "Verification"
718 description = "Create clover instrumented all source files"
720 dependsOn cloverInstrJava
721 dependsOn cloverInstrTests
725 cloverClasses.dependsOn cloverInstr
728 task cloverConsoleReport(type: JavaExec) {
729 group = "Verification"
730 description = "Creates clover console report"
733 file(cloverDb).exists()
736 inputs.dir cloverClassesDir
738 classpath = sourceSets.clover.runtimeClasspath
739 main = "com.atlassian.clover.reporters.console.ConsoleReporter"
741 if (cloverreport_mem.length() > 0) {
742 maxHeapSize = cloverreport_mem
744 if (cloverreport_jvmargs.length() > 0) {
745 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
755 args argsList.toArray()
759 task cloverHtmlReport(type: JavaExec) {
760 group = "Verification"
761 description = "Creates clover HTML report"
764 file(cloverDb).exists()
767 def cloverHtmlDir = "${cloverReportDir}/clover"
768 inputs.dir cloverClassesDir
769 outputs.dir cloverHtmlDir
771 classpath = sourceSets.clover.runtimeClasspath
772 main = "com.atlassian.clover.reporters.html.HtmlReporter"
774 if (cloverreport_mem.length() > 0) {
775 maxHeapSize = cloverreport_mem
777 if (cloverreport_jvmargs.length() > 0) {
778 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
789 if (cloverreport_html_options.length() > 0) {
790 argsList += cloverreport_html_options.split(" ")
793 args argsList.toArray()
797 task cloverXmlReport(type: JavaExec) {
798 group = "Verification"
799 description = "Creates clover XML report"
802 file(cloverDb).exists()
805 def cloverXmlFile = "${cloverReportDir}/clover.xml"
806 inputs.dir cloverClassesDir
807 outputs.file cloverXmlFile
809 classpath = sourceSets.clover.runtimeClasspath
810 main = "com.atlassian.clover.reporters.xml.XMLReporter"
812 if (cloverreport_mem.length() > 0) {
813 maxHeapSize = cloverreport_mem
815 if (cloverreport_jvmargs.length() > 0) {
816 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
827 if (cloverreport_xml_options.length() > 0) {
828 argsList += cloverreport_xml_options.split(" ")
831 args argsList.toArray()
836 group = "Verification"
837 description = "Creates clover reports"
839 dependsOn cloverXmlReport
840 dependsOn cloverHtmlReport
847 sourceCompatibility = compile_source_compatibility
848 targetCompatibility = compile_target_compatibility
849 options.compilerArgs += additional_compiler_args
850 print ("Setting target compatibility to "+targetCompatibility+"\n")
852 //classpath += configurations.cloverRuntime
860 sourceCompatibility = compile_source_compatibility
861 targetCompatibility = compile_target_compatibility
862 options.compilerArgs = additional_compiler_args
863 print ("Setting target compatibility to "+targetCompatibility+"\n")
871 sourceCompatibility = compile_source_compatibility
872 targetCompatibility = compile_target_compatibility
873 options.compilerArgs = additional_compiler_args
874 print ("Setting target compatibility to "+targetCompatibility+"\n")
881 delete sourceSets.main.java.outputDir
887 dependsOn cleanClover
889 delete sourceSets.test.java.outputDir
894 // format is a string like date.format("dd MMMM yyyy")
895 def getDate(format) {
896 def date = new Date()
897 return date.format(format)
902 def hashStdOut = new ByteArrayOutputStream()
904 commandLine "git", "rev-parse", "--short", "HEAD"
905 standardOutput = hashStdOut
909 def branchStdOut = new ByteArrayOutputStream()
911 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
912 standardOutput = branchStdOut
916 gitHash = hashStdOut.toString().trim()
917 gitBranch = branchStdOut.toString().trim()
919 outputs.upToDateWhen { false }
923 task createBuildProperties(type: WriteProperties) {
925 inputs.dir(sourceDir)
926 inputs.dir(resourceDir)
927 file(buildProperties).getParentFile().mkdirs()
928 outputFile (buildProperties)
929 // taking time specific comment out to allow better incremental builds
930 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
931 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
932 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
933 property "VERSION", JALVIEW_VERSION
934 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
935 outputs.file(outputFile)
939 task cleanBuildingHTML(type: Delete) {
946 task convertBuildingMD(type: Exec) {
947 dependsOn cleanBuildingHTML
948 def buildingMD = "${jalviewDir}/${doc_dir}/building.md"
949 def css = "${jalviewDir}/${doc_dir}/github.css"
952 pandoc_exec.split(",").each {
953 if (file(it.trim()).exists()) {
959 def hostname = "hostname".execute().text.trim()
960 def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
961 if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
962 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
966 if (pandoc != null && file(pandoc).exists()) {
967 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
969 println("Cannot find pandoc. Skipping convert building.md to HTML")
970 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
976 inputs.file(buildingMD)
978 outputs.file(buildingHTML)
989 task syncDocs(type: Sync) {
990 dependsOn convertBuildingMD
991 def syncDir = "${resourceClassesDir}/${doc_dir}"
992 from fileTree("${jalviewDir}/${doc_dir}")
998 task copyHelp(type: Copy) {
999 def inputDir = helpSourceDir
1000 def outputDir = "${resourceClassesDir}/${help_dir}"
1005 filter(ReplaceTokens,
1009 'Version-Rel': JALVIEW_VERSION,
1010 'Year-Rel': getDate("yyyy")
1021 inputs.dir(inputDir)
1022 outputs.files(helpFile)
1023 outputs.dir(outputDir)
1027 task syncLib(type: Sync) {
1028 def syncDir = "${resourceClassesDir}/${libDistDir}"
1029 from fileTree("${jalviewDir}/${libDistDir}")
1034 task syncResources(type: Sync) {
1037 into "${resourceClassesDir}"
1045 dependsOn syncResources
1051 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
1054 //dependsOn compileJava ////? DELETE
1057 dependsOn cloverClasses
1059 dependsOn compileJava //?
1063 includeGroups testng_groups
1064 excludeGroups testng_excluded_groups
1066 useDefaultListeners=true
1069 maxHeapSize = "1024m"
1071 workingDir = jalviewDir
1072 //systemProperties 'clover.jar' System.properties.clover.jar
1073 def testLaf = project.findProperty("test_laf")
1074 if (testLaf != null) {
1075 println("Setting Test LaF to '${testLaf}'")
1076 systemProperty "laf", testLaf
1078 def testHiDPIScale = project.findProperty("test_HiDPIScale")
1079 if (testHiDPIScale != null) {
1080 println("Setting Test HiDPI Scale to '${testHiDPIScale}'")
1081 systemProperty "sun.java2d.uiScale", testHiDPIScale
1083 sourceCompatibility = compile_source_compatibility
1084 targetCompatibility = compile_target_compatibility
1085 jvmArgs += additional_compiler_args
1089 println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
1095 task buildIndices(type: JavaExec) {
1097 classpath = sourceSets.main.compileClasspath
1098 main = "com.sun.java.help.search.Indexer"
1099 workingDir = "${classesDir}/${help_dir}"
1102 inputs.dir("${workingDir}/${argDir}")
1104 outputs.dir("${classesDir}/doc")
1105 outputs.dir("${classesDir}/help")
1106 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
1107 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
1108 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
1109 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
1110 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
1111 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
1115 task compileLinkCheck(type: JavaCompile) {
1117 classpath = files("${jalviewDir}/${utils_dir}")
1118 destinationDir = file("${jalviewDir}/${utils_dir}")
1119 source = fileTree(dir: "${jalviewDir}/${utils_dir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
1121 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1122 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1123 outputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.class")
1124 outputs.file("${jalviewDir}/${utils_dir}/BufferedLineReader.class")
1128 task linkCheck(type: JavaExec) {
1129 dependsOn prepare, compileLinkCheck
1131 def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
1132 classpath = files("${jalviewDir}/${utils_dir}")
1133 main = "HelpLinksChecker"
1134 workingDir = jalviewDir
1135 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
1137 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
1139 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1142 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1146 inputs.dir("${classesDir}/${help_dir}")
1147 outputs.file(helpLinksCheckerOutFile)
1150 // import the pubhtmlhelp target
1151 ant.properties.basedir = "${jalviewDir}"
1152 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
1153 ant.importBuild "${utils_dir}/publishHelp.xml"
1156 task cleanPackageDir(type: Delete) {
1158 delete fileTree(dir: "${jalviewDir}/${package_dir}", include: "*.jar")
1164 dependsOn buildIndices
1165 dependsOn createBuildProperties
1168 attributes "Main-Class": main_class,
1169 "Permissions": "all-permissions",
1170 "Application-Name": "Jalview Desktop",
1171 "Codebase": application_codebase
1174 destinationDir = file("${jalviewDir}/${package_dir}")
1175 archiveName = rootProject.name+".jar"
1181 exclude "**/*.jar.*"
1183 inputs.dir(classesDir)
1184 outputs.file("${jalviewDir}/${package_dir}/${archiveName}")
1188 task copyJars(type: Copy) {
1189 from fileTree(dir: classesDir, include: "**/*.jar").files
1190 into "${jalviewDir}/${package_dir}"
1194 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
1195 task syncJars(type: Sync) {
1196 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
1197 into "${jalviewDir}/${package_dir}"
1199 include jar.archiveName
1206 description = "Put all required libraries in dist"
1207 // order of "cleanPackageDir", "copyJars", "jar" important!
1208 jar.mustRunAfter cleanPackageDir
1209 syncJars.mustRunAfter cleanPackageDir
1210 dependsOn cleanPackageDir
1213 outputs.dir("${jalviewDir}/${package_dir}")
1218 dependsOn cleanPackageDir
1224 group = "distribution"
1228 from ("${jalviewDir}/${libDistDir}") {
1232 attributes 'Implementation-Version': JALVIEW_VERSION
1234 mainClassName = shadow_jar_main_class
1236 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
1241 task getdownWebsite() {
1242 group = "distribution"
1243 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
1248 def getdownWebsiteResourceFilenames = []
1249 def getdownTextString = ""
1250 def getdownResourceDir = getdownResourceDir
1251 def getdownResourceFilenames = []
1254 // clean the getdown website and files dir before creating getdown folders
1255 delete getdownWebsiteDir
1256 delete getdownFilesDir
1259 from buildProperties
1260 rename(build_properties_file, getdown_build_properties)
1263 getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1265 // set some getdown_txt_ properties then go through all properties looking for getdown_txt_...
1266 def props = project.properties.sort { it.key }
1267 if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
1268 props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
1270 if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
1271 props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
1273 if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
1274 props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
1277 props.put("getdown_txt_title", jalview_name)
1278 props.put("getdown_txt_ui.name", install4jApplicationName)
1280 // start with appbase
1281 getdownTextString += "appbase = ${getdownAppBase}\n"
1282 props.each{ prop, val ->
1283 if (prop.startsWith("getdown_txt_") && val != null) {
1284 if (prop.startsWith("getdown_txt_multi_")) {
1285 def key = prop.substring(18)
1286 val.split(",").each{ v ->
1287 def line = "${key} = ${v}\n"
1288 getdownTextString += line
1291 // file values rationalised
1292 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1294 if (val.indexOf('/') == 0) {
1297 } else if (val.indexOf('/') > 0) {
1298 // relative path (relative to jalviewDir)
1299 r = file( "${jalviewDir}/${val}" )
1302 val = "${getdown_resource_dir}/" + r.getName()
1303 getdownWebsiteResourceFilenames += val
1304 getdownResourceFilenames += r.getPath()
1307 if (! prop.startsWith("getdown_txt_resource")) {
1308 def line = prop.substring(12) + " = ${val}\n"
1309 getdownTextString += line
1315 getdownWebsiteResourceFilenames.each{ filename ->
1316 getdownTextString += "resource = ${filename}\n"
1318 getdownResourceFilenames.each{ filename ->
1321 into getdownResourceDir
1326 fileTree(file(package_dir)).each{ f ->
1327 if (f.isDirectory()) {
1328 def files = fileTree(dir: f, include: ["*"]).getFiles()
1330 } else if (f.exists()) {
1334 codeFiles.sort().each{f ->
1335 def name = f.getName()
1336 def line = "code = ${getdownAppDistDir}/${name}\n"
1337 getdownTextString += line
1344 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1346 if (JAVA_VERSION.equals("11")) {
1347 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1348 j11libFiles.sort().each{f ->
1349 def name = f.getName()
1350 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1351 getdownTextString += line
1354 into getdownJ11libDir
1360 // 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.
1361 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1362 getdownTextString += "resource = ${getdown_launcher_new}\n"
1363 getdownTextString += "class = ${mainClass}\n"
1365 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1366 getdown_txt.write(getdownTextString)
1368 def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
1369 def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
1370 launchJvl.write("appbase=${getdownAppBase}")
1373 from getdownLauncher
1374 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1375 into getdownWebsiteDir
1379 from getdownLauncher
1380 if (file(getdownLauncher).getName() != getdown_launcher) {
1381 rename(file(getdownLauncher).getName(), getdown_launcher)
1383 into getdownWebsiteDir
1386 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1389 from getdownLauncher
1390 from "${getdownWebsiteDir}/${getdown_build_properties}"
1391 if (file(getdownLauncher).getName() != getdown_launcher) {
1392 rename(file(getdownLauncher).getName(), getdown_launcher)
1394 into getdownInstallDir
1398 from getdownInstallDir
1399 into getdownFilesInstallDir
1406 from getdownLauncher
1407 from "${getdownWebsiteDir}/${getdown_build_properties}"
1408 if (file(getdownLauncher).getName() != getdown_launcher) {
1409 rename(file(getdownLauncher).getName(), getdown_launcher)
1411 into getdownFilesDir
1415 from getdownResourceDir
1416 into "${getdownFilesDir}/${getdown_resource_dir}"
1421 inputs.dir("${jalviewDir}/${package_dir}")
1423 outputs.dir(getdownWebsiteDir)
1424 outputs.dir(getdownFilesDir)
1428 // a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
1429 task getdownDigestDir(type: JavaExec) {
1431 description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..."
1433 def digestDirPropertyName = "DIGESTDIR"
1435 classpath = files(getdownLauncher)
1436 def digestDir = findProperty(digestDirPropertyName)
1437 if (digestDir == null) {
1438 throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
1442 main = "com.threerings.getdown.tools.Digester"
1446 task getdownDigest(type: JavaExec) {
1447 group = "distribution"
1448 description = "Digest the getdown website folder"
1449 dependsOn getdownWebsite
1451 classpath = files(getdownLauncher)
1453 main = "com.threerings.getdown.tools.Digester"
1454 args getdownWebsiteDir
1455 inputs.dir(getdownWebsiteDir)
1456 outputs.file("${getdownWebsiteDir}/digest2.txt")
1461 group = "distribution"
1462 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1463 dependsOn getdownDigest
1465 if (reportRsyncCommand) {
1466 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1467 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1468 println "LIKELY RSYNC COMMAND:"
1469 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1470 if (RUNRSYNC == "true") {
1472 commandLine "mkdir", "-p", toDir
1475 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1485 delete getdownWebsiteDir
1486 delete getdownFilesDir
1492 if (file(install4jHomeDir).exists()) {
1494 } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1495 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1496 } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1497 install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1499 installDir(file(install4jHomeDir))
1501 mediaTypes = Arrays.asList(install4j_media_types.split(","))
1505 task copyInstall4jTemplate {
1506 def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1507 def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1508 inputs.file(install4jTemplateFile)
1509 inputs.file(install4jFileAssociationsFile)
1510 inputs.property("CHANNEL", { CHANNEL })
1511 outputs.file(install4jConfFile)
1514 def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1516 // turn off code signing if no OSX_KEYPASS
1517 if (OSX_KEYPASS == "") {
1518 install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1519 codeSigning.'@macEnabled' = "false"
1521 install4jConfigXml.'**'.windows.each { windows ->
1522 windows.'@runPostProcessor' = "false"
1526 // turn off checksum creation for LOCAL channel
1527 def e = install4jConfigXml.application[0]
1528 if (CHANNEL == "LOCAL") {
1529 e.'@createChecksums' = "false"
1531 e.'@createChecksums' = "true"
1534 // put file association actions where placeholder action is
1535 def install4jFileAssociationsText = install4jFileAssociationsFile.text
1536 def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1537 install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
1538 if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1539 def parent = a.parent()
1541 fileAssociationActions.each { faa ->
1544 // don't need to continue in .any loop once replacements have been made
1549 // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
1550 // NB we're deleting the /other/ one!
1551 // Also remove the examples subdir from non-release versions
1552 def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
1553 // 2.11.1.0 NOT releasing with the Examples folder in the Program Group
1554 if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel
1555 customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
1557 // remove the examples subdir from Full File Set
1558 def files = install4jConfigXml.files[0]
1559 def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
1560 def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
1561 def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
1562 def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
1563 dirEntry.parent().remove(dirEntry)
1565 install4jConfigXml.'**'.action.any { a ->
1566 if (a.'@customizedId' == customizedIdToDelete) {
1567 def parent = a.parent()
1573 // remove the "Uninstall Old Jalview (optional)" symlink from DMG for non-release DS_Stores
1574 if (! (CHANNEL == "RELEASE" || CHANNEL == "TEST-RELEASE" ) ) {
1575 def symlink = install4jConfigXml.'**'.topLevelFiles.symlink.find { sl -> sl.'@name' == "Uninstall Old Jalview (optional).app" }
1576 symlink.parent().remove(symlink)
1579 // write install4j file
1580 install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1587 delete install4jConfFile
1592 task installers(type: com.install4j.gradle.Install4jTask) {
1593 group = "distribution"
1594 description = "Create the install4j installers"
1595 dependsOn setGitVals
1597 dependsOn copyInstall4jTemplate
1599 projectFile = install4jConfFile
1601 // create an md5 for the input files to use as version for install4j conf file
1602 def digest = MessageDigest.getInstance("MD5")
1604 (file("${install4jDir}/${install4j_template}").text +
1605 file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1606 file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1607 def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1608 if (filesMd5.length() >= 8) {
1609 filesMd5 = filesMd5.substring(0,8)
1611 def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1612 // make install4jBuildDir relative to jalviewDir
1613 def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
1616 'JALVIEW_NAME': jalview_name,
1617 'JALVIEW_APPLICATION_NAME': install4jApplicationName,
1618 'JALVIEW_DIR': "../..",
1619 'OSX_KEYSTORE': OSX_KEYSTORE,
1620 'JSIGN_SH': JSIGN_SH,
1621 'JRE_DIR': getdown_app_dir_java,
1622 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1623 'JALVIEW_VERSION': JALVIEW_VERSION,
1624 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1625 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1626 'JAVA_VERSION': JAVA_VERSION,
1627 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1628 'VERSION': JALVIEW_VERSION,
1629 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1630 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1631 'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
1632 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1633 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1634 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
1635 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1636 'BUNDLE_ID': install4jBundleId,
1637 'INTERNAL_ID': install4jInternalId,
1638 'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
1639 'MACOS_DS_STORE': install4jDSStore,
1640 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
1641 'INSTALLER_NAME': install4jInstallerName,
1642 'INSTALL4J_UTILS_DIR': install4j_utils_dir,
1643 'GETDOWN_WEBSITE_DIR': getdown_website_dir,
1644 'GETDOWN_FILES_DIR': getdown_files_dir,
1645 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1646 'GETDOWN_DIST_DIR': getdownAppDistDir,
1647 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1648 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1649 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1650 'BUILD_DIR': install4jBuildDir,
1651 'APPLICATION_CATEGORIES': install4j_application_categories,
1652 'APPLICATION_FOLDER': install4jApplicationFolder,
1653 'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
1654 'EXECUTABLE_NAME': install4jExecutableName,
1655 'EXTRA_SCHEME': install4jExtraScheme,
1658 //println("INSTALL4J VARIABLES:")
1659 //variables.each{k,v->println("${k}=${v}")}
1661 destination = "${jalviewDir}/${install4jBuildDir}"
1662 buildSelected = true
1664 if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
1666 disableSigning = true
1670 macKeystorePassword = OSX_KEYPASS
1674 println("Using projectFile "+projectFile)
1677 inputs.dir(getdownWebsiteDir)
1678 inputs.file(install4jConfFile)
1679 inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1680 inputs.dir(macosJavaVMDir)
1681 inputs.dir(windowsJavaVMDir)
1682 outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1686 task sourceDist(type: Tar) {
1688 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1689 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1690 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1692 archiveFileName = outputFileName
1693 } catch (Exception e) {
1694 archiveName = outputFileName
1697 compression Compression.GZIP
1712 "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
1714 "utils/InstallAnywhere",
1729 "gradle.properties",
1740 ".settings/org.eclipse.jdt.core.jalview.prefs",
1744 exclude (EXCLUDE_FILES)
1745 include (PROCESS_FILES)
1746 filter(ReplaceTokens,
1750 'Version-Rel': JALVIEW_VERSION,
1751 'Year-Rel': getDate("yyyy")
1756 exclude (EXCLUDE_FILES)
1757 exclude (PROCESS_FILES)
1758 exclude ("appletlib")
1759 exclude ("**/*locales")
1760 exclude ("*locales/**")
1761 exclude ("utils/InstallAnywhere")
1763 exclude (getdown_files_dir)
1764 exclude (getdown_website_dir)
1766 // exluding these as not using jars as modules yet
1767 exclude ("$j11modDir/**/*.jar")
1770 include(INCLUDE_FILES)
1772 // from (jalviewDir) {
1773 // // explicit includes for stuff that seemed to not get included
1774 // include(fileTree("test/**/*."))
1775 // exclude(EXCLUDE_FILES)
1776 // exclude(PROCESS_FILES)
1783 dependsOn pubhtmlhelp
1785 inputs.dir("${classesDir}/${help_dir}")
1786 outputs.dir("${buildDir}/distributions/${help_dir}")
1789 // LARGE AMOUNT OF JALVIEWJS STUFF DELETED HERE
1790 task eclipseAutoBuildTask {}
1791 task eclipseSynchronizationTask {}