mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Repair m2e configurer in Windows
This commit is contained in:
parent
5bb3cbde65
commit
ff469f4cc4
|
@ -1,5 +1,6 @@
|
|||
package org.teavm.eclipse.m2e;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.*;
|
||||
|
@ -57,8 +58,11 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
|||
}
|
||||
monitor.beginTask("Configuring TeaVM builder", sz * 1000);
|
||||
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
|
||||
settings.load();
|
||||
try {
|
||||
if (!hasNature) {
|
||||
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
|
||||
}
|
||||
settings.load();
|
||||
Set<String> coveredProfiles = new HashSet<>();
|
||||
for (MojoExecution execution : executions) {
|
||||
if (monitor.isCanceled()) {
|
||||
|
@ -82,9 +86,6 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
|||
settings.deleteProfile(profile);
|
||||
}
|
||||
}
|
||||
if (!hasNature) {
|
||||
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
|
||||
}
|
||||
settings.save();
|
||||
} finally {
|
||||
monitor.done();
|
||||
|
@ -179,24 +180,20 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
|||
}
|
||||
|
||||
private String absolutePathToWorkspacePath(String path) {
|
||||
try {
|
||||
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IContainer[] containers = root.findContainersForLocationURI(new URI("file://" + path));
|
||||
if (containers.length == 0) {
|
||||
return null;
|
||||
}
|
||||
IContainer container = containers[0];
|
||||
String suffix = "";
|
||||
while (!(container instanceof IProject)) {
|
||||
suffix = "/" + container.getName() + suffix;
|
||||
container = container.getParent();
|
||||
}
|
||||
path = container.getFullPath().toString();
|
||||
return varManager.generateVariableExpression("workspace_loc", path) + suffix;
|
||||
} catch (URISyntaxException e) {
|
||||
throw new RuntimeException(e);
|
||||
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
IContainer[] containers = root.findContainersForLocationURI(new File(path).toURI());
|
||||
if (containers.length == 0) {
|
||||
return null;
|
||||
}
|
||||
IContainer container = containers[0];
|
||||
String suffix = "";
|
||||
while (!(container instanceof IProject)) {
|
||||
suffix = "/" + container.getName() + suffix;
|
||||
container = container.getParent();
|
||||
}
|
||||
path = container.getFullPath().toString();
|
||||
return varManager.generateVariableExpression("workspace_loc", path) + suffix;
|
||||
}
|
||||
|
||||
private TeaVMRuntimeMode getRuntimeMode(String name) {
|
||||
|
|
|
@ -53,8 +53,11 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
|||
private String projectName;
|
||||
|
||||
public PreferencesBasedTeaVMProjectSettings(IProject project) {
|
||||
ProjectScope scope = new ProjectScope(project);
|
||||
globalPreferences = scope.getNode(TeaVMEclipsePlugin.ID);
|
||||
this(project, new ProjectScope(project).getNode(TeaVMEclipsePlugin.ID));
|
||||
}
|
||||
|
||||
public PreferencesBasedTeaVMProjectSettings(IProject project, IEclipsePreferences preferences) {
|
||||
globalPreferences = preferences;
|
||||
projectName = project.getName();
|
||||
}
|
||||
|
||||
|
|
|
@ -16,18 +16,21 @@
|
|||
package org.teavm.eclipse;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IProjectDescription;
|
||||
import org.eclipse.core.resources.ProjectScope;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
import org.eclipse.jface.operation.IRunnableContext;
|
||||
import org.eclipse.jface.operation.IRunnableWithProgress;
|
||||
import org.eclipse.ui.plugin.AbstractUIPlugin;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -90,6 +93,14 @@ public class TeaVMEclipsePlugin extends AbstractUIPlugin {
|
|||
}
|
||||
|
||||
public void addNature(IProgressMonitor progressMonitor, IProject project) throws CoreException {
|
||||
ProjectScope scope = new ProjectScope(project);
|
||||
try {
|
||||
IEclipsePreferences prefs = scope.getNode(TeaVMEclipsePlugin.ID);
|
||||
prefs.flush();
|
||||
settingsMap.put(project, new PreferencesBasedTeaVMProjectSettings(project, prefs));
|
||||
} catch (BackingStoreException e) {
|
||||
throw new RuntimeException("Error creating preferences", e);
|
||||
}
|
||||
IProjectDescription projectDescription = project.getDescription();
|
||||
String[] natureIds = projectDescription.getNatureIds();
|
||||
natureIds = Arrays.copyOf(natureIds, natureIds.length + 1);
|
||||
|
|
Loading…
Reference in New Issue
Block a user