+ 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}")
+ cloverDb = string("${buildDir}/clover/clover.db")
+ 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}")
+ buildDist = true
+
+ // the following values might be overridden by the CHANNEL switch
+ getdownChannelName = CHANNEL.toLowerCase()
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}")
+ getdownAppDistDir = getdown_app_dir_alt
+ buildProperties = string("${classesDir}/${build_properties_file}")
+ reportRsyncCmd = false
+ jvlChannelName = CHANNEL.toLowerCase()
+ switch (CHANNEL) {
+
+ case "BUILD":
+ // TODO: get bamboo build artifact URL for getdown artifacts
+ getdown_channel_base = bamboo_channelbase
+ getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
+ getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
+ jvlChannelName += "_${getdownChannelName}"
+ break
+
+ case "RELEASE":
+ getdownAppDistDir = getdown_app_dir_release
+ reportRsyncCommand = true
+ break
+
+ case "ARCHIVE":
+ getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
+ if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
+ throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
+ } else {
+ packageDir = string("${ARCHIVEDIR}/${packageDir}")
+ buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}")
+ buildDist = false
+ }
+ reportRsyncCommand = true
+ break
+
+ case "ARCHIVELOCAL":
+ getdownChannelName = string("archive/${JALVIEW_VERSION}")
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = file(getdownWebsiteDir).toURI().toString()
+ if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
+ throw new GradleException("Must provide an ARCHIVEDIR value to produce an archive distribution")
+ } 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":
+ reportRsyncCommand = true
+ break
+
+ case "TEST-RELEASE":
+ reportRsyncCommand = true
+ break
+
+ case ~/^SCRATCH(|-[-\w]*)$/:
+ getdownChannelName = CHANNEL
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
+ reportRsyncCommand = true
+ break
+
+ case "TEST-LOCAL":
+ if (!file("${LOCALDIR}").exists()) {
+ throw new GradleException("Must provide a LOCALDIR value to produce a local distribution")
+ } else {
+ getdownAppBase = file(file("${LOCALDIR}").getAbsolutePath()).toURI().toString()
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+ }
+ break
+
+ case "LOCAL":
+ getdownAppBase = file(getdownWebsiteDir).toURI().toString()
+ getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}")
+ break
+
+ default: // something wrong specified
+ throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
+ break
+
+ }
+ // override getdownAppBase if requested
+ if (findProperty("getdown_appbase_override") != null) {
+ getdownAppBase = string(getProperty("getdown_appbase_override"))
+ println("Overriding getdown appbase with '${getdownAppBase}'")
+ }
+ // sanitise file name for jalview launcher file for this channel
+ jvlChannelName = jvlChannelName.replaceAll(/[^\w\-]/,"_")
+
+ getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
+ //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"])