Commit 6165207c authored by Romain Bioteau's avatar Romain Bioteau Committed by Adrien

feat(java11) add jre 11 in community installers (#1555)

* use hotspot instead of openj9 (bug with macos)

Closes BST-52
parent c16f2414
...@@ -268,7 +268,7 @@ ...@@ -268,7 +268,7 @@
</createDirectory> </createDirectory>
<runProgram> <runProgram>
<program>tar</program> <program>tar</program>
<programArguments>-xzf "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre-8u112-macosx-x64.tar.gz" -C "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre"</programArguments> <programArguments>-xzf "${installdir}/@mac.shortcut.name@/Contents/Eclipse/OpenJDK11U-jre_x64_mac_hotspot_11.0.2_9.tar.gz" -C "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre"</programArguments>
<progressText>Installing JRE...</progressText> <progressText>Installing JRE...</progressText>
<ruleList> <ruleList>
<platformTest> <platformTest>
...@@ -276,9 +276,27 @@ ...@@ -276,9 +276,27 @@
</platformTest> </platformTest>
</ruleList> </ruleList>
</runProgram> </runProgram>
<runProgram>
<program>mkdir</program>
<programArguments>-p "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/"</programArguments>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
</ruleList>
</runProgram>
<runProgram> <runProgram>
<program>mv</program> <program>mv</program>
<programArguments>"${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/jre1.8.0_112.jre/Contents" "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre"</programArguments> <programArguments>"${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/jdk-11.0.2+9-jre/Contents/" "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/"</programArguments>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
</ruleList>
</runProgram>
<runProgram>
<program>rm</program>
<programArguments>-rf "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/jdk-11.0.2+9-jre"</programArguments>
<ruleList> <ruleList>
<platformTest> <platformTest>
<type>osx</type> <type>osx</type>
...@@ -287,7 +305,7 @@ ...@@ -287,7 +305,7 @@
</runProgram> </runProgram>
<runProgram> <runProgram>
<program>rm</program> <program>rm</program>
<programArguments>-rf "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre-8u112-macosx-x64.tar.gz"</programArguments> <programArguments>-rf "${installdir}/@mac.shortcut.name@/Contents/Eclipse/OpenJDK11U-jre_x64_mac_hotspot_11.0.2_9.tar.gz"</programArguments>
<ruleList> <ruleList>
<platformTest> <platformTest>
<type>osx</type> <type>osx</type>
...@@ -300,10 +318,10 @@ ...@@ -300,10 +318,10 @@
<type>exact</type> <type>exact</type>
<substitutionList> <substitutionList>
<substitution> <substitution>
<pattern>--launcher.XXMaxPermSize512m</pattern> <pattern>-startup</pattern>
<value>--launcher.XXMaxPermSize512m <value>-vm
-vm ${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/Contents/Home/bin/java
${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/Contents/Home/bin/java</value> -startup</value>
</substitution> </substitution>
</substitutionList> </substitutionList>
<ruleList> <ruleList>
......
...@@ -298,9 +298,9 @@ ...@@ -298,9 +298,9 @@
<properties> <properties>
<if.task>net.sf.antcontrib.logic.IfTask</if.task> <if.task>net.sf.antcontrib.logic.IfTask</if.task>
<jre.url>http://repositories.rd.lan/tools/studio-tools</jre.url> <jre.url>http://repositories.rd.lan/tools/studio-tools</jre.url>
<jre.winx86.x64.url>jre-8u112-windows-x64</jre.winx86.x64.url> <jre.winx86.x64.url>OpenJDK11U-jre_x64_windows_hotspot_11.0.2_9</jre.winx86.x64.url>
<jre.linuxx86.x64.url>jre-8u112-linux-x64</jre.linuxx86.x64.url> <jre.linuxx86.x64.url>OpenJDK11U-jre_x64_linux_hotspot_11.0.2_9</jre.linuxx86.x64.url>
<jre.osx.url>jre-8u112-macosx-x64</jre.osx.url> <jre.osx.url>OpenJDK11U-jre_x64_mac_hotspot_11.0.2_9</jre.osx.url>
</properties> </properties>
<build> <build>
<plugins> <plugins>
...@@ -448,11 +448,10 @@ ...@@ -448,11 +448,10 @@
<isset property="jre.present" /> <isset property="jre.present" />
</not> </not>
<then> <then>
<get src="${jre.url}/${jre.winx86.x64.url}.tar.gz" <get src="${jre.url}/${jre.winx86.x64.url}.zip"
dest="${user.home}" verbose="true" /> dest="${user.home}" verbose="true" />
<gunzip <unzip
src="${user.home}/${jre.winx86.x64.url}.tar.gz" /> src="${user.home}/${jre.winx86.x64.url}.zip"
<untar src="${user.home}/${jre.winx86.x64.url}.tar"
dest="${user.home}/${jre.winx86.x64.url}" /> dest="${user.home}/${jre.winx86.x64.url}" />
<delete file="${user.home}/${jre.winx86.x64.url}.tar" /> <delete file="${user.home}/${jre.winx86.x64.url}.tar" />
<delete <delete
...@@ -462,7 +461,7 @@ ...@@ -462,7 +461,7 @@
<copy <copy
todir="${project.build.directory}/products/${productId}/win32/win32/x86_64/jre"> todir="${project.build.directory}/products/${productId}/win32/win32/x86_64/jre">
<fileset <fileset
dir="${user.home}/${jre.winx86.x64.url}/jre1.8.0_112" /> dir="${user.home}/${jre.winx86.x64.url}/jdk-11.0.2+9-jre" />
</copy> </copy>
</target> </target>
</configuration> </configuration>
...@@ -499,7 +498,7 @@ ...@@ -499,7 +498,7 @@
<copy <copy
todir="${project.build.directory}/products/${productId}/linux/gtk/x86_64/jre"> todir="${project.build.directory}/products/${productId}/linux/gtk/x86_64/jre">
<fileset <fileset
dir="${user.home}/${jre.linuxx86.x64.url}/jre1.8.0_112" /> dir="${user.home}/${jre.linuxx86.x64.url}/jdk-11.0.2+9-jre" />
</copy> </copy>
</target> </target>
</configuration> </configuration>
......
...@@ -28,8 +28,8 @@ doNotDisplayForOtherDiagrams=Do not display for other new diagrams ...@@ -28,8 +28,8 @@ doNotDisplayForOtherDiagrams=Do not display for other new diagrams
noProcessAvailable=No diagram opened recently noProcessAvailable=No diagram opened recently
offlineRepositoryTitle=Offline project offlineRepositoryTitle=Offline project
offlineRepositoryMessage={0} project is currently offline. You won't be able to update/commit changes in offline mode. offlineRepositoryMessage={0} project is currently offline. You won't be able to update/commit changes in offline mode.
incompatibleJavaVersionTitle=Incompatible java runtime environment version incompatibleJavaVersionTitle=Incompatible Java version
incompatibleJavaVersionMessage=You are running {0} using an incompatible JRE version ({1}).\nPlease check java requirements. incompatibleJavaVersionMessage=You are running %s using an incompatible Java version (%s).\n Supported version are: %s.
exitWarningMessage=Exit {0}?\n\nClosing the Studio will delete unsaved work in the {1} and in the {2}. Be sure you have saved any opened elements in the {2}, and export your custom resources from the {1}.\n\nNote: In <A>Preferences > Database</A>, you can uncheck the "On exit clean database" option to keep your database content. exitWarningMessage=Exit {0}?\n\nClosing the Studio will delete unsaved work in the {1} and in the {2}. Be sure you have saved any opened elements in the {2}, and export your custom resources from the {1}.\n\nNote: In <A>Preferences > Database</A>, you can uncheck the "On exit clean database" option to keep your database content.
doNotShowMeAgain=Do not show me this dialog again doNotShowMeAgain=Do not show me this dialog again
startDialogTitle=Welcome to Bonita Studio %s startDialogTitle=Welcome to Bonita Studio %s
......
...@@ -52,9 +52,6 @@ public class BonitaStudioApplicationTest { ...@@ -52,9 +52,6 @@ public class BonitaStudioApplicationTest {
@Rule @Rule
public RealmWithDisplay realm = new RealmWithDisplay(); public RealmWithDisplay realm = new RealmWithDisplay();
/**
* @throws java.lang.Exception
*/
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
application = spy(new BonitaStudioApplication(realm.getShell().getDisplay())); application = spy(new BonitaStudioApplication(realm.getShell().getDisplay()));
...@@ -64,9 +61,6 @@ public class BonitaStudioApplicationTest { ...@@ -64,9 +61,6 @@ public class BonitaStudioApplicationTest {
doReturn(IApplication.EXIT_OK).when(application).createAndRunWorkbench(any(Display.class)); doReturn(IApplication.EXIT_OK).when(application).createAndRunWorkbench(any(Display.class));
} }
/**
* @throws java.lang.Exception
*/
@After @After
public void tearDown() throws Exception { public void tearDown() throws Exception {
Job.getJobManager().removeJobChangeListener(application); Job.getJobManager().removeJobChangeListener(application);
...@@ -74,7 +68,7 @@ public class BonitaStudioApplicationTest { ...@@ -74,7 +68,7 @@ public class BonitaStudioApplicationTest {
@Test @Test
public void shoul_start_run_workbench_if_java_version_is_valid() throws Exception { public void shoul_start_run_workbench_if_java_version_is_valid() throws Exception {
doReturn("1.7").when(application).getJavaVersion(); doReturn("1.8").when(application).getJavaVersion();
final Object result = application.start(null); final Object result = application.start(null);
...@@ -84,18 +78,18 @@ public class BonitaStudioApplicationTest { ...@@ -84,18 +78,18 @@ public class BonitaStudioApplicationTest {
@Test @Test
public void shoul_start_exit_if_java_version_is_not_valid() throws Exception { public void shoul_start_exit_if_java_version_is_not_valid() throws Exception {
doReturn("1.9").when(application).getJavaVersion(); doReturn("9").when(application).getJavaVersion();
application.start(null); application.start(null);
verify(application).openErrorDialog(realm.getShell().getDisplay(), "1.9"); verify(application).openErrorDialog(realm.getShell().getDisplay(), "9");
verify(application, never()).createAndRunWorkbench(realm.getShell().getDisplay()); verify(application, never()).createAndRunWorkbench(realm.getShell().getDisplay());
} }
@Test @Test
public void should_start_add_auto_build_job_listener_that_cancel_autobuild_jobs_until_workbench_is_ready() public void should_start_add_auto_build_job_listener_that_cancel_autobuild_jobs_until_workbench_is_ready()
throws Exception { throws Exception {
doReturn("1.7").when(application).getJavaVersion(); doReturn("1.8").when(application).getJavaVersion();
application.start(null); application.start(null);
......
...@@ -21,6 +21,7 @@ import java.io.IOException; ...@@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.util.Objects;
import java.util.Properties; import java.util.Properties;
import java.util.stream.Stream; import java.util.stream.Stream;
...@@ -35,6 +36,7 @@ import org.eclipse.core.commands.operations.OperationHistoryFactory; ...@@ -35,6 +36,7 @@ import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.IJobChangeEvent; import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
...@@ -43,6 +45,9 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory; ...@@ -43,6 +45,9 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory; import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jdt.launching.IVMInstall;
import org.eclipse.jdt.launching.IVMInstallType;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.osgi.service.datalocation.Location; import org.eclipse.osgi.service.datalocation.Location;
...@@ -57,7 +62,9 @@ import org.osgi.framework.Version; ...@@ -57,7 +62,9 @@ import org.osgi.framework.Version;
*/ */
public class BonitaStudioApplication extends JobChangeAdapter implements IApplication { public class BonitaStudioApplication extends JobChangeAdapter implements IApplication {
private static final String INVALID_JAVA_VERSION_PREFIX = "1.9"; private static final String HOTSPOT_JRE_11 = "OpenJDK Hotspot JRE 11";
private static final String JAVA_8 = "1.8";
private static final String JAVA_11 = "11";
private Display display; private Display display;
public static final String PREFERENCES_FILE = ".wsPreferences"; public static final String PREFERENCES_FILE = ".wsPreferences";
public static final String WS_ROOT = "wsRootDir"; public static final String WS_ROOT = "wsRootDir";
...@@ -73,10 +80,6 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic ...@@ -73,10 +80,6 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
this.display = display; this.display = display;
} }
/*
* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
@Override @Override
public Object start(final IApplicationContext context) { public Object start(final IApplicationContext context) {
START_TIME = System.currentTimeMillis(); START_TIME = System.currentTimeMillis();
...@@ -168,7 +171,7 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic ...@@ -168,7 +171,7 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
protected boolean isJavaVersionSupported(final Display display) { protected boolean isJavaVersionSupported(final Display display) {
final String javaVersion = getJavaVersion(); final String javaVersion = getJavaVersion();
if (javaVersion.startsWith(INVALID_JAVA_VERSION_PREFIX)) { if (!(javaVersion.startsWith(JAVA_8) || javaVersion.startsWith(JAVA_11))) {
openErrorDialog(display, javaVersion); openErrorDialog(display, javaVersion);
return false; return false;
} }
...@@ -179,12 +182,14 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic ...@@ -179,12 +182,14 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
final Shell shell = new Shell(display); final Shell shell = new Shell(display);
try { try {
final Version version = Version.parseVersion(ProductVersion.CURRENT_VERSION); final Version version = Version.parseVersion(ProductVersion.CURRENT_VERSION);
final String uriWithProductVersion = ONLINE_DOC_REQUIREMENTS + version.getMajor() + "." + version.getMinor(); final String uriWithProductVersion = ONLINE_DOC_REQUIREMENTS + version.getMajor() + "."
+ version.getMinor();
final URI uri = new URI(uriWithProductVersion); final URI uri = new URI(uriWithProductVersion);
final MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell, final MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell,
Messages.incompatibleJavaVersionTitle, null, Messages.bind( Messages.incompatibleJavaVersionTitle, null, String.format(
Messages.incompatibleJavaVersionMessage, Messages.incompatibleJavaVersionMessage,
org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion), org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion,
"Java 1.8 and Java 11."),
MessageDialog.ERROR, MessageDialog.ERROR,
new String[] { IDialogConstants.OK_LABEL }, new String[] { IDialogConstants.OK_LABEL },
0, 0,
...@@ -235,12 +240,31 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic ...@@ -235,12 +240,31 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
} }
} }
} }
File installLocation = new File(Platform.getInstallLocation().getURL().getPath());
File jre11Location = new File(installLocation,"jre");
IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall();
if (!Objects.equals(Platform.getOS(), Platform.OS_MACOSX) && jre11Location.exists()) {
if (defaultVMInstall.getName() != null
&& !Objects.equals(defaultVMInstall.getName(), HOTSPOT_JRE_11)
&& Objects.equals(defaultVMInstall.getInstallLocation(),installLocation)) { //Remove invalid JRE
defaultVMInstall.getVMInstallType().disposeVMInstall(defaultVMInstall.getId());
}
IVMInstallType type = JavaRuntime
.getVMInstallType("org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType");
IVMInstall jre11Install = type.findVMInstall(HOTSPOT_JRE_11);
if(jre11Install == null) {
jre11Install = type.createVMInstall(HOTSPOT_JRE_11);
jre11Install.setName(HOTSPOT_JRE_11);
jre11Install.setInstallLocation(jre11Location);
try {
JavaRuntime.setDefaultVMInstall(jre11Install, new NullProgressMonitor(), true);
} catch (CoreException e) {
BonitaStudioLog.error(e);
}
}
}
} }
/*
* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#stop()
*/
@Override @Override
public void stop() { public void stop() {
final IWorkbench workbench = PlatformUI.getWorkbench(); final IWorkbench workbench = PlatformUI.getWorkbench();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment