1 /* Convention for properties. Read from gradle.properties, use lower_case_underlines for property names.
2 * For properties set within build.gradle, use camelCaseNoSpace.
4 import org.apache.tools.ant.filters.ReplaceTokens
5 import org.gradle.internal.os.OperatingSystem
6 import org.gradle.plugins.ide.eclipse.model.Output
7 import org.gradle.plugins.ide.eclipse.model.Library
8 import java.security.MessageDigest
9 import groovy.transform.ExternalizeMethods
10 import groovy.util.XmlParser
11 import groovy.xml.XmlUtil
26 id 'com.github.johnrengelman.shadow' version '4.0.3'
27 id 'com.install4j.gradle' version '8.0.4'
28 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 // can be "projectDir/local.properties"
50 def localProps = "${projectDir}/local.properties"
52 if (file(localProps).exists()) {
53 propsFile = localProps
55 // or "../projectDir_local.properties"
56 def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties"
57 if (file(dirLocalProps).exists()) {
58 propsFile = dirLocalProps
60 if (propsFile != null) {
62 def p = new Properties()
63 def localPropsFIS = new FileInputStream(propsFile)
68 def oldval = findProperty(key)
71 println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'")
73 println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'")
76 } catch (Exception e) {
77 System.out.println("Exception reading local.properties")
82 // Import releaseProps from the RELEASE file
83 // or a file specified via JALVIEW_RELEASE_FILE if defined
84 // Expect jalview.version and target release branch in jalview.release
85 def releaseProps = new Properties();
86 def releasePropFile = findProperty("JALVIEW_RELEASE_FILE");
87 def defaultReleasePropFile = "${jalviewDirAbsolutePath}/RELEASE";
89 (new File(releasePropFile!=null ? releasePropFile : defaultReleasePropFile)).withInputStream {
92 } catch (Exception fileLoadError) {
93 throw new Error("Couldn't load release properties file "+(releasePropFile==null ? defaultReleasePropFile : "from custom location: releasePropFile"),fileLoadError);
96 // Set JALVIEW_VERSION if it is not already set
97 if (findProperty(JALVIEW_VERSION)==null || "".equals(JALVIEW_VERSION)) {
98 JALVIEW_VERSION = releaseProps.get("jalview.version")
101 // this property set when running Eclipse headlessly
102 j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
103 // this property set by Eclipse
104 eclipseApplicationProperty = string("eclipse.application")
105 // CHECK IF RUNNING FROM WITHIN ECLIPSE
106 def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
107 IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
108 // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
109 if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
110 println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
114 println("WITHIN ECLIPSE IDE")
116 println("HEADLESS BUILD")
119 System.properties.sort { it.key }.each {
120 key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
123 if (false && IN_ECLIPSE) {
124 jalviewDir = jalviewDirAbsolutePath
129 bareSourceDir = string(source_dir)
130 sourceDir = string("${jalviewDir}/${bareSourceDir}")
131 resourceDir = string("${jalviewDir}/${resource_dir}")
132 bareTestSourceDir = string(test_source_dir)
133 testDir = string("${jalviewDir}/${bareTestSourceDir}")
135 classesDir = string("${jalviewDir}/${classes_dir}")
138 useClover = clover.equals("true")
139 cloverBuildDir = "${buildDir}/clover"
140 cloverInstrDir = file("${cloverBuildDir}/clover-instr")
141 cloverClassesDir = file("${cloverBuildDir}/clover-classes")
142 cloverReportDir = file("${buildDir}/reports/clover")
143 cloverTestInstrDir = file("${cloverBuildDir}/clover-test-instr")
144 cloverTestClassesDir = file("${cloverBuildDir}/clover-test-classes")
145 //cloverTestClassesDir = cloverClassesDir
146 cloverDb = string("${cloverBuildDir}/clover.db")
148 resourceClassesDir = useClover ? cloverClassesDir : classesDir
150 testSourceDir = useClover ? cloverTestInstrDir : testDir
151 testClassesDir = useClover ? cloverTestClassesDir : "${jalviewDir}/${test_output_dir}"
153 getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
156 // the following values might be overridden by the CHANNEL switch
157 getdownChannelName = CHANNEL.toLowerCase()
158 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
159 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
160 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
161 getdownAppDistDir = getdown_app_dir_alt
162 buildProperties = string("${classesDir}/${build_properties_file}")
163 reportRsyncCommand = false
164 jvlChannelName = CHANNEL.toLowerCase()
165 install4jSuffix = CHANNEL.substring(0, 1).toUpperCase() + CHANNEL.substring(1).toLowerCase(); // BUILD -> Build
166 install4jDSStore = "DS_Store-NON-RELEASE"
167 install4jDMGBackgroundImage = "jalview_dmg_background-NON-RELEASE.png"
168 install4jInstallerName = "${jalview_name} Non-Release Installer"
169 install4jExecutableName = jalview_name.replaceAll("[^\\w]+", "_").toLowerCase()
170 install4jExtraScheme = "jalviewx"
174 // TODO: get bamboo build artifact URL for getdown artifacts
175 getdown_channel_base = bamboo_channelbase
176 getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
177 getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
178 jvlChannelName += "_${getdownChannelName}"
179 // automatically add the test group Not-bamboo for exclusion
180 if ("".equals(testng_excluded_groups)) {
181 testng_excluded_groups = "Not-bamboo"
183 install4jExtraScheme = "jalviewb"
187 getdownAppDistDir = getdown_app_dir_release
188 reportRsyncCommand = true
190 install4jDSStore = "DS_Store"
191 install4jDMGBackgroundImage = "jalview_dmg_background.png"
192 install4jInstallerName = "${jalview_name} Installer"
196 getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
197 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
198 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
199 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
200 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
202 package_dir = string("${ARCHIVEDIR}/${package_dir}")
203 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
206 reportRsyncCommand = true
207 install4jExtraScheme = "jalviewa"
211 getdownChannelName = string("archive/${JALVIEW_VERSION}")
212 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
213 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
214 if (!file("${ARCHIVEDIR}/${package_dir}").exists()) {
215 throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
217 package_dir = string("${ARCHIVEDIR}/${package_dir}")
218 buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
221 reportRsyncCommand = true
222 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
223 install4jSuffix = "Archive"
224 install4jExtraScheme = "jalviewa"
228 reportRsyncCommand = true
230 // DEVELOP-RELEASE is usually associated with a Jalview release series so set the version
231 JALVIEW_VERSION=JALVIEW_VERSION+"-develop"
233 install4jSuffix = "Develop"
234 install4jDSStore = "DS_Store-DEVELOP"
235 install4jDMGBackgroundImage = "jalview_dmg_background-DEVELOP.png"
236 install4jExtraScheme = "jalviewd"
237 install4jInstallerName = "${jalview_name} Develop Installer"
241 reportRsyncCommand = true
243 // TEST-RELEASE is usually associated with a Jalview release series so set the version
244 JALVIEW_VERSION=JALVIEW_VERSION+"-test"
246 install4jSuffix = "Test"
247 install4jDSStore = "DS_Store-TEST-RELEASE"
248 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
249 install4jExtraScheme = "jalviewt"
250 install4jInstallerName = "${jalview_name} Test Installer"
253 case ~/^SCRATCH(|-[-\w]*)$/:
254 getdownChannelName = CHANNEL
255 getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
256 getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
257 reportRsyncCommand = true
258 install4jSuffix = "Scratch"
262 if (!file("${LOCALDIR}").exists()) {
263 throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
265 getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
266 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
268 JALVIEW_VERSION = "TEST"
269 install4jSuffix = "Test-Local"
270 install4jDSStore = "DS_Store-TEST-RELEASE"
271 install4jDMGBackgroundImage = "jalview_dmg_background-TEST.png"
272 install4jExtraScheme = "jalviewt"
273 install4jInstallerName = "${jalview_name} Test Installer"
277 getdownAppBase = file(getdownWebsiteDir).toURI().toString()
278 getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
279 install4jExtraScheme = "jalviewl"
282 default: // something wrong specified
283 throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
287 // override getdownAppBase if requested
288 if (findProperty("getdown_appbase_override") != null) {
289 getdownAppBase = string(getProperty("getdown_appbase_override"))
290 println("Overriding getdown appbase with '${getdownAppBase}'")
292 // sanitise file name for jalview launcher file for this channel
293 jvlChannelName = jvlChannelName.replaceAll("[^\\w\\-]+", "_")
294 // install4j application and folder names
295 if (install4jSuffix == "") {
296 install4jApplicationName = "${jalview_name}"
297 install4jBundleId = "${install4j_bundle_id}"
298 install4jWinApplicationId = install4j_release_win_application_id
300 install4jApplicationName = "${jalview_name} ${install4jSuffix}"
301 install4jBundleId = "${install4j_bundle_id}-" + install4jSuffix.toLowerCase()
302 // add int hash of install4jSuffix to the last part of the application_id
303 def id = install4j_release_win_application_id
304 def idsplitreverse = id.split("-").reverse()
305 idsplitreverse[0] = idsplitreverse[0].toInteger() + install4jSuffix.hashCode()
306 install4jWinApplicationId = idsplitreverse.reverse().join("-")
308 // sanitise folder and id names
309 // install4jApplicationFolder = e.g. "Jalview Build"
310 install4jApplicationFolder = install4jApplicationName
311 .replaceAll("[\"'~:/\\\\\\s]", "_") // replace all awkward filename chars " ' ~ : / \
312 .replaceAll("_+", "_") // collapse __
313 install4jInternalId = install4jApplicationName
315 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
316 .replaceAll("_+", "") // collapse __
317 //.replaceAll("_*-_*", "-") // collapse _-_
318 install4jUnixApplicationFolder = install4jApplicationName
320 .replaceAll("[^\\w\\-\\.]", "_") // replace other non [alphanumeric,_,-,.]
321 .replaceAll("_+", "_") // collapse __
322 .replaceAll("_*-_*", "-") // collapse _-_
325 getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
326 //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
327 getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
328 getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
329 getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
330 getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
331 /* compile without modules -- using classpath libraries
332 modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
333 modules_runtimeClasspath = modules_compileClasspath
336 gitBranch = string("")
338 println("Using a ${CHANNEL} profile.")
340 additional_compiler_args = []
341 // configure classpath/args for j8/j11 compilation
342 if (JAVA_VERSION.equals("1.8")) {
343 JAVA_INTEGER_VERSION = string("8")
346 libDistDir = j8libDir
347 compile_source_compatibility = 1.8
348 compile_target_compatibility = 1.8
349 // these are getdown.txt properties defined dependent on the JAVA_VERSION
350 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
351 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
352 // this property is assigned below and expanded to multiple lines in the getdown task
353 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
354 // this property is for the Java library used in eclipse
355 eclipseJavaRuntimeName = string("JavaSE-1.8")
356 } else if (JAVA_VERSION.equals("11")) {
357 JAVA_INTEGER_VERSION = string("11")
359 libDistDir = j11libDir
360 compile_source_compatibility = 11
361 compile_target_compatibility = 11
362 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
363 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
364 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
365 eclipseJavaRuntimeName = string("JavaSE-11")
366 /* compile without modules -- using classpath libraries
367 additional_compiler_args += [
368 '--module-path', modules_compileClasspath.asPath,
369 '--add-modules', j11modules
372 } else if (JAVA_VERSION.equals("12") || JAVA_VERSION.equals("13")) {
373 JAVA_INTEGER_VERSION = JAVA_VERSION
375 libDistDir = j11libDir
376 compile_source_compatibility = JAVA_VERSION
377 compile_target_compatibility = JAVA_VERSION
378 getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
379 getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
380 getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
381 eclipseJavaRuntimeName = string("JavaSE-11")
382 /* compile without modules -- using classpath libraries
383 additional_compiler_args += [
384 '--module-path', modules_compileClasspath.asPath,
385 '--add-modules', j11modules
389 throw new GradleException("JAVA_VERSION=${JAVA_VERSION} not currently supported by Jalview")
394 JAVA_MIN_VERSION = JAVA_VERSION
395 JAVA_MAX_VERSION = JAVA_VERSION
396 def jreInstallsDir = string(jre_installs_dir)
397 if (jreInstallsDir.startsWith("~/")) {
398 jreInstallsDir = System.getProperty("user.home") + jreInstallsDir.substring(1)
400 macosJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-mac-x64/jre")
401 macosJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-mac-x64.tar.gz")
402 windowsJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-windows-x64/jre")
403 windowsJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-windows-x64.tar.gz")
404 linuxJavaVMDir = string("${jreInstallsDir}/jre-${JAVA_INTEGER_VERSION}-linux-x64/jre")
405 linuxJavaVMTgz = string("${jreInstallsDir}/tgz/jre-${JAVA_INTEGER_VERSION}-linux-x64.tar.gz")
406 install4jDir = string("${jalviewDir}/${install4j_utils_dir}")
407 install4jConfFileName = string("jalview-install4j-conf.install4j")
408 install4jConfFile = file("${install4jDir}/${install4jConfFileName}")
409 install4jHomeDir = install4j_home_dir
410 if (install4jHomeDir.startsWith("~/")) {
411 install4jHomeDir = System.getProperty("user.home") + install4jHomeDir.substring(1)
416 buildingHTML = string("${jalviewDir}/${doc_dir}/building.html")
417 helpFile = string("${resourceClassesDir}/${help_dir}/help.jhm")
418 helpParentDir = string("${jalviewDir}/${help_parent_dir}")
419 helpSourceDir = string("${helpParentDir}/${help_dir}")
422 relativeBuildDir = file(jalviewDirAbsolutePath).toPath().relativize(buildDir.toPath())
423 jalviewjsBuildDir = string("${relativeBuildDir}/jalviewjs")
424 jalviewjsSiteDir = string("${jalviewjsBuildDir}/${jalviewjs_site_dir}")
426 jalviewjsTransferSiteJsDir = string(jalviewjsSiteDir)
428 jalviewjsTransferSiteJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_js")
430 jalviewjsTransferSiteLibDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_lib")
431 jalviewjsTransferSiteSwingJsDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_swingjs")
432 jalviewjsTransferSiteCoreDir = string("${jalviewjsBuildDir}/tmp/${jalviewjs_site_dir}_core")
433 jalviewjsJalviewCoreHtmlFile = string("")
434 jalviewjsJalviewCoreName = string(jalviewjs_core_name)
435 jalviewjsCoreClasslists = []
436 jalviewjsJalviewTemplateName = string(jalviewjs_name)
437 jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
438 jalviewjsJ2sProps = null
440 eclipseWorkspace = null
441 eclipseBinary = string("")
442 eclipseVersion = string("")
452 outputDir = file(classesDir)
457 srcDirs += helpParentDir
460 jar.destinationDir = file("${jalviewDir}/${package_dir}")
462 compileClasspath = files(sourceSets.main.java.outputDir)
463 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
465 runtimeClasspath = compileClasspath
470 srcDirs cloverInstrDir
471 outputDir = cloverClassesDir
475 srcDirs = sourceSets.main.resources.srcDirs
478 compileClasspath = files( sourceSets.clover.java.outputDir )
479 //compileClasspath += files( testClassesDir )
480 compileClasspath += fileTree(dir: "${jalviewDir}/${libDir}", include: ["*.jar"])
481 compileClasspath += fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
482 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
484 runtimeClasspath = compileClasspath
489 srcDirs testSourceDir
490 outputDir = file(testClassesDir)
494 srcDirs = useClover ? sourceSets.clover.resources.srcDirs : sourceSets.main.resources.srcDirs
497 compileClasspath = files( sourceSets.test.java.outputDir )
498 compileClasspath += useClover ? sourceSets.clover.compileClasspath : sourceSets.main.compileClasspath
499 compileClasspath += fileTree(dir: "${jalviewDir}/${utils_dir}/testnglibs", include: ["**/*.jar"])
501 runtimeClasspath = compileClasspath
507 // eclipse project and settings files creation, also used by buildship
510 name = eclipse_project_name
512 natures 'org.eclipse.jdt.core.javanature',
513 'org.eclipse.jdt.groovy.core.groovyNature',
514 'org.eclipse.buildship.core.gradleprojectnature'
516 buildCommand 'org.eclipse.jdt.core.javabuilder'
517 buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
521 //defaultOutputDir = sourceSets.main.java.outputDir
524 if (it.isCanBeResolved()) {
529 minusConfigurations += removeThese
530 plusConfigurations = [ ]
534 def removeTheseToo = []
535 HashMap<String, Boolean> alreadyAddedSrcPath = new HashMap<>();
536 cp.entries.each { entry ->
537 // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test".
538 // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover
539 // we add the resources and help/help dirs in as libs afterwards (see below)
540 if (entry.kind == 'src') {
541 if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) {
542 removeTheseToo += entry
544 alreadyAddedSrcPath.putAt(entry.path, true)
549 cp.entries.removeAll(removeTheseToo)
551 //cp.entries += new Output("${eclipse_bin_dir}/main")
552 if (file(helpParentDir).isDirectory()) {
553 cp.entries += new Library(fileReference(helpParentDir))
555 if (file(resourceDir).isDirectory()) {
556 cp.entries += new Library(fileReference(resourceDir))
559 HashMap<String, Boolean> alreadyAddedLibPath = new HashMap<>();
561 sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
562 //don't want to add outputDir as eclipse is using its own output dir in bin/main
563 if (it.isDirectory() || ! it.exists()) {
564 // don't add dirs to classpath, especially if they don't exist
565 return false // groovy "continue" in .any closure
567 def itPath = it.toString()
568 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
569 // make relative path
570 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
572 if (alreadyAddedLibPath.get(itPath)) {
573 //println("Not adding duplicate entry "+itPath)
575 //println("Adding entry "+itPath)
576 cp.entries += new Library(fileReference(itPath))
577 alreadyAddedLibPath.put(itPath, true)
581 sourceSets.test.compileClasspath.findAll { it.name.endsWith(".jar") }.any {
582 //no longer want to add outputDir as eclipse is using its own output dir in bin/main
583 if (it.isDirectory() || ! it.exists()) {
584 // don't add dirs to classpath
585 return false // groovy "continue" in .any closure
588 def itPath = it.toString()
589 if (itPath.startsWith("${jalviewDirAbsolutePath}/")) {
590 itPath = itPath.substring(jalviewDirAbsolutePath.length()+1)
592 if (alreadyAddedLibPath.get(itPath)) {
595 def lib = new Library(fileReference(itPath))
596 lib.entryAttributes["test"] = "true"
598 alreadyAddedLibPath.put(itPath, true)
606 containers 'org.eclipse.buildship.core.gradleclasspathcontainer'
611 // for the IDE, use java 11 compatibility
612 sourceCompatibility = compile_source_compatibility
613 targetCompatibility = compile_target_compatibility
614 javaRuntimeName = eclipseJavaRuntimeName
616 // add in jalview project specific properties/preferences into eclipse core preferences
618 withProperties { props ->
619 def jalview_prefs = new Properties()
620 def ins = new FileInputStream("${jalviewDirAbsolutePath}/${eclipse_extra_jdt_prefs_file}")
621 jalview_prefs.load(ins)
623 jalview_prefs.forEach { t, v ->
624 if (props.getAt(t) == null) {
634 // Don't want these to be activated if in headless build
635 synchronizationTasks "eclipseSynchronizationTask"
636 autoBuildTasks "eclipseAutoBuildTask"
647 delete cloverBuildDir
648 delete cloverReportDir
653 task cloverInstrJava(type: JavaExec) {
654 group = "Verification"
655 description = "Create clover instrumented source java files"
657 dependsOn cleanClover
659 inputs.files(sourceSets.main.allJava)
660 outputs.dir(cloverInstrDir)
662 //classpath = fileTree(dir: "${jalviewDir}/${clover_lib_dir}", include: ["*.jar"])
663 classpath = sourceSets.clover.compileClasspath
664 main = "com.atlassian.clover.CloverInstr"
672 cloverInstrDir.getPath(),
674 def srcFiles = sourceSets.main.allJava.files
677 { file -> file.absolutePath }
680 args argsList.toArray()
683 delete cloverInstrDir
684 println("Clover: About to instrument "+srcFiles.size() +" files")
689 task cloverInstrTests(type: JavaExec) {
690 group = "Verification"
691 description = "Create clover instrumented source test files"
693 dependsOn cleanClover
695 inputs.files(testDir)
696 outputs.dir(cloverTestInstrDir)
698 classpath = sourceSets.clover.compileClasspath
699 main = "com.atlassian.clover.CloverInstr"
709 cloverTestInstrDir.getPath(),
711 args argsList.toArray()
714 delete cloverTestInstrDir
715 println("Clover: About to instrument test files")
721 group = "Verification"
722 description = "Create clover instrumented all source files"
724 dependsOn cloverInstrJava
725 dependsOn cloverInstrTests
729 cloverClasses.dependsOn cloverInstr
732 task cloverConsoleReport(type: JavaExec) {
733 group = "Verification"
734 description = "Creates clover console report"
737 file(cloverDb).exists()
740 inputs.dir cloverClassesDir
742 classpath = sourceSets.clover.runtimeClasspath
743 main = "com.atlassian.clover.reporters.console.ConsoleReporter"
745 if (cloverreport_mem.length() > 0) {
746 maxHeapSize = cloverreport_mem
748 if (cloverreport_jvmargs.length() > 0) {
749 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
759 args argsList.toArray()
763 task cloverHtmlReport(type: JavaExec) {
764 group = "Verification"
765 description = "Creates clover HTML report"
768 file(cloverDb).exists()
771 def cloverHtmlDir = cloverReportDir
772 inputs.dir cloverClassesDir
773 outputs.dir cloverHtmlDir
775 classpath = sourceSets.clover.runtimeClasspath
776 main = "com.atlassian.clover.reporters.html.HtmlReporter"
778 if (cloverreport_mem.length() > 0) {
779 maxHeapSize = cloverreport_mem
781 if (cloverreport_jvmargs.length() > 0) {
782 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
793 if (cloverreport_html_options.length() > 0) {
794 argsList += cloverreport_html_options.split(" ")
797 args argsList.toArray()
801 task cloverXmlReport(type: JavaExec) {
802 group = "Verification"
803 description = "Creates clover XML report"
806 file(cloverDb).exists()
809 def cloverXmlFile = "${cloverReportDir}/clover.xml"
810 inputs.dir cloverClassesDir
811 outputs.file cloverXmlFile
813 classpath = sourceSets.clover.runtimeClasspath
814 main = "com.atlassian.clover.reporters.xml.XMLReporter"
816 if (cloverreport_mem.length() > 0) {
817 maxHeapSize = cloverreport_mem
819 if (cloverreport_jvmargs.length() > 0) {
820 jvmArgs Arrays.asList(cloverreport_jvmargs.split(" "))
831 if (cloverreport_xml_options.length() > 0) {
832 argsList += cloverreport_xml_options.split(" ")
835 args argsList.toArray()
840 group = "Verification"
841 description = "Creates clover reports"
843 dependsOn cloverXmlReport
844 dependsOn cloverHtmlReport
851 sourceCompatibility = compile_source_compatibility
852 targetCompatibility = compile_target_compatibility
853 options.compilerArgs += additional_compiler_args
854 print ("Setting target compatibility to "+targetCompatibility+"\n")
856 //classpath += configurations.cloverRuntime
864 sourceCompatibility = compile_source_compatibility
865 targetCompatibility = compile_target_compatibility
866 options.compilerArgs = additional_compiler_args
867 print ("Setting target compatibility to "+targetCompatibility+"\n")
875 sourceCompatibility = compile_source_compatibility
876 targetCompatibility = compile_target_compatibility
877 options.compilerArgs = additional_compiler_args
878 print ("Setting target compatibility to "+targetCompatibility+"\n")
885 delete sourceSets.main.java.outputDir
891 dependsOn cleanClover
893 delete sourceSets.test.java.outputDir
898 // format is a string like date.format("dd MMMM yyyy")
899 def getDate(format) {
900 def date = new Date()
901 return date.format(format)
906 def hashStdOut = new ByteArrayOutputStream()
908 commandLine "git", "rev-parse", "--short", "HEAD"
909 standardOutput = hashStdOut
913 def branchStdOut = new ByteArrayOutputStream()
915 commandLine "git", "rev-parse", "--abbrev-ref", "HEAD"
916 standardOutput = branchStdOut
920 gitHash = hashStdOut.toString().trim()
921 gitBranch = branchStdOut.toString().trim()
923 outputs.upToDateWhen { false }
927 task createBuildProperties(type: WriteProperties) {
929 inputs.dir(sourceDir)
930 inputs.dir(resourceDir)
931 file(buildProperties).getParentFile().mkdirs()
932 outputFile (buildProperties)
933 // taking time specific comment out to allow better incremental builds
934 comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd HH:mm:ss")
935 //comment "--Jalview Build Details--\n"+getDate("yyyy-MM-dd")
936 property "BUILD_DATE", getDate("HH:mm:ss dd MMMM yyyy")
937 property "VERSION", JALVIEW_VERSION
938 property "INSTALLATION", INSTALLATION+" git-commit:"+gitHash+" ["+gitBranch+"]"
939 outputs.file(outputFile)
943 task cleanBuildingHTML(type: Delete) {
950 task convertBuildingMD(type: Exec) {
951 dependsOn cleanBuildingHTML
952 def buildingMD = "${jalviewDir}/${doc_dir}/building.md"
953 def css = "${jalviewDir}/${doc_dir}/github.css"
956 pandoc_exec.split(",").each {
957 if (file(it.trim()).exists()) {
963 def hostname = "hostname".execute().text.trim()
964 def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
965 if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
966 pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
970 if (pandoc != null && file(pandoc).exists()) {
971 commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD
973 println("Cannot find pandoc. Skipping convert building.md to HTML")
974 throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML")
980 inputs.file(buildingMD)
982 outputs.file(buildingHTML)
993 task syncDocs(type: Sync) {
994 dependsOn convertBuildingMD
995 def syncDir = "${resourceClassesDir}/${doc_dir}"
996 from fileTree("${jalviewDir}/${doc_dir}")
1002 task copyHelp(type: Copy) {
1003 def inputDir = helpSourceDir
1004 def outputDir = "${resourceClassesDir}/${help_dir}"
1009 filter(ReplaceTokens,
1013 'Version-Rel': JALVIEW_VERSION,
1014 'Year-Rel': getDate("yyyy")
1025 inputs.dir(inputDir)
1026 outputs.files(helpFile)
1027 outputs.dir(outputDir)
1031 task syncLib(type: Sync) {
1032 def syncDir = "${resourceClassesDir}/${libDistDir}"
1033 from fileTree("${jalviewDir}/${libDistDir}")
1038 task syncResources(type: Sync) {
1041 into "${resourceClassesDir}"
1049 dependsOn syncResources
1055 //testReportDirName = "test-reports" // note that test workingDir will be $jalviewDir
1058 //dependsOn compileJava ////? DELETE
1061 dependsOn cloverClasses
1063 dependsOn compileJava //?
1067 includeGroups testng_groups
1068 excludeGroups testng_excluded_groups
1070 useDefaultListeners=true
1073 maxHeapSize = "1024m"
1075 workingDir = jalviewDir
1076 //systemProperties 'clover.jar' System.properties.clover.jar
1077 def testLaf = project.findProperty("test_laf")
1078 if (testLaf != null) {
1079 println("Setting Test LaF to '${testLaf}'")
1080 systemProperty "laf", testLaf
1082 def testHiDPIScale = project.findProperty("test_HiDPIScale")
1083 if (testHiDPIScale != null) {
1084 println("Setting Test HiDPI Scale to '${testHiDPIScale}'")
1085 systemProperty "sun.java2d.uiScale", testHiDPIScale
1087 sourceCompatibility = compile_source_compatibility
1088 targetCompatibility = compile_target_compatibility
1089 jvmArgs += additional_compiler_args
1093 println("Running tests " + (useClover?"WITH":"WITHOUT") + " clover")
1099 task buildIndices(type: JavaExec) {
1101 classpath = sourceSets.main.compileClasspath
1102 main = "com.sun.java.help.search.Indexer"
1103 workingDir = "${classesDir}/${help_dir}"
1106 inputs.dir("${workingDir}/${argDir}")
1108 outputs.dir("${classesDir}/doc")
1109 outputs.dir("${classesDir}/help")
1110 outputs.file("${workingDir}/JavaHelpSearch/DOCS")
1111 outputs.file("${workingDir}/JavaHelpSearch/DOCS.TAB")
1112 outputs.file("${workingDir}/JavaHelpSearch/OFFSETS")
1113 outputs.file("${workingDir}/JavaHelpSearch/POSITIONS")
1114 outputs.file("${workingDir}/JavaHelpSearch/SCHEMA")
1115 outputs.file("${workingDir}/JavaHelpSearch/TMAP")
1119 task compileLinkCheck(type: JavaCompile) {
1121 classpath = files("${jalviewDir}/${utils_dir}")
1122 destinationDir = file("${jalviewDir}/${utils_dir}")
1123 source = fileTree(dir: "${jalviewDir}/${utils_dir}", include: ["HelpLinksChecker.java", "BufferedLineReader.java"])
1125 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1126 inputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.java")
1127 outputs.file("${jalviewDir}/${utils_dir}/HelpLinksChecker.class")
1128 outputs.file("${jalviewDir}/${utils_dir}/BufferedLineReader.class")
1132 task linkCheck(type: JavaExec) {
1133 dependsOn prepare, compileLinkCheck
1135 def helpLinksCheckerOutFile = file("${jalviewDir}/${utils_dir}/HelpLinksChecker.out")
1136 classpath = files("${jalviewDir}/${utils_dir}")
1137 main = "HelpLinksChecker"
1138 workingDir = jalviewDir
1139 args = [ "${classesDir}/${help_dir}", "-nointernet" ]
1141 def outFOS = new FileOutputStream(helpLinksCheckerOutFile, false) // false == don't append
1143 standardOutput = new org.apache.tools.ant.util.TeeOutputStream(
1146 errorOutput = new org.apache.tools.ant.util.TeeOutputStream(
1150 inputs.dir("${classesDir}/${help_dir}")
1151 outputs.file(helpLinksCheckerOutFile)
1154 // import the pubhtmlhelp target
1155 ant.properties.basedir = "${jalviewDir}"
1156 ant.properties.helpBuildDir = "${jalviewDirAbsolutePath}/${classes_dir}/${help_dir}"
1157 ant.importBuild "${utils_dir}/publishHelp.xml"
1160 task cleanPackageDir(type: Delete) {
1162 delete fileTree(dir: "${jalviewDir}/${package_dir}", include: "*.jar")
1168 dependsOn buildIndices
1169 dependsOn createBuildProperties
1172 attributes "Main-Class": main_class,
1173 "Permissions": "all-permissions",
1174 "Application-Name": "Jalview Desktop",
1175 "Codebase": application_codebase
1178 destinationDir = file("${jalviewDir}/${package_dir}")
1179 archiveName = rootProject.name+".jar"
1185 exclude "**/*.jar.*"
1187 inputs.dir(classesDir)
1188 outputs.file("${jalviewDir}/${package_dir}/${archiveName}")
1192 task copyJars(type: Copy) {
1193 from fileTree(dir: classesDir, include: "**/*.jar").files
1194 into "${jalviewDir}/${package_dir}"
1198 // doing a Sync instead of Copy as Copy doesn't deal with "outputs" very well
1199 task syncJars(type: Sync) {
1200 from fileTree(dir: "${jalviewDir}/${libDistDir}", include: "**/*.jar").files
1201 into "${jalviewDir}/${package_dir}"
1203 include jar.archiveName
1210 description = "Put all required libraries in dist"
1211 // order of "cleanPackageDir", "copyJars", "jar" important!
1212 jar.mustRunAfter cleanPackageDir
1213 syncJars.mustRunAfter cleanPackageDir
1214 dependsOn cleanPackageDir
1217 outputs.dir("${jalviewDir}/${package_dir}")
1222 dependsOn cleanPackageDir
1228 group = "distribution"
1232 from ("${jalviewDir}/${libDistDir}") {
1236 attributes 'Implementation-Version': JALVIEW_VERSION
1238 mainClassName = shadow_jar_main_class
1240 classifier = "all-"+JALVIEW_VERSION+"-j"+JAVA_VERSION
1245 task getdownWebsite() {
1246 group = "distribution"
1247 description = "Create the getdown minimal app folder, and website folder for this version of jalview. Website folder also used for offline app installer"
1252 def getdownWebsiteResourceFilenames = []
1253 def getdownTextString = ""
1254 def getdownResourceDir = getdownResourceDir
1255 def getdownResourceFilenames = []
1258 // clean the getdown website and files dir before creating getdown folders
1259 delete getdownWebsiteDir
1260 delete getdownFilesDir
1263 from buildProperties
1264 rename(build_properties_file, getdown_build_properties)
1267 getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
1269 // set some getdown_txt_ properties then go through all properties looking for getdown_txt_...
1270 def props = project.properties.sort { it.key }
1271 if (getdownAltJavaMinVersion != null && getdownAltJavaMinVersion.length() > 0) {
1272 props.put("getdown_txt_java_min_version", getdownAltJavaMinVersion)
1274 if (getdownAltJavaMaxVersion != null && getdownAltJavaMaxVersion.length() > 0) {
1275 props.put("getdown_txt_java_max_version", getdownAltJavaMaxVersion)
1277 if (getdownAltMultiJavaLocation != null && getdownAltMultiJavaLocation.length() > 0) {
1278 props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
1281 props.put("getdown_txt_title", jalview_name)
1282 props.put("getdown_txt_ui.name", install4jApplicationName)
1284 // start with appbase
1285 getdownTextString += "appbase = ${getdownAppBase}\n"
1286 props.each{ prop, val ->
1287 if (prop.startsWith("getdown_txt_") && val != null) {
1288 if (prop.startsWith("getdown_txt_multi_")) {
1289 def key = prop.substring(18)
1290 val.split(",").each{ v ->
1291 def line = "${key} = ${v}\n"
1292 getdownTextString += line
1295 // file values rationalised
1296 if (val.indexOf('/') > -1 || prop.startsWith("getdown_txt_resource")) {
1298 if (val.indexOf('/') == 0) {
1301 } else if (val.indexOf('/') > 0) {
1302 // relative path (relative to jalviewDir)
1303 r = file( "${jalviewDir}/${val}" )
1306 val = "${getdown_resource_dir}/" + r.getName()
1307 getdownWebsiteResourceFilenames += val
1308 getdownResourceFilenames += r.getPath()
1311 if (! prop.startsWith("getdown_txt_resource")) {
1312 def line = prop.substring(12) + " = ${val}\n"
1313 getdownTextString += line
1319 getdownWebsiteResourceFilenames.each{ filename ->
1320 getdownTextString += "resource = ${filename}\n"
1322 getdownResourceFilenames.each{ filename ->
1325 into getdownResourceDir
1330 fileTree(file(package_dir)).each{ f ->
1331 if (f.isDirectory()) {
1332 def files = fileTree(dir: f, include: ["*"]).getFiles()
1334 } else if (f.exists()) {
1338 codeFiles.sort().each{f ->
1339 def name = f.getName()
1340 def line = "code = ${getdownAppDistDir}/${name}\n"
1341 getdownTextString += line
1348 // NOT USING MODULES YET, EVERYTHING SHOULD BE IN dist
1350 if (JAVA_VERSION.equals("11")) {
1351 def j11libFiles = fileTree(dir: "${jalviewDir}/${j11libDir}", include: ["*.jar"]).getFiles()
1352 j11libFiles.sort().each{f ->
1353 def name = f.getName()
1354 def line = "code = ${getdown_j11lib_dir}/${name}\n"
1355 getdownTextString += line
1358 into getdownJ11libDir
1364 // 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.
1365 //getdownTextString += "class = " + file(getdownLauncher).getName() + "\n"
1366 getdownTextString += "resource = ${getdown_launcher_new}\n"
1367 getdownTextString += "class = ${main_class}\n"
1369 def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
1370 getdown_txt.write(getdownTextString)
1372 def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
1373 def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
1374 launchJvl.write("appbase=${getdownAppBase}")
1377 from getdownLauncher
1378 rename(file(getdownLauncher).getName(), getdown_launcher_new)
1379 into getdownWebsiteDir
1383 from getdownLauncher
1384 if (file(getdownLauncher).getName() != getdown_launcher) {
1385 rename(file(getdownLauncher).getName(), getdown_launcher)
1387 into getdownWebsiteDir
1390 if (! (CHANNEL.startsWith("ARCHIVE") || CHANNEL.startsWith("DEVELOP"))) {
1393 from getdownLauncher
1394 from "${getdownWebsiteDir}/${getdown_build_properties}"
1395 if (file(getdownLauncher).getName() != getdown_launcher) {
1396 rename(file(getdownLauncher).getName(), getdown_launcher)
1398 into getdownInstallDir
1402 from getdownInstallDir
1403 into getdownFilesInstallDir
1410 from getdownLauncher
1411 from "${getdownWebsiteDir}/${getdown_build_properties}"
1412 if (file(getdownLauncher).getName() != getdown_launcher) {
1413 rename(file(getdownLauncher).getName(), getdown_launcher)
1415 into getdownFilesDir
1419 from getdownResourceDir
1420 into "${getdownFilesDir}/${getdown_resource_dir}"
1425 inputs.dir("${jalviewDir}/${package_dir}")
1427 outputs.dir(getdownWebsiteDir)
1428 outputs.dir(getdownFilesDir)
1432 // a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
1433 task getdownDigestDir(type: JavaExec) {
1435 description "A task to run a getdown Digest on a dir with getdown.txt. Provide a DIGESTDIR property via -PDIGESTDIR=..."
1437 def digestDirPropertyName = "DIGESTDIR"
1439 classpath = files(getdownLauncher)
1440 def digestDir = findProperty(digestDirPropertyName)
1441 if (digestDir == null) {
1442 throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
1446 main = "com.threerings.getdown.tools.Digester"
1450 task getdownDigest(type: JavaExec) {
1451 group = "distribution"
1452 description = "Digest the getdown website folder"
1453 dependsOn getdownWebsite
1455 classpath = files(getdownLauncher)
1457 main = "com.threerings.getdown.tools.Digester"
1458 args getdownWebsiteDir
1459 inputs.dir(getdownWebsiteDir)
1460 outputs.file("${getdownWebsiteDir}/digest2.txt")
1465 group = "distribution"
1466 description = "Create the minimal and full getdown app folder for installers and website and create digest file"
1467 dependsOn getdownDigest
1469 if (reportRsyncCommand) {
1470 def fromDir = getdownWebsiteDir + (getdownWebsiteDir.endsWith('/')?'':'/')
1471 def toDir = "${getdown_rsync_dest}/${getdownDir}" + (getdownDir.endsWith('/')?'':'/')
1472 println "LIKELY RSYNC COMMAND:"
1473 println "mkdir -p '$toDir'\nrsync -avh --delete '$fromDir' '$toDir'"
1474 if (RUNRSYNC == "true") {
1476 commandLine "mkdir", "-p", toDir
1479 commandLine "rsync", "-avh", "--delete", fromDir, toDir
1489 delete getdownWebsiteDir
1490 delete getdownFilesDir
1496 if (file(install4jHomeDir).exists()) {
1498 } else if (file(System.getProperty("user.home")+"/buildtools/install4j").exists()) {
1499 install4jHomeDir = System.getProperty("user.home")+"/buildtools/install4j"
1500 } else if (file("/Applications/install4j.app/Contents/Resources/app").exists()) {
1501 install4jHomeDir = "/Applications/install4j.app/Contents/Resources/app"
1503 installDir(file(install4jHomeDir))
1505 mediaTypes = Arrays.asList(install4j_media_types.split(","))
1509 task copyInstall4jTemplate {
1510 def install4jTemplateFile = file("${install4jDir}/${install4j_template}")
1511 def install4jFileAssociationsFile = file("${install4jDir}/${install4j_installer_file_associations}")
1512 inputs.file(install4jTemplateFile)
1513 inputs.file(install4jFileAssociationsFile)
1514 inputs.property("CHANNEL", { CHANNEL })
1515 outputs.file(install4jConfFile)
1518 def install4jConfigXml = new XmlParser().parse(install4jTemplateFile)
1520 // turn off code signing if no OSX_KEYPASS
1521 if (OSX_KEYPASS == "") {
1522 install4jConfigXml.'**'.codeSigning.each { codeSigning ->
1523 codeSigning.'@macEnabled' = "false"
1525 install4jConfigXml.'**'.windows.each { windows ->
1526 windows.'@runPostProcessor' = "false"
1530 // turn off checksum creation for LOCAL channel
1531 def e = install4jConfigXml.application[0]
1532 if (CHANNEL == "LOCAL") {
1533 e.'@createChecksums' = "false"
1535 e.'@createChecksums' = "true"
1538 // put file association actions where placeholder action is
1539 def install4jFileAssociationsText = install4jFileAssociationsFile.text
1540 def fileAssociationActions = new XmlParser().parseText("<actions>${install4jFileAssociationsText}</actions>")
1541 install4jConfigXml.'**'.action.any { a -> // .any{} stops after the first one that returns true
1542 if (a.'@name' == 'EXTENSIONS_REPLACED_BY_GRADLE') {
1543 def parent = a.parent()
1545 fileAssociationActions.each { faa ->
1548 // don't need to continue in .any loop once replacements have been made
1553 // use Windows Program Group with Examples folder for RELEASE, and Program Group without Examples for everything else
1554 // NB we're deleting the /other/ one!
1555 // Also remove the examples subdir from non-release versions
1556 def customizedIdToDelete = "PROGRAM_GROUP_RELEASE"
1557 // 2.11.1.0 NOT releasing with the Examples folder in the Program Group
1558 if (false && CHANNEL=="RELEASE") { // remove 'false && ' to include Examples folder in RELEASE channel
1559 customizedIdToDelete = "PROGRAM_GROUP_NON_RELEASE"
1561 // remove the examples subdir from Full File Set
1562 def files = install4jConfigXml.files[0]
1563 def fileset = files.filesets.fileset.find { fs -> fs.'@customizedId' == "FULL_FILE_SET" }
1564 def root = files.roots.root.find { r -> r.'@fileset' == fileset.'@id' }
1565 def mountPoint = files.mountPoints.mountPoint.find { mp -> mp.'@root' == root.'@id' }
1566 def dirEntry = files.entries.dirEntry.find { de -> de.'@mountPoint' == mountPoint.'@id' && de.'@subDirectory' == "examples" }
1567 dirEntry.parent().remove(dirEntry)
1569 install4jConfigXml.'**'.action.any { a ->
1570 if (a.'@customizedId' == customizedIdToDelete) {
1571 def parent = a.parent()
1577 // remove the "Uninstall Old Jalview (optional)" symlink from DMG for non-release DS_Stores
1578 if (! (CHANNEL == "RELEASE" || CHANNEL == "TEST-RELEASE" ) ) {
1579 def symlink = install4jConfigXml.'**'.topLevelFiles.symlink.find { sl -> sl.'@name' == "Uninstall Old Jalview (optional).app" }
1580 symlink.parent().remove(symlink)
1583 // write install4j file
1584 install4jConfFile.text = XmlUtil.serialize(install4jConfigXml)
1591 delete install4jConfFile
1596 task installers(type: com.install4j.gradle.Install4jTask) {
1597 group = "distribution"
1598 description = "Create the install4j installers"
1599 dependsOn setGitVals
1601 dependsOn copyInstall4jTemplate
1603 projectFile = install4jConfFile
1605 // create an md5 for the input files to use as version for install4j conf file
1606 def digest = MessageDigest.getInstance("MD5")
1608 (file("${install4jDir}/${install4j_template}").text +
1609 file("${install4jDir}/${install4j_info_plist_file_associations}").text +
1610 file("${install4jDir}/${install4j_installer_file_associations}").text).bytes)
1611 def filesMd5 = new BigInteger(1, digest.digest()).toString(16)
1612 if (filesMd5.length() >= 8) {
1613 filesMd5 = filesMd5.substring(0,8)
1615 def install4jTemplateVersion = "${JALVIEW_VERSION}_F${filesMd5}_C${gitHash}"
1616 // make install4jBuildDir relative to jalviewDir
1617 def install4jBuildDir = "${install4j_build_dir}/${JAVA_VERSION}"
1620 'JALVIEW_NAME': jalview_name,
1621 'JALVIEW_APPLICATION_NAME': install4jApplicationName,
1622 'JALVIEW_DIR': "../..",
1623 'OSX_KEYSTORE': OSX_KEYSTORE,
1624 'JSIGN_SH': JSIGN_SH,
1625 'JRE_DIR': getdown_app_dir_java,
1626 'INSTALLER_TEMPLATE_VERSION': install4jTemplateVersion,
1627 'JALVIEW_VERSION': JALVIEW_VERSION,
1628 'JAVA_MIN_VERSION': JAVA_MIN_VERSION,
1629 'JAVA_MAX_VERSION': JAVA_MAX_VERSION,
1630 'JAVA_VERSION': JAVA_VERSION,
1631 'JAVA_INTEGER_VERSION': JAVA_INTEGER_VERSION,
1632 'VERSION': JALVIEW_VERSION,
1633 'MACOS_JAVA_VM_DIR': macosJavaVMDir,
1634 'WINDOWS_JAVA_VM_DIR': windowsJavaVMDir,
1635 'LINUX_JAVA_VM_DIR': linuxJavaVMDir,
1636 'MACOS_JAVA_VM_TGZ': macosJavaVMTgz,
1637 'WINDOWS_JAVA_VM_TGZ': windowsJavaVMTgz,
1638 'LINUX_JAVA_VM_TGZ': linuxJavaVMTgz,
1639 'COPYRIGHT_MESSAGE': install4j_copyright_message,
1640 'BUNDLE_ID': install4jBundleId,
1641 'INTERNAL_ID': install4jInternalId,
1642 'WINDOWS_APPLICATION_ID': install4jWinApplicationId,
1643 'MACOS_DS_STORE': install4jDSStore,
1644 'MACOS_DMG_BG_IMAGE': install4jDMGBackgroundImage,
1645 'INSTALLER_NAME': install4jInstallerName,
1646 'INSTALL4J_UTILS_DIR': install4j_utils_dir,
1647 'GETDOWN_WEBSITE_DIR': getdown_website_dir,
1648 'GETDOWN_FILES_DIR': getdown_files_dir,
1649 'GETDOWN_RESOURCE_DIR': getdown_resource_dir,
1650 'GETDOWN_DIST_DIR': getdownAppDistDir,
1651 'GETDOWN_ALT_DIR': getdown_app_dir_alt,
1652 'GETDOWN_INSTALL_DIR': getdown_install_dir,
1653 'INFO_PLIST_FILE_ASSOCIATIONS_FILE': install4j_info_plist_file_associations,
1654 'BUILD_DIR': install4jBuildDir,
1655 'APPLICATION_CATEGORIES': install4j_application_categories,
1656 'APPLICATION_FOLDER': install4jApplicationFolder,
1657 'UNIX_APPLICATION_FOLDER': install4jUnixApplicationFolder,
1658 'EXECUTABLE_NAME': install4jExecutableName,
1659 'EXTRA_SCHEME': install4jExtraScheme,
1662 //println("INSTALL4J VARIABLES:")
1663 //variables.each{k,v->println("${k}=${v}")}
1665 destination = "${jalviewDir}/${install4jBuildDir}"
1666 buildSelected = true
1668 if (install4j_faster.equals("true") || CHANNEL.startsWith("LOCAL")) {
1670 disableSigning = true
1674 macKeystorePassword = OSX_KEYPASS
1678 println("Using projectFile "+projectFile)
1681 inputs.dir(getdownWebsiteDir)
1682 inputs.file(install4jConfFile)
1683 inputs.file("${install4jDir}/${install4j_info_plist_file_associations}")
1684 inputs.dir(macosJavaVMDir)
1685 inputs.dir(windowsJavaVMDir)
1686 outputs.dir("${jalviewDir}/${install4j_build_dir}/${JAVA_VERSION}")
1690 task sourceDist(type: Tar) {
1692 def VERSION_UNDERSCORES = JALVIEW_VERSION.replaceAll("\\.", "_")
1693 def outputFileName = "${project.name}_${VERSION_UNDERSCORES}.tar.gz"
1694 // cater for buildship < 3.1 [3.0.1 is max version in eclipse 2018-09]
1696 archiveFileName = outputFileName
1697 } catch (Exception e) {
1698 archiveName = outputFileName
1701 compression Compression.GZIP
1716 "**/*.class","$j11modDir/**/*.jar","appletlib","**/*locales",
1718 "utils/InstallAnywhere",
1733 "gradle.properties",
1744 ".settings/org.eclipse.jdt.core.jalview.prefs",
1748 exclude (EXCLUDE_FILES)
1749 include (PROCESS_FILES)
1750 filter(ReplaceTokens,
1754 'Version-Rel': JALVIEW_VERSION,
1755 'Year-Rel': getDate("yyyy")
1760 exclude (EXCLUDE_FILES)
1761 exclude (PROCESS_FILES)
1762 exclude ("appletlib")
1763 exclude ("**/*locales")
1764 exclude ("*locales/**")
1765 exclude ("utils/InstallAnywhere")
1767 exclude (getdown_files_dir)
1768 exclude (getdown_website_dir)
1770 // exluding these as not using jars as modules yet
1771 exclude ("$j11modDir/**/*.jar")
1774 include(INCLUDE_FILES)
1776 // from (jalviewDir) {
1777 // // explicit includes for stuff that seemed to not get included
1778 // include(fileTree("test/**/*."))
1779 // exclude(EXCLUDE_FILES)
1780 // exclude(PROCESS_FILES)
1787 dependsOn pubhtmlhelp
1789 inputs.dir("${classesDir}/${help_dir}")
1790 outputs.dir("${buildDir}/distributions/${help_dir}")
1793 // LARGE AMOUNT OF JALVIEWJS STUFF DELETED HERE
1794 task eclipseAutoBuildTask {}
1795 task eclipseSynchronizationTask {}