I am working on a auto installer in java that setup different programs (java, maven, eclipse, environment variables) and launches eclipse with a plugin that I developed. The plugin clones, import and mvn install a project then it creates workingsets. My problem is that the creation of the workingsets stops at 37 of 59 and the only way to restart it is to close the java app that launched eclipse and I don't understand at all where the problem comes from.
The only link that I have from the app and the plugin is that I have a conf.xml that defines the different workingsets and what project should go inside. I write that file in the java app and read it in the eclipse plugin. But I parse the entire xml file before creating the workingsets so the creation should not start if the problem came from there.
This is how I launch eclipse :
String[] command = { eclipseExePath, "-data", workspacePath };
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.environment().put(installation.javaName + "_HOME", javaPath);
try {
Process process = processBuilder.start();
process.waitFor();
} catch (IOException e) {
e.printStackTrace();
}
This is how I create my workingsets :
for (Map.Entry<String, List<String>> entry : workingSetMap.entrySet())
{
if (monitor.isCanceled())
{
break;
}
String workingSetName = entry.getKey();
List<String> keywords = entry.getValue();
// Try to find an existing working set with the same name
IWorkingSet existingWorkingSet = workingSetManager.getWorkingSet(workingSetName);
// Create a new working set or use the existing one
IWorkingSet workingSet;
if (existingWorkingSet == null)
{
workingSet = workingSetManager.createWorkingSet(workingSetName, new IAdaptable[0]);
}
else
{
workingSet = existingWorkingSet;
}
// Add projects to the working set based on keywords
for (IProject project : allProjects)
{
if (monitor.isCanceled())
{
break;
}
monitor.subTask(project.getName());
try
{
if (project.isOpen())
{
for (String keyword : keywords)
{
if (containsKeyword(project, keyword))
{
System.out.println(keyword + " : " + project.getProject().getName());
workingSetManager.addToWorkingSets(project, new IWorkingSet[]
{ workingSet });
break;
}
}
}
}
catch (CoreException e)
{
e.printStackTrace();
}
monitor.worked(1);
}
// Add the working set to the working set manager
if (existingWorkingSet == null)
{
workingSetManager.addWorkingSet(workingSet);
}
}
I go through every project and if the name of the project contains one of the keyword linked to a specific workingsets then I add this project to the workingsets.
Thanks to greg-449's comment I solved the problem, here the code :
String[] command = { eclipseExePath, "-data", workspacePath };
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.environment().put(installation.javaName + "_HOME", javaPath);
processBuilder.redirectError(ProcessBuilder.Redirect.DISCARD);
processBuilder.redirectOutput(ProcessBuilder.Redirect.DISCARD);
try {
Process process = processBuilder.start();
process.waitFor();
} catch (IOException e) {
e.printStackTrace();
}
I chose to discard the output but it can be read as it is explained in the link greg gave.