From: Ben Soares Date: Thu, 14 Nov 2019 10:35:11 +0000 (+0000) Subject: JAL-3210 Auto copy j2s plugin to Eclipse IDE dropins dir. Off by default X-Git-Tag: Release_2_11_4_0~45^2~18^2~52 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7b4179c8760e3c7e797ad2cecc3150cbd7608259;p=jalview.git JAL-3210 Auto copy j2s plugin to Eclipse IDE dropins dir. Off by default --- diff --git a/build.gradle b/build.gradle index 7cdadc1..0117ffc 100644 --- a/build.gradle +++ b/build.gradle @@ -431,6 +431,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 @@ -438,10 +441,11 @@ eclipse { alreadyAddedSrcPath.putAt(entry.path, true) } } + } cp.entries.removeAll(removeTheseToo) - cp.entries += new Output("${eclipse_bin_dir}/main") + //cp.entries += new Output("${eclipse_bin_dir}/main") if (file(helpSourceDir).isDirectory()) { cp.entries += new Library(fileReference(helpSourceDir)) } @@ -454,8 +458,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}/")) { @@ -528,6 +532,7 @@ eclipse { // Don't want these to be activated if in headless build synchronizationTasks "eclipseSynchronizationTask" autoBuildTasks "eclipseAutoBuildTask" + } } @@ -2260,12 +2265,14 @@ task cleanJalviewjsAll { task jalviewjsIDE_checkJ2sPlugin { group "00 JalviewJS in Eclipse" - description "Compare the swingjs/net.sf.j2s.core.jar file with the Eclipse pluing version" + description "Compare the swingjs/net.sf.j2s.core.jar file with the Eclipse IDE's plugin version (found in the 'dropins' dir)" doFirst { def j2sPlugin = string("${jalviewDir}/${jalviewjs_j2s_plugin}") def j2sPluginFile = file(j2sPlugin) def eclipseHome = System.properties["eclipse.home.location"] + def copyPlugin = jalviewjs_eclipseIDE_auto_copy_j2s_plugin == "true" + def doCopy = false if (eclipseHome == null || ! IN_ECLIPSE) { throw new StopExecutionException("Cannot find running Eclipse home from System.properties['eclipse.home.location']. Skipping J2S Plugin Check.") } @@ -2274,7 +2281,10 @@ task jalviewjsIDE_checkJ2sPlugin { if (!eclipseJ2sPluginFile.exists()) { def msg = "Eclipse J2S Plugin is not installed" println(msg) - throw new GradleException(msg) + if (! copyPlugin) { + throw new GradleException(msg) + } + doCopy = true } def digest = MessageDigest.getInstance("MD5") @@ -2286,12 +2296,26 @@ task jalviewjsIDE_checkJ2sPlugin { def eclipseJ2sPluginMd5 = new BigInteger(1, digest.digest()).toString(16).padLeft(32, '0') if (j2sPluginMd5 != eclipseJ2sPluginMd5) { - def msg = "Eclipse J2S Plugin is different to '${j2sPlugin}'" + def msg = "WARNING! Eclipse J2S Plugin '${eclipseJ2sPlugin}' is different to this commit's version '${j2sPlugin}'" println(msg) - throw new GradleException(msg) + if (! copyPlugin) { + throw new StopExecutionException(msg) + } + doCopy = true } - println("Eclipse J2S Plugin is same as '${j2sPlugin}'") + if (doCopy) { + def msg = "WARNING! Auto-copying this commit's j2s plugin version '${j2sPlugin}' to Eclipse J2S Plugin '${eclipseJ2sPlugin}'\n May require an Eclipse restart" + println(msg) + copy { + from j2sPlugin + eclipseJ2sPluginFile.getParentFile().mkdirs() + into eclipseJ2sPluginFile.getParent() + } + } else { + def msg = "Eclipse J2S Plugin is the same as '${j2sPlugin}'" + println(msg) + } } } @@ -2341,15 +2365,17 @@ task jalviewjsIDE_Server { } -// buildship runs this at import +// buildship runs this at import or gradle refresh task eclipseSynchronizationTask { //dependsOn eclipseSetup dependsOn jalviewjsIDE_j2sFile + dependsOn jalviewjsIDE_checkJ2sPlugin } -// buildship runs this at build time +// buildship runs this at build time or project refresh task eclipseAutoBuildTask { + //dependsOn jalviewjsIDE_checkJ2sPlugin dependsOn jalviewjsIDE_PrepareSite } diff --git a/gradle.properties b/gradle.properties index 7389cbe..b64eb11 100644 --- a/gradle.properties +++ b/gradle.properties @@ -147,6 +147,9 @@ eclipse_project_name = jalview eclipse_bin_dir = bin eclipse_debug = false +# for developing in Eclipse as IDE, set this to automatically copy current swingjs/net.sf.j2s.core.jar to your dropins dir +jalviewjs_eclipseIDE_auto_copy_j2s_plugin = false +# Override this in a local.properties file jalviewjs_eclipse_root = ~/buildtools/eclipse/jee-2019-09 jalviewjs_eclipse_dropins_dir = utils/jalviewjs/eclipse/dropins