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 @@
</createDirectory>
<runProgram>
<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>
<ruleList>
<platformTest>
......@@ -276,9 +276,27 @@
</platformTest>
</ruleList>
</runProgram>
<runProgram>
<program>mkdir</program>
<programArguments>-p "${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/"</programArguments>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
</ruleList>
</runProgram>
<runProgram>
<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>
<platformTest>
<type>osx</type>
......@@ -287,7 +305,7 @@
</runProgram>
<runProgram>
<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>
<platformTest>
<type>osx</type>
......@@ -300,10 +318,10 @@
<type>exact</type>
<substitutionList>
<substitution>
<pattern>--launcher.XXMaxPermSize512m</pattern>
<value>--launcher.XXMaxPermSize512m
-vm
${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/Contents/Home/bin/java</value>
<pattern>-startup</pattern>
<value>-vm
${installdir}/@mac.shortcut.name@/Contents/Eclipse/jre/Contents/Home/bin/java
-startup</value>
</substitution>
</substitutionList>
<ruleList>
......
......@@ -298,9 +298,9 @@
<properties>
<if.task>net.sf.antcontrib.logic.IfTask</if.task>
<jre.url>http://repositories.rd.lan/tools/studio-tools</jre.url>
<jre.winx86.x64.url>jre-8u112-windows-x64</jre.winx86.x64.url>
<jre.linuxx86.x64.url>jre-8u112-linux-x64</jre.linuxx86.x64.url>
<jre.osx.url>jre-8u112-macosx-x64</jre.osx.url>
<jre.winx86.x64.url>OpenJDK11U-jre_x64_windows_hotspot_11.0.2_9</jre.winx86.x64.url>
<jre.linuxx86.x64.url>OpenJDK11U-jre_x64_linux_hotspot_11.0.2_9</jre.linuxx86.x64.url>
<jre.osx.url>OpenJDK11U-jre_x64_mac_hotspot_11.0.2_9</jre.osx.url>
</properties>
<build>
<plugins>
......@@ -448,11 +448,10 @@
<isset property="jre.present" />
</not>
<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" />
<gunzip
src="${user.home}/${jre.winx86.x64.url}.tar.gz" />
<untar src="${user.home}/${jre.winx86.x64.url}.tar"
<unzip
src="${user.home}/${jre.winx86.x64.url}.zip"
dest="${user.home}/${jre.winx86.x64.url}" />
<delete file="${user.home}/${jre.winx86.x64.url}.tar" />
<delete
......@@ -462,7 +461,7 @@
<copy
todir="${project.build.directory}/products/${productId}/win32/win32/x86_64/jre">
<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>
</target>
</configuration>
......@@ -499,7 +498,7 @@
<copy
todir="${project.build.directory}/products/${productId}/linux/gtk/x86_64/jre">
<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>
</target>
</configuration>
......
......@@ -28,8 +28,8 @@ doNotDisplayForOtherDiagrams=Do not display for other new diagrams
noProcessAvailable=No diagram opened recently
offlineRepositoryTitle=Offline project
offlineRepositoryMessage={0} project is currently offline. You won't be able to update/commit changes in offline mode.
incompatibleJavaVersionTitle=Incompatible java runtime environment version
incompatibleJavaVersionMessage=You are running {0} using an incompatible JRE version ({1}).\nPlease check java requirements.
incompatibleJavaVersionTitle=Incompatible Java version
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.
doNotShowMeAgain=Do not show me this dialog again
startDialogTitle=Welcome to Bonita Studio %s
......
......@@ -52,9 +52,6 @@ public class BonitaStudioApplicationTest {
@Rule
public RealmWithDisplay realm = new RealmWithDisplay();
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
application = spy(new BonitaStudioApplication(realm.getShell().getDisplay()));
......@@ -64,9 +61,6 @@ public class BonitaStudioApplicationTest {
doReturn(IApplication.EXIT_OK).when(application).createAndRunWorkbench(any(Display.class));
}
/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
Job.getJobManager().removeJobChangeListener(application);
......@@ -74,7 +68,7 @@ public class BonitaStudioApplicationTest {
@Test
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);
......@@ -84,18 +78,18 @@ public class BonitaStudioApplicationTest {
@Test
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);
verify(application).openErrorDialog(realm.getShell().getDisplay(), "1.9");
verify(application).openErrorDialog(realm.getShell().getDisplay(), "9");
verify(application, never()).createAndRunWorkbench(realm.getShell().getDisplay());
}
@Test
public void should_start_add_auto_build_job_listener_that_cancel_autobuild_jobs_until_workbench_is_ready()
throws Exception {
doReturn("1.7").when(application).getJavaVersion();
doReturn("1.8").when(application).getJavaVersion();
application.start(null);
......
......@@ -21,6 +21,7 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Objects;
import java.util.Properties;
import java.util.stream.Stream;
......@@ -35,6 +36,7 @@ import org.eclipse.core.commands.operations.OperationHistoryFactory;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
......@@ -43,6 +45,9 @@ import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.EclipseContextFactory;
import org.eclipse.equinox.app.IApplication;
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.MessageDialog;
import org.eclipse.osgi.service.datalocation.Location;
......@@ -57,7 +62,9 @@ import org.osgi.framework.Version;
*/
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;
public static final String PREFERENCES_FILE = ".wsPreferences";
public static final String WS_ROOT = "wsRootDir";
......@@ -73,10 +80,6 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
this.display = display;
}
/*
* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
@Override
public Object start(final IApplicationContext context) {
START_TIME = System.currentTimeMillis();
......@@ -168,7 +171,7 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
protected boolean isJavaVersionSupported(final Display display) {
final String javaVersion = getJavaVersion();
if (javaVersion.startsWith(INVALID_JAVA_VERSION_PREFIX)) {
if (!(javaVersion.startsWith(JAVA_8) || javaVersion.startsWith(JAVA_11))) {
openErrorDialog(display, javaVersion);
return false;
}
......@@ -179,12 +182,14 @@ public class BonitaStudioApplication extends JobChangeAdapter implements IApplic
final Shell shell = new Shell(display);
try {
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 MessageDialogWithLink messageDialog = new MessageDialogWithLink(shell,
Messages.incompatibleJavaVersionTitle, null, Messages.bind(
Messages.incompatibleJavaVersionTitle, null, String.format(
Messages.incompatibleJavaVersionMessage,
org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion),
org.bonitasoft.studio.common.Messages.bonitaStudioModuleName, javaVersion,
"Java 1.8 and Java 11."),
MessageDialog.ERROR,
new String[] { IDialogConstants.OK_LABEL },
0,
......@@ -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
public void stop() {
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