X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=build.gradle;h=1f1bc2f6d9ba7c01880c10075b5f210955af0fad;hb=8e6e5eba1f8130dad6c2b697bf7671cb7036c1c0;hp=21a4c81056a60c515957e814586fac298713a1bf;hpb=e8a974af046e0ee231b09743c4299c89d3a95d87;p=jalview.git diff --git a/build.gradle b/build.gradle index 21a4c81..1f1bc2f 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ import org.apache.tools.ant.filters.ReplaceTokens import org.gradle.internal.os.OperatingSystem import org.gradle.plugins.ide.eclipse.model.Output import org.gradle.plugins.ide.eclipse.model.Library +import java.security.MessageDigest import groovy.transform.ExternalizeMethods @@ -82,10 +83,17 @@ 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}'") } + /-* *-/ if (false && IN_ECLIPSE) { jalviewDir = jalviewDirAbsolutePath } @@ -115,7 +123,7 @@ ext { getdownDir = string("") reportRsyncCmd = false buildDist = true - buildProperties = build_properties_file + buildProperties = string("${resourceDir}/${build_properties_file}") getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher}") switch (CHANNEL) { @@ -125,7 +133,7 @@ ext { 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}") + buildProperties = string("${resourceDir}/${build_properties_file}") break case "RELEASE": @@ -133,8 +141,13 @@ ext { 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}") + buildProperties = string("${resourceDir}/${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 "ARCHIVE": @@ -147,7 +160,7 @@ ext { exit } else { packageDir = string("${ARCHIVEDIR}/${packageDir}") - buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}") + buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}") buildDist = false } reportRsyncCommand = true @@ -163,7 +176,7 @@ ext { exit } else { packageDir = string("${ARCHIVEDIR}/${packageDir}") - buildProperties = string("${ARCHIVEDIR}/${classes_dir}/${build_properties_file}") + buildProperties = string("${ARCHIVEDIR}/${resource_dir}/${build_properties_file}") buildDist = false } reportRsyncCommand = true @@ -175,7 +188,7 @@ ext { 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}") + buildProperties = string("${resourceDir}/${build_properties_file}") reportRsyncCommand = true break @@ -184,8 +197,13 @@ ext { 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}") + buildProperties = string("${resourceDir}/${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]*)$/: @@ -193,14 +211,14 @@ ext { 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}") + buildProperties = string("${resourceDir}/${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}") + buildProperties = string("${resourceDir}/${build_properties_file}") getdownLauncher = string("${jalviewDir}/${getdown_lib_dir}/${getdown_launcher_local}") break @@ -314,10 +332,19 @@ ext { jalviewjsJ2sSettingsFileName = string("${jalviewDir}/${jalviewjs_j2s_settings}") jalviewjsJ2sProps = null + eclipseJavaVersion = "55" + jalviewjsJ2sPlugin = jalviewjs_j2s_plugin + if (IN_ECLIPSE) { + //def eclipseJavaVersion = System.property["java.class.version"] + if (Float.parseFloat(eclipseJavaVersion) >= 55 && file(jalviewjs_j2s_plugin_j11).exists()) { // 55 is Java 11 + jalviewjsJ2sPlugin = jalviewjs_j2s_plugin_j11 + } + } eclipseWorkspace = null eclipseBinary = string("") eclipseVersion = string("") eclipseDebug = false + eclipseJavaVersion = string("") // ENDEXT } @@ -429,6 +456,9 @@ eclipse { def removeTheseToo = [] HashMap alreadyAddedSrcPath = new HashMap<>(); cp.entries.each { entry -> + // This conditional removes all src classpathentries that a) have already been added or b) aren't "src" or "test". + // e.g. this removes the resources dir being copied into bin/main, bin/test AND bin/clover + // we add the resources and help/help dirs in as libs afterwards (see below) if (entry.kind == 'src') { if (alreadyAddedSrcPath.getAt(entry.path) || !(entry.path == bareSourceDir || entry.path == bareTestSourceDir)) { removeTheseToo += entry @@ -436,6 +466,7 @@ eclipse { alreadyAddedSrcPath.putAt(entry.path, true) } } + } cp.entries.removeAll(removeTheseToo) @@ -452,8 +483,8 @@ eclipse { sourceSets.main.compileClasspath.findAll { it.name.endsWith(".jar") }.each { //don't want to add outputDir as eclipse is using its own output dir in bin/main if (it.isDirectory() || ! it.exists()) { - // don't add dirs to classpath - return + // don't add dirs to classpath, especially if they don't exist + return false // groovy "continue" in .any closure } def itPath = it.toString() if (itPath.startsWith("${jalviewDirAbsolutePath}/")) { @@ -506,6 +537,7 @@ eclipse { javaRuntimeName = eclipse_java_runtime_name // 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() @@ -517,6 +549,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) + } + } + } + } } } @@ -525,7 +573,8 @@ eclipse { if (IN_ECLIPSE) { // Don't want these to be activated if in headless build synchronizationTasks "eclipseSynchronizationTask" - autoBuildTasks "eclipseAutoBuildTask" + //autoBuildTasks "eclipseAutoBuildTask" + } } @@ -657,6 +706,8 @@ task setGitVals { task createBuildProperties(type: WriteProperties) { + group = "build" + description = "Create the ${buildProperties} file" dependsOn setGitVals inputs.dir(sourceDir) inputs.dir(resourceDir) @@ -672,6 +723,13 @@ task createBuildProperties(type: WriteProperties) { } +clean { + doFirst { + delete buildProperties + } +} + + task cleanBuildingHTML(type: Delete) { doFirst { delete buildingHTML @@ -702,7 +760,7 @@ task convertBuildingMD(type: Exec) { commandLine pandoc, '-s', '-o', buildingHTML, '--metadata', 'pagetitle="Building Jalview from Source"', '--toc', '-H', css, buildingMD } else { println("Cannot find pandoc. Skipping convert building.md to HTML") - throw new StopExecutionException() + throw new StopExecutionException("Cannot find pandoc. Skipping convert building.md to HTML") } } @@ -767,6 +825,7 @@ task syncLib(type: Sync) { task syncResources(type: Sync) { + dependsOn createBuildProperties from resourceDir include "**/*.*" into "${classesDir}" @@ -878,6 +937,7 @@ task cleanPackageDir(type: Delete) { } } + jar { dependsOn linkCheck dependsOn buildIndices @@ -1524,6 +1584,15 @@ task jalviewjsEclipsePaths { } +task printProperties { + group "Debug" + description "Output to console all System.properties" + doFirst { + System.properties.each { key, val -> System.out.println("Property: ${key}=${val}") } + } +} + + task eclipseSetup { dependsOn eclipseProject dependsOn eclipseClasspath @@ -1536,7 +1605,7 @@ task jalviewjsEclipseCopyDropins(type: Copy) { dependsOn jalviewjsEclipsePaths def inputFiles = fileTree(dir: "${jalviewDir}/${jalviewjs_eclipse_dropins_dir}", include: "*.jar") - inputFiles += file("${jalviewDir}/${jalviewjs_j2s_plugin}") + inputFiles += file("${jalviewDir}/${jalviewjsJ2sPlugin}") def outputDir = "${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_eclipse_tmp_dropins_dir}" from inputFiles @@ -1827,7 +1896,12 @@ DEBUG: ${eclipseDebug} if (stdout.toString().contains("Error processing ")) { // j2s did not complete transpile //throw new TaskExecutionException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'") - throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'") + if (jalviewjs_ignore_transpile_errors.equals("true")) { + println("IGNORING TRANSPILE ERRORS") + println("See eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'") + } else { + throw new GradleException("Error during transpilation:\n${stderr}\nSee eclipse transpile log file '${jalviewDir}/${jalviewjsBuildDir}/${jalviewjs_j2s_transpile_stdout}'") + } } } @@ -1877,6 +1951,7 @@ def jalviewjsCallCore(String name, FileCollection list, String prefixFile, Strin javaexec { classpath = files(["${jalviewDir}/tools/closure_compiler.jar"]) args = [ "--js", jsfile, "--js_output_file", zjsfile ] + maxHeapSize = "2g" msg = "\nRunning '"+commandLine.join(' ')+"'\n" println(msg) @@ -1947,7 +2022,7 @@ task jalviewjsBuildAllCores { def file = hash['file'] if (! file.exists()) { - println("...classlist file '"+file.getPath()+"' does not exist, skipping") + //println("...classlist file '"+file.getPath()+"' does not exist, skipping") return false // this is a "continue" in groovy .each closure } def name = hash['name'] @@ -2020,7 +2095,8 @@ task jalviewjsBuildAllCores { 'list': allJsFiles, 'name': allClasslistName ] - jalviewjsCoreClasslists += allClasslist + // not including this version of "all" core at the moment + //jalviewjsCoreClasslists += allClasslist inputs.files(allClasslist['list']) outputs.file(allClasslist['jsfile']) outputs.file(allClasslist['zjsfile']) @@ -2157,12 +2233,19 @@ task jalviewjsBuildSite { } -task cleanJalviewjsSite { +task cleanJalviewjsTransferSite { doFirst { delete "${jalviewDir}/${jalviewjsTransferSiteJsDir}" delete "${jalviewDir}/${jalviewjsTransferSiteLibDir}" delete "${jalviewDir}/${jalviewjsTransferSiteSwingJsDir}" delete "${jalviewDir}/${jalviewjsTransferSiteCoreDir}" + } +} + + +task cleanJalviewjsSite { + dependsOn cleanJalviewjsTransferSite + doFirst { delete "${jalviewDir}/${jalviewjsSiteDir}" } } @@ -2255,6 +2338,67 @@ task cleanJalviewjsAll { } +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" @@ -2270,9 +2414,7 @@ task jalviewjsIDE_SyncCore { } -task jalviewjsIDE_PrepareSite { - group "00 JalviewJS in Eclipse" - description "Sync libs and resources to site dir, but not closure cores" +task jalviewjsIDE_SyncSiteAll { dependsOn jalviewjsSyncAllLibs dependsOn jalviewjsSyncResources dependsOn jalviewjsSyncSiteResources @@ -2280,6 +2422,18 @@ task jalviewjsIDE_PrepareSite { } +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" @@ -2301,16 +2455,22 @@ task jalviewjsIDE_Server { } -// buildship runs this at import +// buildship runs this at import or gradle refresh task eclipseSynchronizationTask { //dependsOn eclipseSetup - dependsOn jalviewjsIDE_j2sFile + dependsOn createBuildProperties + if (J2S_ENABLED) { + dependsOn jalviewjsIDE_j2sFile + dependsOn jalviewjsIDE_checkJ2sPlugin + dependsOn jalviewjsIDE_PrepareSite + } } -// buildship runs this at build time +// buildship runs this at build time or project refresh task eclipseAutoBuildTask { - dependsOn jalviewjsIDE_PrepareSite + //dependsOn jalviewjsIDE_checkJ2sPlugin + //dependsOn jalviewjsIDE_PrepareSite }