X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=dde96ea8be094e277acdbd758217f72bd0f5fe9a;hb=290d1c0638e869b08d5f2729472197873fa06af0;hp=efa2e6e918693f9fc12b34794060a903f67442c0;hpb=6bd49578cee98d3dfaa7feae59a4cad830d507cc;p=jalview.git
diff --git a/build.gradle b/build.gradle
index efa2e6e..dde96ea 100644
--- a/build.gradle
+++ b/build.gradle
@@ -7,32 +7,31 @@ import groovy.transform.ExternalizeMethods
import groovy.util.XmlParser
import groovy.xml.XmlUtil
+
buildscript {
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ }
dependencies {
- classpath 'org.openclover:clover:4.3.1'
+ classpath 'org.openclover:clover:4.4.1'
}
}
+
plugins {
id 'java'
id 'application'
id 'eclipse'
id 'com.github.johnrengelman.shadow' version '4.0.3'
- id 'com.install4j.gradle' version '8.0.2'
- id 'com.dorongold.task-tree' version '1.4' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
+ id 'com.install4j.gradle' version '8.0.4'
+ id 'com.dorongold.task-tree' version '1.5' // only needed to display task dependency tree with gradle task1 [task2 ...] taskTree
}
repositories {
jcenter()
mavenCentral()
mavenLocal()
- flatDir {
- dirs gradlePluginsDir
- }
-}
-
-dependencies {
- compile 'org.apache.commons:commons-compress:1.18'
}
@@ -47,11 +46,21 @@ ext {
jalviewDirRelativePath = jalviewDir
// local build environment properties
- def localProps = "${jalviewDirAbsolutePath}/local.properties"
+ // can be "projectDir/local.properties"
+ def localProps = "${projectDir}/local.properties"
+ def propsFile = null;
if (file(localProps).exists()) {
+ propsFile = localProps
+ }
+ // or "../projectDir_local.properties"
+ def dirLocalProps = projectDir.getParent() + "/" + projectDir.getName() + "_local.properties"
+ if (file(dirLocalProps).exists()) {
+ propsFile = dirLocalProps
+ }
+ if (propsFile != null) {
try {
def p = new Properties()
- def localPropsFIS = new FileInputStream(localProps)
+ def localPropsFIS = new FileInputStream(propsFile)
p.load(localPropsFIS)
localPropsFIS.close()
p.each {
@@ -59,9 +68,9 @@ ext {
def oldval = findProperty(key)
setProperty(key, val)
if (oldval != null) {
- println("Overriding property '${key}' ('${oldval}') with local.properties value '${val}'")
+ println("Overriding property '${key}' ('${oldval}') with ${file(propsFile).getName()} value '${val}'")
} else {
- println("Setting unknown property '${key}' with local.properties value '${val}'")
+ println("Setting unknown property '${key}' with ${file(propsFile).getName()}s value '${val}'")
}
}
} catch (Exception e) {
@@ -86,6 +95,12 @@ ext {
} else {
println("HEADLESS BUILD")
}
+
+ J2S_ENABLED = (project.hasProperty('j2s.compiler.status') && project['j2s.compiler.status'] != null && project['j2s.compiler.status'] == "enable")
+ if (J2S_ENABLED) {
+ println("J2S ENABLED")
+ }
+
/* *-/
System.properties.sort { it.key }.each {
key, val -> println("SYSTEM PROPERTY ${key}='${val}'")
@@ -105,6 +120,7 @@ ext {
// clover
cloverInstrDir = file("${buildDir}/${cloverSourcesInstrDir}")
+ cloverDb = string("${buildDir}/clover/clover.db")
classesDir = string("${jalviewDir}/${classes_dir}")
if (clover.equals("true")) {
use_clover = true
@@ -117,58 +133,64 @@ ext {
classes = classesDir
getdownWebsiteDir = string("${jalviewDir}/${getdown_website_dir}/${JAVA_VERSION}")
- getdownDir = string("")
- reportRsyncCmd = false
buildDist = true
- buildProperties = build_properties_file
+
+ // 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("${resourceDir}/${build_properties_file}")
+ reportRsyncCommand = false
+ jvlChannelName = CHANNEL.toLowerCase()
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}")
+ getdownChannelName = string("${bamboo_planKey}/${JAVA_VERSION}")
+ getdownAppBase = string("${bamboo_channelbase}/${bamboo_planKey}${bamboo_getdown_channel_suffix}/${JAVA_VERSION}")
+ jvlChannelName += "_${getdownChannelName}"
+ // automatically add the test group Not-bamboo for exclusion
+ if ("".equals(testngExcludedGroups)) {
+ testngExcludedGroups = "Not-bamboo"
+ }
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}")
+ getdownAppDistDir = getdown_app_dir_release
reportRsyncCommand = true
+ // Don't ignore transpile errors for release build
+ if (jalviewjs_ignore_transpile_errors.equals("true")) {
+ jalviewjs_ignore_transpile_errors = "false"
+ println("Setting jalviewjs_ignore_transpile_errors to 'false'")
+ }
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
+ getdownChannelName = CHANNEL.toLowerCase()+"/${JALVIEW_VERSION}"
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = string("${getdown_channel_base}/${getdownDir}")
if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
- print "Must provide an ARCHIVEDIR value to produce an archive distribution"
- exit
+ 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}")
+ buildProperties = string("${buildDir}/archive/${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
+ getdownChannelName = string("archive/${JALVIEW_VERSION}")
+ getdownDir = string("${getdownChannelName}/${JAVA_VERSION}")
+ getdownAppBase = file(getdownWebsiteDir).toURI().toString()
if (!file("${ARCHIVEDIR}/${packageDir}").exists()) {
- print "Must provide an ARCHIVEDIR value to produce an archive distribution"
- exit
+ 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}")
+ buildProperties = string("${buildDir}/archive/${build_properties_file}")
buildDist = false
}
reportRsyncCommand = true
@@ -176,52 +198,53 @@ ext {
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
+ // Don't ignore transpile errors for release build
+ if (jalviewjs_ignore_transpile_errors.equals("true")) {
+ jalviewjs_ignore_transpile_errors = "false"
+ println("Setting jalviewjs_ignore_transpile_errors to 'false'")
+ }
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}")
+ 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":
- getdown_app_base = file(getdownWebsiteDir).toURI().toString()
- getdown_app_dir = getdown_app_dir_alt
- buildProperties = string("${classesDir}/${build_properties_file}")
+ getdownAppBase = file(getdownWebsiteDir).toURI().toString()
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
+ throw new GradleException("CHANNEL must be one of BUILD, RELEASE, ARCHIVE, DEVELOP, TEST-RELEASE, SCRATCH-..., LOCAL [default]")
break
}
- // override getdown_app_base if requested
+ // override getdownAppBase if requested
if (findProperty("getdown_appbase_override") != null) {
- getdown_app_base = string(getProperty("getdown_appbase_override"))
- println("Overriding getdown appbase with '${getdown_app_base}'")
+ 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}/${getdown_app_dir}")
+ getdownAppDir = string("${getdownWebsiteDir}/${getdownAppDistDir}")
//getdownJ11libDir = "${getdownWebsiteDir}/${getdown_j11lib_dir}"
getdownResourceDir = string("${getdownWebsiteDir}/${getdown_resource_dir}")
getdownInstallDir = string("${getdownWebsiteDir}/${getdown_install_dir}")
@@ -335,6 +358,7 @@ ext {
jalviewjsJalviewTemplateName = string(jalviewjs_name)
jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}")
jalviewjsJ2sProps = null
+ jalviewjsJ2sPlugin = jalviewjs_j2s_plugin
eclipseWorkspace = null
eclipseBinary = string("")
@@ -396,7 +420,7 @@ sourceSets {
compileClasspath = files( sourceSets.test.java.outputDir )
if (use_clover) {
- compileClasspath += sourceSets.clover.compileClasspath
+ compileClasspath = sourceSets.clover.compileClasspath
} else {
compileClasspath += files(sourceSets.main.java.outputDir)
}
@@ -413,8 +437,8 @@ sourceSets {
// clover bits
dependencies {
if (use_clover) {
- cloverCompile 'org.openclover:clover:4.3.1'
- testCompile 'org.openclover:clover:4.3.1'
+ cloverCompile 'org.openclover:clover:4.4.1'
+ testCompile 'org.openclover:clover:4.4.1'
}
}
@@ -424,6 +448,8 @@ configurations {
cloverRuntime.extendsFrom cloverCompile
}
+
+// eclipse project and settings files creation, also used by buildship
eclipse {
project {
name = eclipse_project_name
@@ -533,6 +559,7 @@ eclipse {
javaRuntimeName = eclipseJavaRuntimeName
// add in jalview project specific properties/preferences into eclipse core preferences
+ // and also the codestyle XML file
file {
withProperties { props ->
def jalview_prefs = new Properties()
@@ -544,6 +571,22 @@ eclipse {
props.putAt(t, v)
}
}
+ // codestyle file -- overrides previous formatter prefs
+ def csFile = file("${jalviewDirAbsolutePath}/${eclipse_codestyle_file}")
+ if (csFile.exists()) {
+ XmlParser parser = new XmlParser()
+ def profiles = parser.parse(csFile)
+ def profile = profiles.'profile'.find { p -> (p.'@kind' == "CodeFormatterProfile" && p.'@name' == "Jalview") }
+ if (profile != null) {
+ profile.'setting'.each { s ->
+ def id = s.'@id'
+ def value = s.'@value'
+ if (id != null && value != null) {
+ props.putAt(id, value)
+ }
+ }
+ }
+ }
}
}
@@ -552,24 +595,30 @@ eclipse {
if (IN_ECLIPSE) {
// Don't want these to be activated if in headless build
synchronizationTasks "eclipseSynchronizationTask"
- autoBuildTasks "eclipseAutoBuildTask"
+ //autoBuildTasks "eclipseAutoBuildTask"
}
}
-task cloverInstr() {
+task cloverInstr {
// only instrument source, we build test classes as normal
- inputs.files files (sourceSets.main.allJava) // , fileTree(dir: testSourceDir, include: ["**/*.java"]))
+ inputs.files files (sourceSets.main.allJava,sourceSets.test.allJava) // , fileTree(dir:"$jalviewDir/$testSourceDir", include: ["**/*.java"]))
outputs.dir cloverInstrDir
doFirst {
delete cloverInstrDir
- def argsList = ["--initstring", "${buildDir}/clover/clover.db",
- "-d", "${buildDir}/${cloverSourcesInstrDir}"]
- argsList.addAll(inputs.files.files.collect({ file ->
- file.absolutePath
- }))
+ def argsList = [
+ "--initstring",
+ cloverDb,
+ "-d",
+ cloverInstrDir.getPath(),
+ ]
+ argsList.addAll(
+ inputs.files.files.collect(
+ { file -> file.absolutePath }
+ )
+ )
String[] args = argsList.toArray()
println("About to instrument "+args.length +" files")
com.atlassian.clover.CloverInstr.mainImpl(args)
@@ -577,26 +626,57 @@ task cloverInstr() {
}
+cloverClasses.dependsOn cloverInstr
+
+
task cloverReport {
group = "Verification"
- description = "Createst the Clover report"
- inputs.dir "${buildDir}/clover"
- outputs.dir "${reportsDir}/clover"
- onlyIf {
- file("${buildDir}/clover/clover.db").exists()
- }
+ description = "Creates the Clover report"
+ inputs.dir "${buildDir}/clover"
+ outputs.dir "${reportsDir}/clover"
+ onlyIf {
+ file(cloverDb).exists()
+ }
doFirst {
- def argsList = ["--initstring", "${buildDir}/clover/clover.db",
- "-o", "${reportsDir}/clover"]
+ def argsList = [
+ "--initstring",
+ cloverDb,
+ "-o",
+ "${reportsDir}/clover"
+ ]
String[] args = argsList.toArray()
com.atlassian.clover.reporters.html.HtmlReporter.runReport(args)
// and generate ${reportsDir}/clover/clover.xml
- args = ["--initstring", "${buildDir}/clover/clover.db",
- "-o", "${reportsDir}/clover/clover.xml"].toArray()
+ args = [
+ "--initstring",
+ cloverDb,
+ "-o",
+ "${reportsDir}/clover/clover.xml"
+ ].toArray()
com.atlassian.clover.reporters.xml.XMLReporter.runReport(args)
}
}
+
+
+compileCloverJava {
+
+ doFirst {
+ sourceCompatibility = compile_source_compatibility
+ targetCompatibility = compile_target_compatibility
+ options.compilerArgs += additional_compiler_args
+ print ("Setting target compatibility to "+targetCompatibility+"\n")
+ }
+ classpath += configurations.cloverRuntime
+}
+
+
+task cleanClover {
+ doFirst {
+ delete cloverInstrDir
+ delete cloverDb
+ }
+}
// end clover bits
@@ -628,18 +708,6 @@ compileTestJava {
}
-compileCloverJava {
-
- doFirst {
- sourceCompatibility = compile_source_compatibility
- targetCompatibility = compile_target_compatibility
- options.compilerArgs += additional_compiler_args
- print ("Setting target compatibility to "+targetCompatibility+"\n")
- }
- classpath += configurations.cloverRuntime
-}
-
-
clean {
doFirst {
delete sourceSets.main.java.outputDir
@@ -648,9 +716,9 @@ clean {
cleanTest {
+ dependsOn cleanClover
doFirst {
delete sourceSets.test.java.outputDir
- delete cloverInstrDir
}
}
@@ -685,6 +753,8 @@ task setGitVals {
task createBuildProperties(type: WriteProperties) {
+ group = "build"
+ description = "Create the ${buildProperties} file"
dependsOn setGitVals
inputs.dir(sourceDir)
inputs.dir(resourceDir)
@@ -700,6 +770,13 @@ task createBuildProperties(type: WriteProperties) {
}
+clean {
+ doFirst {
+ delete buildProperties
+ }
+}
+
+
task cleanBuildingHTML(type: Delete) {
doFirst {
delete buildingHTML
@@ -720,7 +797,6 @@ task convertBuildingMD(type: Exec) {
}
}
- def hostname = "hostname".execute().text.trim()
def buildtoolsPandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
if ((pandoc == null || ! file(pandoc).exists()) && file(buildtoolsPandoc).exists()) {
pandoc = System.getProperty("user.home")+"/buildtools/pandoc/bin/pandoc"
@@ -796,6 +872,7 @@ task syncLib(type: Sync) {
task syncResources(type: Sync) {
+ dependsOn createBuildProperties
from resourceDir
include "**/*.*"
into "${classesDir}"
@@ -826,10 +903,13 @@ test {
useTestNG() {
includeGroups testngGroups
+ excludeGroups testngExcludedGroups
preserveOrder true
useDefaultListeners=true
}
+ maxHeapSize = "1024m"
+
workingDir = jalviewDir
//systemProperties 'clover.jar' System.properties.clover.jar
sourceCompatibility = compile_source_compatibility
@@ -906,6 +986,7 @@ task cleanPackageDir(type: Delete) {
}
}
+
jar {
dependsOn linkCheck
dependsOn buildIndices
@@ -995,7 +1076,6 @@ task getdownWebsite() {
def getdownWebsiteResourceFilenames = []
def getdownTextString = ""
def getdownResourceDir = getdownResourceDir
- def getdownAppDir = getdownAppDir
def getdownResourceFilenames = []
doFirst {
@@ -1008,7 +1088,7 @@ task getdownWebsite() {
rename(build_properties_file, getdown_build_properties)
into getdownAppDir
}
- getdownWebsiteResourceFilenames += "${getdown_app_dir}/${getdown_build_properties}"
+ getdownWebsiteResourceFilenames += "${getdownAppDistDir}/${getdown_build_properties}"
// go through properties looking for getdown_txt_...
def props = project.properties.sort { it.key }
@@ -1022,7 +1102,7 @@ task getdownWebsite() {
props.put("getdown_txt_multi_java_location", getdownAltMultiJavaLocation)
}
- props.put("getdown_txt_appbase", getdown_app_base)
+ props.put("getdown_txt_appbase", getdownAppBase)
props.each{ prop, val ->
if (prop.startsWith("getdown_txt_") && val != null) {
if (prop.startsWith("getdown_txt_multi_")) {
@@ -1077,7 +1157,7 @@ task getdownWebsite() {
}
codeFiles.sort().each{f ->
def name = f.getName()
- def line = "code = ${getdown_app_dir}/${name}\n"
+ def line = "code = ${getdownAppDistDir}/${name}\n"
getdownTextString += line
copy {
from f.getPath()
@@ -1109,8 +1189,9 @@ task getdownWebsite() {
def getdown_txt = file("${getdownWebsiteDir}/getdown.txt")
getdown_txt.write(getdownTextString)
- def launch_jvl = file("${getdownWebsiteDir}/${getdown_launch_jvl}")
- launch_jvl.write("appbase="+props.get("getdown_txt_appbase"))
+ def getdownLaunchJvl = getdown_launch_jvl_name + ( (jvlChannelName != null && jvlChannelName.length() > 0)?"-${jvlChannelName}":"" ) + ".jvl"
+ def launchJvl = file("${getdownWebsiteDir}/${getdownLaunchJvl}")
+ launchJvl.write("appbase="+props.get("getdown_txt_appbase"))
copy {
from getdownLauncher
@@ -1145,7 +1226,7 @@ task getdownWebsite() {
copy {
from getdown_txt
- from launch_jvl
+ from launchJvl
from getdownLauncher
from "${getdownWebsiteDir}/${getdown_build_properties}"
if (file(getdownLauncher).getName() != getdown_launcher) {
@@ -1168,12 +1249,28 @@ task getdownWebsite() {
}
+// a helper task to allow getdown digest of any dir: `gradle getdownDigestDir -PDIGESTDIR=/path/to/my/random/getdown/dir
+task getdownDigestDir(type: JavaExec) {
+ def digestDirPropertyName = "DIGESTDIR"
+ description = "Digest a local dir (-P${digestDirPropertyName}=...) for getdown"
+ doFirst {
+ classpath = files(getdownLauncher)
+ def digestDir = findProperty(digestDirPropertyName)
+ if (digestDir == null) {
+ throw new GradleException("Must provide a DIGESTDIR value to produce an alternative getdown digest")
+ }
+ args digestDir
+ }
+ main = "com.threerings.getdown.tools.Digester"
+}
+
+
task getdownDigest(type: JavaExec) {
group = "distribution"
description = "Digest the getdown website folder"
dependsOn getdownWebsite
doFirst {
- classpath = files("${getdownWebsiteDir}/${getdown_launcher}")
+ classpath = files(getdownLauncher)
}
main = "com.threerings.getdown.tools.Digester"
args getdownWebsiteDir
@@ -1247,6 +1344,14 @@ task copyInstall4jTemplate {
}
}
+ // turn off checksum creation for LOCAL channel
+ def e = install4jConfigXml.application[0]
+ if (CHANNEL == "LOCAL") {
+ e.'@createChecksums' = "false"
+ } else {
+ e.'@createChecksums' = "true"
+ }
+
// put file association actions where placeholder action is
def install4jFileAssociationsText = install4jFileAssociationsFile.text
def fileAssociationActions = new XmlParser().parseText("
JalviewJS Test with debug. <${url}?j2sdebug>
+JalviewJS Test with verbose. <${url}?j2sdebug>
+ """ + jalviewjsCoreClasslists.each { cl -> + def urlcore = jalviewjsServer.getResourceUrl(file(cl.outputfile).getName()) + htmlText += """ +${jalviewjsJalviewTemplateName} [core ${cl.name}]. <${urlcore}>
+ """ + println("For core ${cl.name}: "+urlcore) + } + + file(htmlFile).text = htmlText + } + + outputs.file(htmlFile) + outputs.upToDateWhen({false}) +} + + +task cleanJalviewjsAll { + group "JalviewJS" + description "Delete all configuration and build artifacts to do with JalviewJS build" + dependsOn cleanJalviewjsSite + dependsOn jalviewjsEclipsePaths + + doFirst { + delete "${jalviewDir}/${jalviewjsBuildDir}" + delete "${jalviewDir}/${eclipse_bin_dir}" + if (eclipseWorkspace != null && file(eclipseWorkspace.getAbsolutePath()+"/.metadata").exists()) { + delete file(eclipseWorkspace.getAbsolutePath()+"/.metadata") + } + delete "${jalviewDir}/${jalviewjs_j2s_settings}" + } + + outputs.upToDateWhen( { false } ) +} + + +task jalviewjsIDE_checkJ2sPlugin { + group "00 JalviewJS in Eclipse" + description "Compare the swingjs/net.sf.j2s.core(-j11)?.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)" + + doFirst { + def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}") + def j2sPluginFile = file(j2sPlugin) + def eclipseHome = System.properties["eclipse.home.location"] + if (eclipseHome == null || ! IN_ECLIPSE) { + throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.") + } + def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}" + def eclipseJ2sPluginFile = file(eclipseJ2sPlugin) + if (!eclipseJ2sPluginFile.exists()) { + def msg = "Eclipse J2S Plugin is not installed (could not find '${eclipseJ2sPlugin}')\nTry running task jalviewjsIDE_copyJ2sPlugin" + System.err.println(msg) + throw new StopExecutionException(msg) + } + + def digest = MessageDigest.getInstance("MD5") + + digest.update(j2sPluginFile.text.bytes) + def j2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') + + digest.update(eclipseJ2sPluginFile.text.bytes) + def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') + + if (j2sPluginMd5 != eclipseJ2sPluginMd5) { + def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'" + System.err.println(msg) + throw new StopExecutionException(msg) + } else { + def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}' (this is good)" + println(msg) + } + } +} + +task jalviewjsIDE_copyJ2sPlugin { + group "00 JalviewJS in Eclipse" + description "Copy the swingjs/net.sf.j2s.core(-j11)?.jar file into the Eclipse IDE's 'dropins' dir" + + doFirst { + def j2sPlugin = string("${jalviewDir}/${jalviewjsJ2sPlugin}") + def j2sPluginFile = file(j2sPlugin) + def eclipseHome = System.properties["eclipse.home.location"] + if (eclipseHome == null || ! IN_ECLIPSE) { + throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. NOT copying J2S Plugin.") + } + def eclipseJ2sPlugin = "${eclipseHome}/dropins/${j2sPluginFile.getName()}" + def eclipseJ2sPluginFile = file(eclipseJ2sPlugin) + def msg = "WARNING! Copying this commit's j2s plugin '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n* May require an Eclipse restart" + System.err.println(msg) + copy { + from j2sPlugin + eclipseJ2sPluginFile.getParentFile().mkdirs() + into eclipseJ2sPluginFile.getParent() + } + } +} + + +task jalviewjsIDE_j2sFile { + group "00 JalviewJS in Eclipse" + description "Creates the .j2s file" + dependsOn jalviewjsCreateJ2sSettings +} + + +task jalviewjsIDE_SyncCore { + group "00 JalviewJS in Eclipse" + description "Build the core js lib closures listed in the classlists dir and publish core html from template" + dependsOn jalviewjsSyncCore +} + + +task jalviewjsIDE_SyncSiteAll { + dependsOn jalviewjsSyncAllLibs + dependsOn jalviewjsSyncResources + dependsOn jalviewjsSyncSiteResources + dependsOn jalviewjsSyncBuildProperties +} + + +cleanJalviewjsTransferSite.mustRunAfter jalviewjsIDE_SyncSiteAll + + +task jalviewjsIDE_PrepareSite { + group "00 JalviewJS in Eclipse" + description "Sync libs and resources to site dir, but not closure cores" + + dependsOn jalviewjsIDE_SyncSiteAll + dependsOn cleanJalviewjsTransferSite +} + + +task jalviewjsIDE_AssembleSite { + group "00 JalviewJS in Eclipse" + description "Assembles unzipped supporting zipfiles, resources, site resources and closure cores into the Eclipse transpiled site" + dependsOn jalviewjsPrepareSite +} + + +task jalviewjsIDE_SiteClean { + group "00 JalviewJS in Eclipse" + description "Deletes the Eclipse transpiled site" + dependsOn cleanJalviewjsSite +} + + +task jalviewjsIDE_Server { + group "00 JalviewJS in Eclipse" + description "Starts a webserver on localhost to test the website" + dependsOn jalviewjsServer +} + + +// buildship runs this at import or gradle refresh +task eclipseSynchronizationTask { + //dependsOn eclipseSetup + dependsOn createBuildProperties + if (J2S_ENABLED) { + dependsOn jalviewjsIDE_j2sFile + dependsOn jalviewjsIDE_checkJ2sPlugin + dependsOn jalviewjsIDE_PrepareSite + } +} + + +// buildship runs this at build time or project refresh +task eclipseAutoBuildTask { + //dependsOn jalviewjsIDE_checkJ2sPlugin + //dependsOn jalviewjsIDE_PrepareSite +} + + +task jalviewjs { + group "JalviewJS" + description "Build the site" + dependsOn jalviewjsBuildSite +}