mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-10 08:54:11 -08:00
Merge branch 'master' into tycho-build
Conflicts: teavm-eclipse/teavm-eclipse-plugin/META-INF/MANIFEST.MF
This commit is contained in:
commit
5f4d8ded11
|
@ -38,6 +38,7 @@
|
||||||
<module>teavm-eclipse-plugin</module>
|
<module>teavm-eclipse-plugin</module>
|
||||||
<module>teavm-eclipse-m2e-plugin</module>
|
<module>teavm-eclipse-m2e-plugin</module>
|
||||||
<module>teavm-eclipse-feature</module>
|
<module>teavm-eclipse-feature</module>
|
||||||
|
<module>teavm-eclipse-m2e-feature</module>
|
||||||
<module>teavm-eclipse-updatesite</module>
|
<module>teavm-eclipse-updatesite</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,8 @@
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.teavm</groupId>
|
<groupId>org.teavm</groupId>
|
||||||
<artifactId>teavm</artifactId>
|
<artifactId>teavm-eclipse</artifactId>
|
||||||
<version>0.2-SNAPSHOT</version>
|
<version>0.2-SNAPSHOT</version>
|
||||||
<relativePath>../..</relativePath>
|
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>teavm-eclipse-core-plugin</artifactId>
|
<artifactId>teavm-eclipse-core-plugin</artifactId>
|
||||||
<version>0.2.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
|
@ -60,6 +59,8 @@
|
||||||
<arguments>
|
<arguments>
|
||||||
<item>-f</item>
|
<item>-f</item>
|
||||||
<item>dep-pom.xml</item>
|
<item>dep-pom.xml</item>
|
||||||
|
<item>clean</item>
|
||||||
|
<item>package</item>
|
||||||
</arguments>
|
</arguments>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -237,7 +237,7 @@
|
||||||
unpack="false"/>
|
unpack="false"/>
|
||||||
|
|
||||||
<plugin
|
<plugin
|
||||||
id="teavm-eclipse-plugin"
|
id="teavm-eclipse-core-plugin"
|
||||||
download-size="0"
|
download-size="0"
|
||||||
install-size="0"
|
install-size="0"
|
||||||
version="0.0.0"
|
version="0.0.0"
|
||||||
|
|
|
@ -28,11 +28,16 @@
|
||||||
|
|
||||||
<packaging>eclipse-feature</packaging>
|
<packaging>eclipse-feature</packaging>
|
||||||
|
|
||||||
<repositories>
|
<dependencies>
|
||||||
<repository>
|
<dependency>
|
||||||
<id>teavm</id>
|
<groupId>org.teavm</groupId>
|
||||||
<url>${project.baseUri}../teavm-eclipse-repository/target/repository</url>
|
<artifactId>teavm-eclipse-core-plugin</artifactId>
|
||||||
<layout>p2</layout>
|
<version>${project.version}</version>
|
||||||
</repository>
|
</dependency>
|
||||||
</repositories>
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-eclipse-plugin</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -1,13 +1,15 @@
|
||||||
Manifest-Version: 1.0
|
Manifest-Version: 1.0
|
||||||
Bundle-ManifestVersion: 2
|
Bundle-ManifestVersion: 2
|
||||||
Bundle-Name: TeaVM plugin for m2e
|
Bundle-Name: TeaVM plugin for m2e
|
||||||
Bundle-SymbolicName: teavm-eclipse-m2-plugin;singleton:=true
|
Bundle-SymbolicName: teavm-eclipse-m2e-plugin;singleton:=true
|
||||||
Bundle-Version: 0.2.0.qualifier
|
Bundle-Version: 0.2.0.qualifier
|
||||||
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
|
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
|
||||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||||
Require-Bundle: teavm-eclipse-plugin;bundle-version="[0.2,0.3)",
|
Require-Bundle: teavm-eclipse-plugin;bundle-version="[0.2,0.3)",
|
||||||
org.eclipse.m2e.core;bundle-version="[1.3,2)",
|
org.eclipse.m2e.core;bundle-version="[1.3,2)",
|
||||||
org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)",
|
org.eclipse.core.runtime;bundle-version="[3.8,4.0)",
|
||||||
org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)",
|
org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)",
|
||||||
org.eclipse.core.resources;bundle-version="[3.6,4)",
|
org.eclipse.core.resources;bundle-version="[3.6,4)",
|
||||||
org.eclipse.ui;bundle-version="[3.6,4.0)"
|
org.eclipse.core.variables;bundle-version="[3.2,4)",
|
||||||
|
org.eclipse.ui;bundle-version="[3.6,4.0)",
|
||||||
|
org.eclipse.jdt.core;bundle-version="[3.8,4.0.0)"
|
||||||
|
|
|
@ -1,14 +1,22 @@
|
||||||
package org.teavm.eclipse.m2e;
|
package org.teavm.eclipse.m2e;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.net.URISyntaxException;
|
||||||
import java.util.Set;
|
import java.util.*;
|
||||||
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.plugin.MojoExecution;
|
import org.apache.maven.plugin.MojoExecution;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
import org.eclipse.core.variables.IStringVariableManager;
|
||||||
|
import org.eclipse.core.variables.VariablesPlugin;
|
||||||
|
import org.eclipse.jdt.core.IJavaProject;
|
||||||
|
import org.eclipse.jdt.core.JavaCore;
|
||||||
import org.eclipse.m2e.core.MavenPlugin;
|
import org.eclipse.m2e.core.MavenPlugin;
|
||||||
import org.eclipse.m2e.core.embedder.IMaven;
|
import org.eclipse.m2e.core.embedder.IMaven;
|
||||||
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
|
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
|
||||||
|
@ -16,29 +24,32 @@ import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
|
||||||
import org.teavm.eclipse.TeaVMEclipsePlugin;
|
import org.teavm.eclipse.TeaVMEclipsePlugin;
|
||||||
import org.teavm.eclipse.TeaVMProfile;
|
import org.teavm.eclipse.TeaVMProfile;
|
||||||
import org.teavm.eclipse.TeaVMProjectSettings;
|
import org.teavm.eclipse.TeaVMProjectSettings;
|
||||||
|
import org.teavm.eclipse.TeaVMRuntimeMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
||||||
|
private static final String TOOL_ID = "teavm-eclipse-m2e-plugin.tool";
|
||||||
private static final String TEAVM_ARTIFACT_ID = "teavm-maven-plugin";
|
private static final String TEAVM_ARTIFACT_ID = "teavm-maven-plugin";
|
||||||
private static final String TEAVM_GROUP_ID = "org.teavm";
|
private static final String TEAVM_GROUP_ID = "org.teavm";
|
||||||
private static final String TEAVM_MAIN_GOAL = "build-javascript";
|
private static final String TEAVM_MAIN_GOAL = "build-javascript";
|
||||||
private int executionIdGenerator;
|
private int executionIdGenerator;
|
||||||
private Set<String> usedExecutionIds = new HashSet<>();
|
private Set<String> usedExecutionIds = new HashSet<>();
|
||||||
private IMaven maven;
|
private IMaven maven;
|
||||||
private MavenProject mavenProject;
|
private MavenSession mavenSession;
|
||||||
|
private IProject project;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void configure(ProjectConfigurationRequest configurationRequest, IProgressMonitor monitor)
|
public void configure(ProjectConfigurationRequest configurationRequest, IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
maven = MavenPlugin.getMaven();
|
maven = MavenPlugin.getMaven();
|
||||||
mavenProject = configurationRequest.getMavenProject();
|
mavenSession = configurationRequest.getMavenSession();
|
||||||
List<MojoExecution> executions = configurationRequest.getMavenProjectFacade().getMojoExecutions(
|
List<MojoExecution> executions = configurationRequest.getMavenProjectFacade().getMojoExecutions(
|
||||||
TEAVM_GROUP_ID, TEAVM_ARTIFACT_ID, monitor, TEAVM_MAIN_GOAL);
|
TEAVM_GROUP_ID, TEAVM_ARTIFACT_ID, monitor, TEAVM_MAIN_GOAL);
|
||||||
TeaVMEclipsePlugin teaVMPlugin = TeaVMEclipsePlugin.getDefault();
|
TeaVMEclipsePlugin teaVMPlugin = TeaVMEclipsePlugin.getDefault();
|
||||||
IProject project = configurationRequest.getProject();
|
project = configurationRequest.getProject();
|
||||||
boolean hasNature = project.hasNature(TeaVMEclipsePlugin.NATURE_ID);
|
boolean hasNature = project.hasNature(TeaVMEclipsePlugin.NATURE_ID);
|
||||||
int sz = executions.size();
|
int sz = executions.size();
|
||||||
if (!hasNature) {
|
if (!hasNature) {
|
||||||
|
@ -48,21 +59,29 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
||||||
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
|
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
|
||||||
settings.load();
|
settings.load();
|
||||||
try {
|
try {
|
||||||
|
Set<String> coveredProfiles = new HashSet<>();
|
||||||
for (MojoExecution execution : executions) {
|
for (MojoExecution execution : executions) {
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String profileId = getIdForProfile(execution);
|
String profileId = getIdForProfile(execution);
|
||||||
|
coveredProfiles.add(profileId);
|
||||||
TeaVMProfile profile = settings.getProfile(profileId);
|
TeaVMProfile profile = settings.getProfile(profileId);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
profile = settings.createProfile();
|
profile = settings.createProfile();
|
||||||
profile.setName(profileId);
|
profile.setName(profileId);
|
||||||
}
|
}
|
||||||
|
profile.setExternalToolId(TOOL_ID);
|
||||||
configureProfile(execution, profile, new SubProgressMonitor(monitor, 1000));
|
configureProfile(execution, profile, new SubProgressMonitor(monitor, 1000));
|
||||||
if (monitor.isCanceled()) {
|
if (monitor.isCanceled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (TeaVMProfile profile : settings.getProfiles()) {
|
||||||
|
if (!coveredProfiles.contains(profile.getName()) && profile.getExternalToolId().equals(TOOL_ID)) {
|
||||||
|
settings.deleteProfile(profile);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!hasNature) {
|
if (!hasNature) {
|
||||||
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
|
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
|
||||||
}
|
}
|
||||||
|
@ -74,19 +93,120 @@ public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
||||||
|
|
||||||
private void configureProfile(MojoExecution execution, TeaVMProfile profile, IProgressMonitor monitor)
|
private void configureProfile(MojoExecution execution, TeaVMProfile profile, IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
monitor.beginTask("Configuring profile " + profile.getName(), 30);
|
monitor.beginTask("Configuring profile " + profile.getName(), 110);
|
||||||
String mainClass = maven.getMojoParameterValue(mavenProject, execution, "mainClass", String.class,
|
String buildDir = getProjectBuildDirectory();
|
||||||
new SubProgressMonitor(monitor, 10));
|
|
||||||
|
String mainClass = maven.getMojoParameterValue(mavenSession, execution, "mainClass", String.class);
|
||||||
profile.setMainClass(mainClass);
|
profile.setMainClass(mainClass);
|
||||||
String targetDir = maven.getMojoParameterValue(mavenProject, execution, "targetDirectory", String.class,
|
monitor.worked(10);
|
||||||
new SubProgressMonitor(monitor, 10));
|
|
||||||
profile.setTargetDirectory(targetDir);
|
String targetDir = maven.getMojoParameterValue(mavenSession, execution, "targetDirectory", String.class);
|
||||||
String targetFileName = maven.getMojoParameterValue(mavenProject, execution, "targetFileName", String.class,
|
profile.setTargetDirectory(targetDir != null ? absolutePathToWorkspacePath(targetDir) :
|
||||||
new SubProgressMonitor(monitor, 10));
|
buildDir + "/javascript");
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
String targetFileName = maven.getMojoParameterValue(mavenSession, execution, "targetFileName", String.class);
|
||||||
profile.setTargetFileName(targetFileName != null ? targetFileName : "classes.js");
|
profile.setTargetFileName(targetFileName != null ? targetFileName : "classes.js");
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
Boolean minifying = maven.getMojoParameterValue(mavenSession, execution, "minifying", Boolean.class);
|
||||||
|
profile.setMinifying(minifying != null ? minifying : true);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
String runtime = maven.getMojoParameterValue(mavenSession, execution, "runtime", String.class);
|
||||||
|
profile.setRuntimeMode(runtime != null ? getRuntimeMode(runtime) : TeaVMRuntimeMode.SEPARATE);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
Properties properties = maven.getMojoParameterValue(mavenSession, execution, "properties", Properties.class);
|
||||||
|
profile.setProperties(properties != null ? properties : new Properties());
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
Boolean debug = maven.getMojoParameterValue(mavenSession, execution, "debugInformationGenerated",
|
||||||
|
Boolean.class);
|
||||||
|
profile.setDebugInformationGenerated(debug != null ? debug : false);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
Boolean sourceMaps = maven.getMojoParameterValue(mavenSession, execution, "sourceMapsGenerated",
|
||||||
|
Boolean.class);
|
||||||
|
profile.setSourceMapsGenerated(sourceMaps != null ? sourceMaps : false);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
Boolean incremental = maven.getMojoParameterValue(mavenSession, execution, "incremental", Boolean.class);
|
||||||
|
profile.setIncremental(incremental != null ? incremental : false);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
String cacheDir = maven.getMojoParameterValue(mavenSession, execution, "cacheDirectory", String.class);
|
||||||
|
profile.setCacheDirectory(cacheDir != null ? absolutePathToWorkspacePath(cacheDir) :
|
||||||
|
buildDir + "/teavm-cache");
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
String[] transformers = maven.getMojoParameterValue(mavenSession, execution, "transformers", String[].class);
|
||||||
|
profile.setTransformers(transformers != null ? transformers : new String[0]);
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
|
profile.setClassAliases(readClassAliases(execution));
|
||||||
|
monitor.worked(10);
|
||||||
|
|
||||||
monitor.done();
|
monitor.done();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, String> readClassAliases(MojoExecution execution) {
|
||||||
|
Map<String, String> aliases = new HashMap<>();
|
||||||
|
Xpp3Dom aliasesElem = execution.getConfiguration().getChild("classAliases");
|
||||||
|
if (aliasesElem != null) {
|
||||||
|
for (Xpp3Dom item : aliasesElem.getChildren()) {
|
||||||
|
String className = item.getChild("className").getValue();
|
||||||
|
String alias = item.getChild("alias").getValue();
|
||||||
|
aliases.put(className, alias);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getProjectBuildDirectory() throws CoreException {
|
||||||
|
IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager();
|
||||||
|
if (!project.hasNature(JavaCore.NATURE_ID)) {
|
||||||
|
return varManager.generateVariableExpression("workspace_loc", "/" + project.getName());
|
||||||
|
}
|
||||||
|
IJavaProject javaProject = JavaCore.create(project);
|
||||||
|
String path = javaProject.getOutputLocation().toString();
|
||||||
|
return varManager.generateVariableExpression("workspace_loc", path);
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private TeaVMRuntimeMode getRuntimeMode(String name) {
|
||||||
|
switch (name) {
|
||||||
|
case "SEPARATE":
|
||||||
|
return TeaVMRuntimeMode.SEPARATE;
|
||||||
|
case "MERGED":
|
||||||
|
return TeaVMRuntimeMode.MERGE;
|
||||||
|
case "NONE":
|
||||||
|
return TeaVMRuntimeMode.NONE;
|
||||||
|
default:
|
||||||
|
return TeaVMRuntimeMode.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getIdForProfile(MojoExecution pluginExecution) {
|
private String getIdForProfile(MojoExecution pluginExecution) {
|
||||||
String executionId = pluginExecution.getExecutionId();
|
String executionId = pluginExecution.getExecutionId();
|
||||||
if (executionId != null && usedExecutionIds.add(executionId)) {
|
if (executionId != null && usedExecutionIds.add(executionId)) {
|
||||||
|
|
|
@ -23,6 +23,5 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)",
|
||||||
org.eclipse.core.databinding.observable;bundle-version="[1.4.1,2)",
|
org.eclipse.core.databinding.observable;bundle-version="[1.4.1,2)",
|
||||||
org.eclipse.jface.databinding;bundle-version="[1.6.0,2)",
|
org.eclipse.jface.databinding;bundle-version="[1.6.0,2)",
|
||||||
teavm-eclipse-core-plugin;bundle-version="0.2.0"
|
teavm-eclipse-core-plugin;bundle-version="0.2.0"
|
||||||
Bundle-ClassPath: .
|
|
||||||
Export-Package: org.teavm.eclipse.debugger,org.teavm.eclipse
|
Export-Package: org.teavm.eclipse.debugger,org.teavm.eclipse
|
||||||
Bundle-ActivationPolicy: lazy
|
Bundle-ActivationPolicy: lazy
|
||||||
|
|
|
@ -43,6 +43,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
public static final String PROPERTIES = "properties";
|
public static final String PROPERTIES = "properties";
|
||||||
public static final String CLASSES = "classes";
|
public static final String CLASSES = "classes";
|
||||||
public static final String TRANSFORMERS = "transformers";
|
public static final String TRANSFORMERS = "transformers";
|
||||||
|
public static final String EXTERNAL_TOOL_ID = "externalTool";
|
||||||
|
|
||||||
private static final String NEW_PROFILE_NAME = "New profile";
|
private static final String NEW_PROFILE_NAME = "New profile";
|
||||||
private List<ProfileImpl> profiles = new ArrayList<>();
|
private List<ProfileImpl> profiles = new ArrayList<>();
|
||||||
|
@ -71,7 +72,7 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
if (profileMap.get(profile.getName()) != profile) {
|
if (profileMap.get(profile.getName()) != profile) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
profileMap.remove(profile);
|
profileMap.remove(profile.getName());
|
||||||
profiles.remove(profile);
|
profiles.remove(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +110,8 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
}
|
}
|
||||||
for (String key : globalPreferences.childrenNames()) {
|
for (String key : globalPreferences.childrenNames()) {
|
||||||
if (!profileMap.containsKey(key)) {
|
if (!profileMap.containsKey(key)) {
|
||||||
globalPreferences.node(key).removeNode();
|
Preferences node = globalPreferences.node(key);
|
||||||
|
node.removeNode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
globalPreferences.flush();
|
globalPreferences.flush();
|
||||||
|
@ -160,7 +162,8 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
private boolean debugInformationGenerated;
|
private boolean debugInformationGenerated;
|
||||||
private Properties properties = new Properties();
|
private Properties properties = new Properties();
|
||||||
private String[] transformers = new String[0];
|
private String[] transformers = new String[0];
|
||||||
private Map<String, String> classeAliases = new HashMap<>();
|
private Map<String, String> classAliases = new HashMap<>();
|
||||||
|
private String externalToolId = "";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -293,12 +296,12 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, String> getClassAliases() {
|
public Map<String, String> getClassAliases() {
|
||||||
return new HashMap<>(classeAliases);
|
return new HashMap<>(classAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setClassAliases(Map<String, String> classAliases) {
|
public void setClassAliases(Map<String, String> classAliases) {
|
||||||
this.classeAliases = new HashMap<>(classAliases);
|
this.classAliases = new HashMap<>(classAliases);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -311,6 +314,16 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
this.transformers = transformers.clone();
|
this.transformers = transformers.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getExternalToolId() {
|
||||||
|
return externalToolId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setExternalToolId(String toolId) {
|
||||||
|
this.externalToolId = toolId;
|
||||||
|
}
|
||||||
|
|
||||||
public void load() throws BackingStoreException {
|
public void load() throws BackingStoreException {
|
||||||
preferences.sync();
|
preferences.sync();
|
||||||
enabled = preferences.getBoolean(ENABLED, true);
|
enabled = preferences.getBoolean(ENABLED, true);
|
||||||
|
@ -335,8 +348,9 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
Preferences classesPrefs = preferences.node(CLASSES);
|
Preferences classesPrefs = preferences.node(CLASSES);
|
||||||
classesPrefs.sync();
|
classesPrefs.sync();
|
||||||
for (String key : classesPrefs.keys()) {
|
for (String key : classesPrefs.keys()) {
|
||||||
classeAliases.put(key, classesPrefs.get(key, "_"));
|
classAliases.put(key, classesPrefs.get(key, "_"));
|
||||||
}
|
}
|
||||||
|
externalToolId = preferences.get(EXTERNAL_TOOL_ID, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() throws BackingStoreException {
|
public void save() throws BackingStoreException {
|
||||||
|
@ -365,10 +379,11 @@ public class PreferencesBasedTeaVMProjectSettings implements TeaVMProjectSetting
|
||||||
transformersPrefs.flush();
|
transformersPrefs.flush();
|
||||||
Preferences classesPrefs = preferences.node(CLASSES);
|
Preferences classesPrefs = preferences.node(CLASSES);
|
||||||
classesPrefs.clear();
|
classesPrefs.clear();
|
||||||
for (String key : classeAliases.keySet()) {
|
for (String key : classAliases.keySet()) {
|
||||||
classesPrefs.put(key, classeAliases.get(key));
|
classesPrefs.put(key, classAliases.get(key));
|
||||||
}
|
}
|
||||||
classesPrefs.flush();
|
classesPrefs.flush();
|
||||||
|
preferences.put(EXTERNAL_TOOL_ID, externalToolId);
|
||||||
preferences.flush();
|
preferences.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,4 +78,8 @@ public interface TeaVMProfile {
|
||||||
Map<String, String> getClassAliases();
|
Map<String, String> getClassAliases();
|
||||||
|
|
||||||
void setClassAliases(Map<String, String> classAliases);
|
void setClassAliases(Map<String, String> classAliases);
|
||||||
|
|
||||||
|
String getExternalToolId();
|
||||||
|
|
||||||
|
void setExternalToolId(String toolId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
|
||||||
tool.setDebugInformationGenerated(profile.isDebugInformationGenerated());
|
tool.setDebugInformationGenerated(profile.isDebugInformationGenerated());
|
||||||
tool.setSourceMapsFileGenerated(profile.isSourceMapsGenerated());
|
tool.setSourceMapsFileGenerated(profile.isSourceMapsGenerated());
|
||||||
String targetDir = profile.getTargetDirectory();
|
String targetDir = profile.getTargetDirectory();
|
||||||
tool.setTargetDirectory(new File(varManager.performStringSubstitution(targetDir)));
|
tool.setTargetDirectory(new File(varManager.performStringSubstitution(targetDir, false)));
|
||||||
tool.setTargetFileName(profile.getTargetFileName());
|
tool.setTargetFileName(profile.getTargetFileName());
|
||||||
tool.setMinifying(profile.isMinifying());
|
tool.setMinifying(profile.isMinifying());
|
||||||
tool.setRuntime(mapRuntime(profile.getRuntimeMode()));
|
tool.setRuntime(mapRuntime(profile.getRuntimeMode()));
|
||||||
|
@ -107,7 +107,8 @@ public class TeaVMProjectBuilder extends IncrementalProjectBuilder {
|
||||||
tool.getProperties().putAll(profile.getProperties());
|
tool.getProperties().putAll(profile.getProperties());
|
||||||
tool.setIncremental(profile.isIncremental());
|
tool.setIncremental(profile.isIncremental());
|
||||||
String cacheDir = profile.getCacheDirectory();
|
String cacheDir = profile.getCacheDirectory();
|
||||||
tool.setCacheDirectory(!cacheDir.isEmpty() ? new File(varManager.performStringSubstitution(cacheDir)) : null);
|
tool.setCacheDirectory(!cacheDir.isEmpty() ?
|
||||||
|
new File(varManager.performStringSubstitution(cacheDir, false)) : null);
|
||||||
for (ClassHolderTransformer transformer : instantiateTransformers(profile, classLoader)) {
|
for (ClassHolderTransformer transformer : instantiateTransformers(profile, classLoader)) {
|
||||||
tool.getTransformers().add(transformer);
|
tool.getTransformers().add(transformer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import org.teavm.eclipse.TeaVMRuntimeMode;
|
||||||
public class TeaVMProfileDialog extends Dialog {
|
public class TeaVMProfileDialog extends Dialog {
|
||||||
private static List<TeaVMRuntimeMode> runtimeModes = Arrays.asList(TeaVMRuntimeMode.SEPARATE,
|
private static List<TeaVMRuntimeMode> runtimeModes = Arrays.asList(TeaVMRuntimeMode.SEPARATE,
|
||||||
TeaVMRuntimeMode.MERGE, TeaVMRuntimeMode.NONE);
|
TeaVMRuntimeMode.MERGE, TeaVMRuntimeMode.NONE);
|
||||||
|
private TabFolder tabFolder;
|
||||||
private Text nameField;
|
private Text nameField;
|
||||||
private Text mainClassField;
|
private Text mainClassField;
|
||||||
private Button mainClassChooseButton;
|
private Button mainClassChooseButton;
|
||||||
|
@ -107,7 +108,7 @@ public class TeaVMProfileDialog extends Dialog {
|
||||||
area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
area.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
ScrolledComposite scrollContainer = new ScrolledComposite(area, SWT.V_SCROLL | SWT.H_SCROLL);
|
ScrolledComposite scrollContainer = new ScrolledComposite(area, SWT.V_SCROLL | SWT.H_SCROLL);
|
||||||
scrollContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
scrollContainer.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
|
||||||
TabFolder tabFolder = new TabFolder(scrollContainer, SWT.TOP);
|
tabFolder = new TabFolder(scrollContainer, SWT.TOP);
|
||||||
scrollContainer.setContent(tabFolder);
|
scrollContainer.setContent(tabFolder);
|
||||||
scrollContainer.setExpandHorizontal(true);
|
scrollContainer.setExpandHorizontal(true);
|
||||||
scrollContainer.setExpandVertical(true);
|
scrollContainer.setExpandVertical(true);
|
||||||
|
@ -644,6 +645,18 @@ public class TeaVMProfileDialog extends Dialog {
|
||||||
cacheDirectoryWorkspaceButton.setEnabled(incrementalButton.getSelection());
|
cacheDirectoryWorkspaceButton.setEnabled(incrementalButton.getSelection());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setEnabledRecursive(Composite composite, boolean enabled) {
|
||||||
|
Control[] children = composite.getChildren();
|
||||||
|
for (int i = 0; i < children.length; i++) {
|
||||||
|
if (children[i] instanceof Composite) {
|
||||||
|
setEnabledRecursive((Composite) children[i], enabled);
|
||||||
|
} else {
|
||||||
|
children[i].setEnabled(enabled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
composite.setEnabled(enabled);
|
||||||
|
}
|
||||||
|
|
||||||
private void load() {
|
private void load() {
|
||||||
nameField.setText(profile.getName());
|
nameField.setText(profile.getName());
|
||||||
mainClassField.setText(profile.getMainClass() != null ? profile.getMainClass() : "");
|
mainClassField.setText(profile.getMainClass() != null ? profile.getMainClass() : "");
|
||||||
|
@ -671,6 +684,11 @@ public class TeaVMProfileDialog extends Dialog {
|
||||||
row.alias = entry.getValue();
|
row.alias = entry.getValue();
|
||||||
classAliases.add(row);
|
classAliases.add(row);
|
||||||
}
|
}
|
||||||
|
for (Control control : tabFolder.getTabList()) {
|
||||||
|
if (control instanceof Composite) {
|
||||||
|
setEnabledRecursive((Composite)control, profile.getExternalToolId().isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean save() {
|
private boolean save() {
|
||||||
|
|
|
@ -99,6 +99,11 @@ public class TeaVMProjectPropertyPage extends PropertyPage implements IWorkbench
|
||||||
TableColumn fileColumn = new TableColumn(profilesTable, SWT.LEFT);
|
TableColumn fileColumn = new TableColumn(profilesTable, SWT.LEFT);
|
||||||
fileColumn.setText("Target file");
|
fileColumn.setText("Target file");
|
||||||
fileColumn.setWidth(150);
|
fileColumn.setWidth(150);
|
||||||
|
profilesTable.addSelectionListener(new SelectionAdapter() {
|
||||||
|
@Override public void widgetSelected(SelectionEvent e) {
|
||||||
|
updateTableSelection();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
addProfileButton = new Button(container, SWT.PUSH);
|
addProfileButton = new Button(container, SWT.PUSH);
|
||||||
addProfileButton.setText("Add...");
|
addProfileButton.setText("Add...");
|
||||||
|
@ -130,6 +135,16 @@ public class TeaVMProjectPropertyPage extends PropertyPage implements IWorkbench
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateTableSelection() {
|
||||||
|
if (profilesTable.getSelectionCount() != 1) {
|
||||||
|
removeProfileButton.setEnabled(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TableItem item = profilesTable.getSelection()[0];
|
||||||
|
TeaVMProfile profile = (TeaVMProfile)item.getData();
|
||||||
|
removeProfileButton.setEnabled(profile.getExternalToolId().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
private void loadProfiles() {
|
private void loadProfiles() {
|
||||||
try {
|
try {
|
||||||
settings.load();
|
settings.load();
|
||||||
|
@ -197,6 +212,10 @@ public class TeaVMProjectPropertyPage extends PropertyPage implements IWorkbench
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TableItem item = profilesTable.getSelection()[0];
|
TableItem item = profilesTable.getSelection()[0];
|
||||||
|
TeaVMProfile profile = (TeaVMProfile)item.getData();
|
||||||
|
if (!profile.getExternalToolId().isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean confirmed = MessageDialog.openConfirm(getShell(), "Deletion confirmation",
|
boolean confirmed = MessageDialog.openConfirm(getShell(), "Deletion confirmation",
|
||||||
"Are you sure to delete profile " + item.getText(0) + "?");
|
"Are you sure to delete profile " + item.getText(0) + "?");
|
||||||
if (!confirmed) {
|
if (!confirmed) {
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<site>
|
<site>
|
||||||
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature" version="0.2.0.qualifier" os="aix,hpux,linux,macosx,qnx,solaris,win32" ws="carbon,cocoa,gtk,motif,photon,win32,wpf" arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64">
|
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature"
|
||||||
|
version="0.2.0.qualifier">
|
||||||
|
<category name="teavm-category"/>
|
||||||
|
</feature>
|
||||||
|
<feature url="features/teavm-eclipse-m2e-feature_0.2.0.qualifier.jar" id="teavm-eclipse-m2e-feature"
|
||||||
|
version="0.2.0.qualifier">
|
||||||
<category name="teavm-category"/>
|
<category name="teavm-category"/>
|
||||||
</feature>
|
</feature>
|
||||||
<category-def name="teavm-category" label="TeaVM"/>
|
<category-def name="teavm-category" label="TeaVM"/>
|
||||||
|
|
|
@ -25,14 +25,18 @@
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>teavm-eclipse-updatesite</artifactId>
|
<artifactId>teavm-eclipse-updatesite</artifactId>
|
||||||
<version>0.2.0-SNAPSHOT</version>
|
<version>0.2.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<packaging>eclipse-repository</packaging>
|
<packaging>eclipse-repository</packaging>
|
||||||
|
|
||||||
<repositories>
|
<dependencies>
|
||||||
<repository>
|
<dependency>
|
||||||
<id>teavm</id>
|
<groupId>org.teavm</groupId>
|
||||||
<url>${project.baseUri}../teavm-eclipse-repository/target/repository</url>
|
<artifactId>teavm-eclipse-feature</artifactId>
|
||||||
<layout>p2</layout>
|
<version>${project.version}</version>
|
||||||
</repository>
|
</dependency>
|
||||||
</repositories>
|
<dependency>
|
||||||
|
<groupId>org.teavm</groupId>
|
||||||
|
<artifactId>teavm-eclipse-m2e-feature</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -3,7 +3,10 @@
|
||||||
<description name="TeaVM update site">
|
<description name="TeaVM update site">
|
||||||
TeaVM update site
|
TeaVM update site
|
||||||
</description>
|
</description>
|
||||||
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature" version="0.0.0" os="aix,hpux,linux,macosx,qnx,solaris,win32" ws="carbon,cocoa,gtk,motif,photon,win32,wpf" arch="ia64,ia64_32,PA_RISC,ppc,sparc,x86,x86_64">
|
<feature url="features/teavm-eclipse-feature_0.2.0.qualifier.jar" id="teavm-eclipse-feature" version="0.0.0">
|
||||||
|
<category name="teavm-eclipse-caregory"/>
|
||||||
|
</feature>
|
||||||
|
<feature url="features/teavm-eclipse-m2e-feature_0.2.0.qualifier.jar" id="teavm-eclipse-m2e-feature" version="0.0.0">
|
||||||
<category name="teavm-eclipse-caregory"/>
|
<category name="teavm-eclipse-caregory"/>
|
||||||
</feature>
|
</feature>
|
||||||
<category-def name="teavm-eclipse-caregory" label="TeaVM"/>
|
<category-def name="teavm-eclipse-caregory" label="TeaVM"/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user