Skip to content

Commit

Permalink
Add an option to the product editor to flag it contain a JRE
Browse files Browse the repository at this point in the history
Currently if one wants to include a JRE it is needed to specify a
concrete EE for each of the linux/win/mac what is quite cumbersome and
could easily forgotten to update.

Instead this adds a new flag "includeJRE" in the product that enables
this for all os at once and always uses the default vm (what is the one
from the target platform or user chosen default).

This will also make it easier for Tools like Tycho that already
investigate the 'includeLaunchers' flag.
  • Loading branch information
laeubi committed Jan 27, 2024
1 parent 2cab2b7 commit b078db2
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.launching.JavaRuntime;
import org.eclipse.osgi.service.resolver.BundleDescription;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.core.plugin.IPluginModelBase;
Expand All @@ -50,6 +51,7 @@
import org.eclipse.pde.internal.core.iproduct.IJREInfo;
import org.eclipse.pde.internal.core.iproduct.ILauncherInfo;
import org.eclipse.pde.internal.core.iproduct.IProduct;
import org.eclipse.pde.internal.core.product.JREInfo;
import org.eclipse.pde.internal.core.util.CoreUtility;

public class ProductExportOperation extends FeatureExportOperation {
Expand Down Expand Up @@ -204,7 +206,7 @@ private void createBuildPropertiesFile(String featureLocation, String[][] config
}
}

