+dependencies {
+ compile 'org.apache.commons:commons-compress:1.18'
+}
+
+
+// in ext the values are cast to Object. Ensure string values are cast as String (and not GStringImpl) for later use
+def string(Object o) {
+ return o == null ? "" : o.toString()
+}
+
+
+ext {
+ jalviewDirAbsolutePath = file(jalviewDir).getAbsolutePath()
+ jalviewDirRelativePath = jalviewDir
+
+ // local build environment properties
+ def localProps = "${jalviewDirAbsolutePath}/local.properties"
+ if (file(localProps).exists()) {
+ try {
+ def p = new Properties()
+ def localPropsFIS = new FileInputStream(localProps)
+ p.load(localPropsFIS)
+ localPropsFIS.close()
+ p.each {
+ key, val ->
+ def oldval = findProperty(key)
+ setProperty(key, val)
+ if (oldval != null) {
+ println("Overriding property '${key}' ('${oldval}') with local.properties value '${val}'")
+ } else {
+ println("Setting unknown property '${key}' with local.properties value '${val}'")
+ }
+ }
+ } catch (Exception e) {
+ System.out.println("Exception reading local.properties")
+ }
+ }
+
+ // this property set when running Eclipse headlessly
+ j2sHeadlessBuildProperty = string("net.sf.j2s.core.headlessbuild")
+ // this property set by Eclipse
+ eclipseApplicationProperty = string("eclipse.application")
+ // CHECK IF RUNNING FROM WITHIN ECLIPSE
+ def eclipseApplicationPropertyVal = System.properties[eclipseApplicationProperty]
+ IN_ECLIPSE = eclipseApplicationPropertyVal != null && eclipseApplicationPropertyVal.startsWith("org.eclipse.ui.")
+ // BUT WITHOUT THE HEADLESS BUILD PROPERTY SET
+ if (System.properties[j2sHeadlessBuildProperty].equals("true")) {
+ println("Setting IN_ECLIPSE to ${IN_ECLIPSE} as System.properties['${j2sHeadlessBuildProperty}'] == '${System.properties[j2sHeadlessBuildProperty]}'")
+ IN_ECLIPSE = false
+ }
+ if (IN_ECLIPSE) {
+ println("WITHIN ECLIPSE IDE")
+ } else {
+ println("HEADLESS BUILD")
+ }
+ /* *-/
+ System.properties.sort { it.key }.each {
+ key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
+ }
+ /-* *-/
+ if (false && IN_ECLIPSE) {
+ jalviewDir = jalviewDirAbsolutePath
+ }
+ */
+
+ // essentials
+ bareSourceDir = string(source_dir)
+ sourceDir = string("${jalviewDir}/${bareSourceDir}")
+ resourceDir = string("${jalviewDir}/${resource_dir}")
+ bareTestSourceDir = string(test_source_dir)
+ testSourceDir = string("${jalviewDir}/${bareTestSourceDir}")
+
+ // clover
+ cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
+ classesDir = string("${jalviewDir}/${classes_dir}")
+ if (clover.equals("true")) {
+ use_clover = true
+ classesDir = string("${buildDir}/${cloverClassesDir}")
+ } else {
+ use_clover = false
+ classesDir = string("${jalviewDir}/${classes_dir}")
+ }
+
+ classes = classesDir
+
+ getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
+ getdownDir = string("")
+ reportRsyncCmd = false
+ buildDist = true
+ buildProperties = build_properties_file
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
+ switch (CHANNEL) {
+
+ case "BUILD":
+ // TODO: get bamboo build artifact URL for getdown artifacts
+ getdown_channel_base = bamboo_channelbase
+ getdown_channel_name = string("${bamboo_planKey}/${JAVA_VERSION}")
+ getdown_app_base = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
+ getdown_app_dir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ break
+
+ case "RELEASE":
+ getdown_channel_name = CHANNEL.toLowerCase()
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
+ getdown_app_dir = getdown_app_dir_release
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ reportRsyncCommand = true
+ break
+
+ case "ARCHIVE":
+ getdown_channel_name = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
+ getdown_app_dir = getdown_app_dir_alt
+ if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
+ print "Must provide an ARCHIVEDIR value to produce an archive distribution"
+ exit
+ } else {
+ packageDir = string("${ARCHIVEDIR}/${packageDir}")
+ buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
+ buildDist = false
+ }
+ reportRsyncCommand = true
+ break
+
+ case "ARCHIVELOCAL":
+ getdown_channel_name = string("archive/${JALVIEW_VERSION}")
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = file(getdownWebsiteDir).toURI().toString()
+ getdown_app_dir = getdown_app_dir_alt
+ if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
+ print "Must provide an ARCHIVEDIR value to produce an archive distribution"
+ exit
+ } else {
+ packageDir = string("${ARCHIVEDIR}/${packageDir}")
+ buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
+ buildDist = false
+ }
+ reportRsyncCommand = true
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+ break
+
+ case "DEVELOP":
+ getdown_channel_name = CHANNEL.toLowerCase()
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
+ getdown_app_dir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ reportRsyncCommand = true
+ break
+
+ case "TEST-RELEASE":
+ getdown_channel_name = CHANNEL.toLowerCase()
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
+ getdown_app_dir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ reportRsyncCommand = true
+ break
+
+ case ~/^SCRATCH(|-[-\w]*)$/:
+ getdown_channel_name = CHANNEL
+ getdownDir = string("${getdown_channel_name}/${JAVA_VERSION}")
+ getdown_app_base = string("${getdown_channel_base}/${getdownDir}")
+ getdown_app_dir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ reportRsyncCommand = true
+ break
+
+ case "LOCAL":
+ getdown_app_base = file(getdownWebsiteDir).toURI().toString()
+ getdown_app_dir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+ break
+
+ default: // something wrong specified
+ println("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
+ exit
+ break
+
+ }
+ // override getdown_app_base if requested
+ if (findProperty("getdown_appbase_override") != null) {
+ getdown_app_base = string(getProperty("getdown_appbase_override"))
+ println("Overriding getdown appbase with '${getdown_app_base}'")
+ }
+
+ getdownAppDir = string("${getdownWebsiteDir}/${getdown_app_dir}")
+ //getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
+ getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
+ getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
+ getdownFilesDir = string("${jalviewDir}/${getdown_files_dir}/${JAVA_VERSION}/")
+ getdownFilesInstallDir = string("${getdownFilesDir}/${getdown_install_dir}")
+ /* compile without modules -- using classpath libraries
+ modules_compileClasspath = fileTree(dir: "${jalviewDir}/${j11modDir}", include: ["*.jar"])
+ modules_runtimeClasspath = modules_compileClasspath
+ */
+ gitHash = string("")
+ gitBranch = string("")
+
+ println("Using a ${CHANNEL} profile.")
+
+ additional_compiler_args = []
+ // configure classpath/args for j8/j11 compilation
+ if (JAVA_VERSION.equals("1.8")) {
+ JAVA_INTEGER_VERSION = string("8")
+ //libDir = j8libDir
+ libDir = j11libDir
+ libDistDir = j8libDir
+ compile_source_compatibility = 1.8
+ compile_target_compatibility = 1.8
+ // these are getdown.txt properties defined dependent on the JAVA_VERSION
+ getdownAltJavaMinVersion = string(findProperty("getdown_alt_java8_min_version"))
+ getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java8_max_version"))
+ // this property is assigned below and expanded to multiple lines in the getdown task
+ getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java8_txt_multi_java_location"))
+ // this property is for the Java library used in eclipse
+ eclipseJavaRuntimeName = string("JavaSE-1.8")
+ } else if (JAVA_VERSION.equals("11")) {
+ JAVA_INTEGER_VERSION = string("11")
+ libDir = j11libDir
+ libDistDir = j11libDir
+ compile_source_compatibility = 11
+ compile_target_compatibility = 11
+ getdownAltJavaMinVersion = string(findProperty("getdown_alt_java11_min_version"))
+ getdownAltJavaMaxVersion = string(findProperty("getdown_alt_java11_max_version"))
+ getdownAltMultiJavaLocation = string(findProperty("getdown_alt_java11_txt_multi_java_location"))
+ eclipseJavaRuntimeName = string("JavaSE-11")
+ /* compile without modules -- using classpath libraries
+ additional_compiler_args += [
+ '--module-path', modules_compileClasspath.asPath,