Skip to content
This repository was archived by the owner on Dec 20, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning (SemVer)](http://semver.org/).
* Plug-in interface to create several services based on configuration
* New menu and dialog to detect and clean obsolete environments
* Extension to provide sorting of projects/environments
* Log Eclipse launcher command-line to INFO

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Properties;
import java.util.stream.Collectors;

import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilderFactory;
Expand Down Expand Up @@ -62,16 +63,9 @@
import org.xml.sax.helpers.DefaultHandler;

/**
* This starter uses Oomph to setup Eclipse and it's workspace.
*
* TODO: The XML files are manually created and saved for Oomph, so the workspace startup works as
* expected. Instead, the Oomph library should be used if possible. Research has to be done how this
* can be implemented.
*
* TODO: The Eclipse installation is fixed and not configured via Oomph. Each setup should provides
* it's own Eclipse installation and workspace. This is useful if bundle pooling is used. Research
* has to be done how this can be implemented.
* Launcher to start and setup an Eclipse workspace with an already installed product and oomph configuration.
*/
// TODO #41 - refactor to use the oomph libraries
public class EclipseLauncher extends AbstractNoParamsLauncher implements IConfigurable {

public static final String LAUNCHER_NAME = "eclipse";
Expand Down Expand Up @@ -172,7 +166,6 @@ public List<ICommand> launch() throws GemException {
}

final Path projectEnvironment = getConfiguration().getResourcesDirectory() //
// TODO: configurable or to static (I think that it is fine to be non-configurable)
.resolve("eclipseworkspaces") //
.resolve(getLaunchScope().getId());

Expand All @@ -182,7 +175,11 @@ public List<ICommand> launch() throws GemException {

try {
LOGGER.trace("About to run eclipse command");
ExecUtils.exec(createCmd(eclipseFolder, projectEnvironment));
final List<String> cmd = createCmd(eclipseFolder, projectEnvironment);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("Eclipse command: '{}'", cmd.stream().collect(Collectors.joining(" ")));
}
ExecUtils.exec(cmd);
} catch (final IOException e) {
LOGGER.error("Could not start Eclipse.", e);
throw new GemException("Could not start eclipse.", e);
Expand All @@ -208,7 +205,7 @@ private List<String> createCmd(final Path eclipseFolder, final Path projectEnvir
list.add("-Dosgi.configuration.area=file:/"
+ pathToString(projectEnvironment.resolve("eclipse").resolve("configuration")));
// should be quoted as it contains the special characters that might not work
list.add(quoteArg(
list.add(quoteArg(
"-Doomph.redirection.index.redirection=index:/->" + "file:/"
+ pathToString(getConfiguration().getRelativeToConfigFile(getEclipseBean().oomphpath))
+ '/'));
Expand Down Expand Up @@ -367,7 +364,6 @@ private void createEclipseOomphSetup(final Path projectEnvironment)
.resolve("configuration") //
.resolve("org.eclipse.oomph.setup") //
.resolve("installation.setup");
// TODO - extend this if to also creation
if (Files.notExists(eclipseSetup)) {
LOGGER.trace("Creating Eclipse Oomph Setup '{}'", eclipseSetup);
final Path eclipseWorkspace = eclipseSetup.getParent();
Expand All @@ -385,7 +381,6 @@ private void createEclipseOomphSetup(final Path projectEnvironment)
final Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.toString());
// TODO - only write if it doesn't exists?
transformer.transform(new DOMSource(document), new StreamResult(eclipseSetup.toFile()));
LOGGER.trace("Eclipse Oomph Setup file '{}' created", eclipseSetup);
} catch (ParserConfigurationException | TransformerException e) {
Expand Down Expand Up @@ -432,7 +427,6 @@ private void createWorkspaceOomphSetup(final Path projectEnvironment) {
.resolve(".plugins") //
.resolve("org.eclipse.oomph.setup") //
.resolve("workspace.setup");
// TODO - extend this if to also creation
if (Files.notExists(workspaceSetup)) {
LOGGER.trace("Creating Workspace Oomph Setup '{}'", workspaceSetup);
final Path eclipseWorkspace = workspaceSetup.getParent();
Expand All @@ -450,7 +444,6 @@ private void createWorkspaceOomphSetup(final Path projectEnvironment) {
final Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.toString());
// TODO - only write if it doesn't exists?
transformer.transform(new DOMSource(document),
new StreamResult(workspaceSetup.toFile()));
LOGGER.trace("Workspace Oomph Setup file '{}' created", workspaceSetup);
Expand Down Expand Up @@ -553,10 +546,7 @@ public void startElement(String uri, String localName, String qName,

});
if (foundProjects.isEmpty()) {
// TODO - if not present, the launcher should not appear instead of fail
// TODO - that will be much better in terms of checking if something
// TODO - is properly configured
// TODO - that should be done at the EclipseLauncherProvider level
// TODO: #43 - diable/misconfigure instead of failing on launch
throw new GemException("Oomph project for setup not found.");
} else {
foundProjects.sort((p1, p2) -> Integer.compare(p2.length(), p1.length()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.aposin.gem.core.api.config.IConfiguration;
import org.aposin.gem.core.api.launcher.ILauncher;
import org.aposin.gem.core.api.model.IEnvironment;
Expand Down Expand Up @@ -52,7 +53,7 @@ public List<ILauncher> getLaunchers(IEnvironment environment) {
final int nReleases = eclipseBean.releases.size();
final List<ILauncher> starters = new ArrayList<>(nReleases);
for (int idx = 0; idx < nReleases; idx++) {
// TODO - implement a filter on the configuration for environments/projects
// TODO #42 - implement a filter on the configuration for environments/projects
starters.add(new EclipseLauncher(this, environment, idx));
}
return starters;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public static class EclipseReleaseBean {

public String name;
public String displayname;
// TODO - do we really need a list of paths for each Eclipse?
// TODO - I will suggest to use just one
public List<String> paths;
public List<String> args;
public List<String> vmargs;
Expand Down