IJREInfo jreInfo = fProduct.getJREInfo();
IJREInfo jreInfo = getJreInfo();
if (jreInfo != null) {
for (String[] configuration : configurations) {
String[] config = configuration;
Expand Down Expand Up @@ -263,6 +265,30 @@ private void createBuildPropertiesFile(String featureLocation, String[][] config
save(new File(file, ICoreConstants.BUILD_FILENAME_DESCRIPTOR), properties, "Build Configuration"); //$NON-NLS-1$
}

private IJREInfo getJreInfo() {
if (fProduct.includeJre()) {
return new JREInfo(fProduct.getModel()) {

private static final long serialVersionUID = 1L;

@Override
public boolean includeJREWithProduct(String os) {
// always true for all os
return true;
}

@Override
public File getJVMLocation(String os) {
// always the default vm install, that is the one from the
// target definition
return JavaRuntime.getDefaultVMInstall().getInstallLocation();
}

};
}
return fProduct.getJREInfo();
}

@Override
protected boolean publishingP2Metadata() {
return fInfo.exportMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public String toString() {
String P_INTRO_ID = "introId"; //$NON-NLS-1$
String P_VERSION = "version"; //$NON-NLS-1$
String P_INCLUDE_LAUNCHERS = "includeLaunchers"; //$NON-NLS-1$
String P_INCLUDE_JRE = "includeJRE"; //$NON-NLS-1$
String P_INCLUDE_REQUIREMENTS_AUTOMATICALLY = "autoIncludeRequirements"; //$NON-NLS-1$

String getId();
Expand All @@ -68,6 +69,8 @@ public String toString() {

boolean includeLaunchers();

boolean includeJre();

boolean includeRequirementsAutomatically();

IAboutInfo getAboutInfo();
Expand Down Expand Up @@ -187,4 +190,6 @@ public String toString() {

boolean containsFeature(String id);

void setIncludeJre(boolean includeJre);

}
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class Product extends ProductObject implements IProduct {
private IJREInfo fJVMInfo;
private ProductType fType = ProductType.BUNDLES;
private boolean fIncludeLaunchers = true;
private boolean fIncludeJre = false;
private boolean fAutoIncludeRequirements = true;
private IWindowImages fWindowImages;
private ISplashInfo fSplashInfo;
Expand Down Expand Up @@ -207,6 +208,9 @@ public void write(String indent, PrintWriter writer) {
}
writer.print(" " + P_TYPE + "=\"" + fType + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.print(" " + P_INCLUDE_LAUNCHERS + "=\"" + fIncludeLaunchers + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (fIncludeJre) {
writer.print(" " + P_INCLUDE_JRE + "=\"true\""); //$NON-NLS-1$ //$NON-NLS-2$
}
writer.print(" " + P_INCLUDE_REQUIREMENTS_AUTOMATICALLY + "=\"" + fAutoIncludeRequirements + "\""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.println(">"); //$NON-NLS-1$

Expand Down Expand Up @@ -366,6 +370,8 @@ public void parse(Node node) {
}
String launchers = element.getAttribute(P_INCLUDE_LAUNCHERS);
fIncludeLaunchers = launchers.isBlank() || "true".equals(launchers); //$NON-NLS-1$
String jre = element.getAttribute(P_INCLUDE_JRE);
fIncludeJre = Boolean.parseBoolean(jre);
String autoAdd = element.getAttribute(P_INCLUDE_REQUIREMENTS_AUTOMATICALLY);
fAutoIncludeRequirements = autoAdd.isBlank() || "true".equals(autoAdd); //$NON-NLS-1$

Expand Down Expand Up @@ -875,6 +881,11 @@ public boolean includeLaunchers() {
return fIncludeLaunchers;
}

@Override
public boolean includeJre() {
return fIncludeJre;
}

@Override
public void setIncludeLaunchers(boolean include) {
boolean old = fIncludeLaunchers;
Expand All @@ -883,4 +894,14 @@ public void setIncludeLaunchers(boolean include) {
firePropertyChanged(P_INCLUDE_LAUNCHERS, Boolean.toString(old), Boolean.toString(fIncludeLaunchers));
}
}

@Override
public void setIncludeJre(boolean include) {
boolean old = fIncludeJre;
fIncludeJre = include;
if (isEditable()) {
firePropertyChanged(P_INCLUDE_LAUNCHERS, Boolean.toString(old), Boolean.toString(fIncludeJre));
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2157,6 +2157,7 @@ public class PDEUIMessages extends NLS {
public static String ProductInfoSection_app;
public static String ProductInfoSection_appTooltip;
public static String ProductInfoSection_launchers;
public static String ProductInfoSection_jre;
public static String SplashSection_title;
public static String SplashSection_desc;
public static String SplashSection_plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public class GeneralInfoSection extends PDESection {
private FormEntry fNameEntry;
private FormEntry fVersionEntry;
private Button fLaunchersButton;
private Button fJreButton;

private static int NUM_COLUMNS = 3;

Expand Down Expand Up @@ -146,12 +147,20 @@ public void textValueChanged(FormEntry entry) {
}

private void createLaunchersOption(Composite client, FormToolkit toolkit) {
// includes launcher
fLaunchersButton = toolkit.createButton(client, PDEUIMessages.ProductInfoSection_launchers, SWT.CHECK);
GridData data = new GridData();
data.horizontalSpan = 2;
fLaunchersButton.setLayoutData(data);
fLaunchersButton.setEnabled(isEditable());
fLaunchersButton.addSelectionListener(widgetSelectedAdapter(e -> getProduct().setIncludeLaunchers(fLaunchersButton.getSelection())));
// includes JRE
fJreButton = toolkit.createButton(client, PDEUIMessages.ProductInfoSection_jre, SWT.CHECK);
fJreButton.setLayoutData(data);
fJreButton.setEnabled(isEditable());
fJreButton.addSelectionListener(
widgetSelectedAdapter(e -> getProduct().setIncludeJre(fJreButton.getSelection())));

}

@Override
Expand Down Expand Up @@ -191,6 +200,7 @@ public void refresh() {
fVersionEntry.setValue(product.getVersion(), true);
}
fLaunchersButton.setSelection(product.includeLaunchers());
fJreButton.setSelection(product.includeJre());
super.refresh();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2120,6 +2120,7 @@ ProductInfoSection_new=New...
ProductInfoSection_app=Application:
ProductInfoSection_appTooltip=The application extension identifier
ProductInfoSection_launchers=The product includes native launcher artifacts
ProductInfoSection_jre=The product includes a JRE
SplashSection_title=Location
SplashSection_desc=The splash screen appears when the product launches. Specify the plug-in in which the splash screen is located.
SplashSection_plugin=Plug-in:
Expand Down

0 comments on commit b078db2

Please sign in to comment.