Permalink
Browse files

add jvmcheck plugin

  • Loading branch information...
1 parent 58fec0a commit 1ee57864dbfed93c5b9c006d9e31ebcb6825d612 @vladdu vladdu committed Sep 9, 2016
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.erlide.jvmcheck</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
@@ -0,0 +1,7 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: erlide Java version check
+Bundle-SymbolicName: org.erlide.jvmcheck;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: erlide.org Team
+Export-Package: org.erlide.jvmcheck
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.startup">
+ <startup
+ class="org.erlide.jvmcheck.JvmCheck">
+ </startup>
+ </extension>
+</plugin>
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.erlide</groupId>
+ <artifactId>org.erlide.parent</artifactId>
+ <version>1.0.0</version>
+ <relativePath>../org.erlide.parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>org.erlide.jvmcheck</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-plugin</packaging>
+
+</project>
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bruno Medeiros - initial API and implementation
+ *******************************************************************************/
+package org.erlide.jvmcheck;
+
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IStartup;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+public class JvmCheck implements IStartup, JvmCheckConstants_Actual {
+
+ public static String getJavaVersionProperty() {
+ return System.getProperty("java.version");
+ }
+
+ public static int getJavaVersion() {
+ String versionProperty = getJavaVersionProperty();
+ String[] versionSegments = versionProperty.split("\\.");
+
+ if(versionSegments.length < 2) {
+ return -1;
+ }
+ String javaVersionStr = versionSegments[1];
+
+ try {
+ return Integer.parseInt(javaVersionStr);
+ } catch(NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ @Override
+ public void earlyStartup() {
+ final int javaVersion = getJavaVersion();
+
+ if(javaVersion >= REQUIRED_JAVA_VERSION)
+ return;
+
+ // Show error message to the user, because the platform just silently fails.
+ // See: https://bugs.eclipse.org/bugs/show_bug.cgi?id=417336
+
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell activeShell = getActiveWorkbenchShell();
+
+ String message = "Could not start " + FEATURE_NAME + " because Java version is: " + javaVersion
+ + "\nVersion " + REQUIRED_JAVA_VERSION + " is required";
+
+ System.err.println(message);
+
+ if(activeShell == null) {
+ return;
+ }
+ MessageDialog.openError(activeShell, "Error", message);
+ }
+ });
+
+ }
+
+ /** Gets the active workbench window. */
+ public static IWorkbenchWindow getActiveWorkbenchWindow() {
+ return PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ }
+
+ /** Gets the active workbench shell. */
+ public static Shell getActiveWorkbenchShell() {
+ IWorkbenchWindow window = getActiveWorkbenchWindow();
+ if(window != null) {
+ return window.getShell();
+ }
+ return null;
+ }
+
+}
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * Copyright (c) 2015, 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Bruno Medeiros - initial API and implementation
+ *******************************************************************************/
+package org.erlide.jvmcheck;
+
+
+public interface JvmCheckConstants_Actual {
+
+ String FEATURE_NAME = "org.erlide";
+ int REQUIRED_JAVA_VERSION = 8;
+
+}
@@ -70,6 +70,7 @@
<module>../org.erlide.dialyzer.ui</module>
<module>../org.erlide.help</module>
<module>../org.erlide.kernel</module>
+ <module>../org.erlide.jvmcheck</module>
<module>../org.erlide.libs</module>
<module>../org.erlide.libs.annotations</module>
<module>../org.erlide.libs2</module>
@@ -23,9 +23,9 @@
</url>
<requires>
- <import feature="org.erlide" version="0.50.0.qualifier" match="compatible"/>
- <import feature="org.eclipse.platform" version="4.4.2.v20150204-1700" match="greaterOrEqual"/>
- <import plugin="org.eclipse.sdk"/>
+ <import feature="org.erlide" version="0.50.1.qualifier" match="compatible"/>
+ <import feature="org.eclipse.platform" version="4.5.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.sdk" version="4.5.0"/>
</requires>
</feature>
@@ -36,6 +36,10 @@ is available from http://www.eclipse.org/legal/epl-v10.html
<discovery label="Handly" url="https://hudson.eclipse.org/handly/job/0.3.x/lastSuccessfulBuild/artifact/build/repository/"/>
</url>
+ <requires>
+ <import feature="org.eclipse.platform" version="4.5.0" match="compatible"/>
+ </requires>
+
<plugin
id="org.erlide.ui"
download-size="0"
@@ -186,4 +190,11 @@ is available from http://www.eclipse.org/legal/epl-v10.html
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.erlide.jvmcheck"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
</feature>

0 comments on commit 1ee5786

Please sign in to comment.