From 4d2867aa88b5ae02ef34a505794c650038fd3591 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 13 Nov 2019 22:52:42 +0000 Subject: [PATCH] JAL-3210 task jalviewjsIDE_checkJ2sPlugin compares installed net.sf.j2s.core with version in eclipse being run --- build.gradle | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 21a4c81..3cf725a 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,11 @@ ext { } else { println("HEADLESS BUILD") } - /* + /* *-/ System.properties.sort { it.key }.each { key, val -> println("SYSTEM PROPERTY ${key}='${val}'") } + /-* *-/ if (false && IN_ECLIPSE) { jalviewDir = jalviewDirAbsolutePath } @@ -702,7 +704,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") } } @@ -2255,6 +2257,43 @@ 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" + + doFirst { + def j2sPlugin = string("${jalviewDir}/${jalviewjs_j2s_plugin}") + 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" + println(msg) + throw new GradleException(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 = "Eclipse J2S Plugin is different to '${j2sPlugin}'" + println(msg) + throw new GradleException(msg) + } + + println("Eclipse J2S Plugin is same as '${j2sPlugin}'") + } +} + task jalviewjsIDE_j2sFile { group "00 JalviewJS in Eclipse" -- 1.7.10.2