mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
First version of m2e-plugin:
https://github.com/konsoletyper/teavm/issues/5
This commit is contained in:
parent
ad33c998dc
commit
50bba7b9e0
7
teavm-eclipse/teavm-eclipse-m2e-plugin/.classpath
Normal file
7
teavm-eclipse/teavm-eclipse-m2e-plugin/.classpath
Normal file
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target"/>
|
||||
</classpath>
|
1
teavm-eclipse/teavm-eclipse-m2e-plugin/.gitignore
vendored
Normal file
1
teavm-eclipse/teavm-eclipse-m2e-plugin/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
28
teavm-eclipse/teavm-eclipse-m2e-plugin/.project
Normal file
28
teavm-eclipse/teavm-eclipse-m2e-plugin/.project
Normal file
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>teavm-eclipse-m2e-plugin</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,7 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
13
teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF
Normal file
13
teavm-eclipse/teavm-eclipse-m2e-plugin/META-INF/MANIFEST.MF
Normal file
|
@ -0,0 +1,13 @@
|
|||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Teavm-eclipse-m2e-plugin
|
||||
Bundle-SymbolicName: org.teavm.eclipse.m2e;singleton:=true
|
||||
Bundle-Version: 0.2.0.qualifier
|
||||
Bundle-Vendor: Alexey Andreev <konsoletyper@gmail.com>
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
|
||||
Require-Bundle: org.teavm.eclipse;bundle-version="[0.2,0.3)",
|
||||
org.eclipse.m2e.core;bundle-version="[1.3,2)",
|
||||
org.eclipse.core.runtime;bundle-version="[3.8.0,4.0)",
|
||||
org.eclipse.m2e.maven.runtime;bundle-version="[1.3,2)",
|
||||
org.eclipse.core.resources;bundle-version="[3.6,4)",
|
||||
org.eclipse.ui;bundle-version="[3.6,4.0)"
|
6
teavm-eclipse/teavm-eclipse-m2e-plugin/build.properties
Normal file
6
teavm-eclipse/teavm-eclipse-m2e-plugin/build.properties
Normal file
|
@ -0,0 +1,6 @@
|
|||
source.. = src/main/java/
|
||||
output.. = target/
|
||||
bin.includes = plugin.xml,\
|
||||
META-INF/,\
|
||||
.,\
|
||||
lifecycle-mapping-metadata.xml
|
|
@ -0,0 +1,20 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>org.teavm</groupId>
|
||||
<artifactId>teavm-maven-plugin</artifactId>
|
||||
<versionRange>0.2.0-SNAPSHOT</versionRange>
|
||||
<goals>
|
||||
<goal>build-javascript</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<configurator>
|
||||
<id>org.teavm.eclipse.m2e.teaVMConfigurator</id>
|
||||
</configurator>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
26
teavm-eclipse/teavm-eclipse-m2e-plugin/plugin.xml
Normal file
26
teavm-eclipse/teavm-eclipse-m2e-plugin/plugin.xml
Normal file
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2014 Alexey Andreev.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
<extension point="org.eclipse.m2e.core.projectConfigurators">
|
||||
<configurator class="org.teavm.eclipse.m2e.TeaVMProjectConfigurator" name="TeaVM project configurator"
|
||||
id="org.teavm.eclipse.m2e.teaVMConfigurator"/>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.m2e.core.lifecycleMappingMetadataSource">
|
||||
</extension>
|
||||
</plugin>
|
|
@ -0,0 +1,101 @@
|
|||
package org.teavm.eclipse.m2e;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||
import org.eclipse.m2e.core.MavenPlugin;
|
||||
import org.eclipse.m2e.core.embedder.IMaven;
|
||||
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
|
||||
import org.eclipse.m2e.core.project.configurator.ProjectConfigurationRequest;
|
||||
import org.teavm.eclipse.TeaVMEclipsePlugin;
|
||||
import org.teavm.eclipse.TeaVMProfile;
|
||||
import org.teavm.eclipse.TeaVMProjectSettings;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alexey Andreev
|
||||
*/
|
||||
public class TeaVMProjectConfigurator extends AbstractProjectConfigurator {
|
||||
private static final String TEAVM_ARTIFACT_ID = "teavm-maven-plugin";
|
||||
private static final String TEAVM_GROUP_ID = "org.teavm";
|
||||
private static final String TEAVM_MAIN_GOAL = "build-javascript";
|
||||
private int executionIdGenerator;
|
||||
private Set<String> usedExecutionIds = new HashSet<>();
|
||||
private IMaven maven;
|
||||
private MavenProject mavenProject;
|
||||
|
||||
@Override
|
||||
public void configure(ProjectConfigurationRequest configurationRequest, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
maven = MavenPlugin.getMaven();
|
||||
mavenProject = configurationRequest.getMavenProject();
|
||||
List<MojoExecution> executions = configurationRequest.getMavenProjectFacade().getMojoExecutions(
|
||||
TEAVM_GROUP_ID, TEAVM_ARTIFACT_ID, monitor, TEAVM_MAIN_GOAL);
|
||||
TeaVMEclipsePlugin teaVMPlugin = TeaVMEclipsePlugin.getDefault();
|
||||
IProject project = configurationRequest.getProject();
|
||||
boolean hasNature = project.hasNature(TeaVMEclipsePlugin.NATURE_ID);
|
||||
int sz = executions.size();
|
||||
if (!hasNature) {
|
||||
++sz;
|
||||
}
|
||||
monitor.beginTask("Configuring TeaVM builder", sz * 1000);
|
||||
TeaVMProjectSettings settings = teaVMPlugin.getSettings(project);
|
||||
settings.load();
|
||||
try {
|
||||
for (MojoExecution execution : executions) {
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
String profileId = getIdForProfile(execution);
|
||||
TeaVMProfile profile = settings.getProfile(profileId);
|
||||
if (profile == null) {
|
||||
profile = settings.createProfile();
|
||||
profile.setName(profileId);
|
||||
}
|
||||
configureProfile(execution, profile, new SubProgressMonitor(monitor, 1000));
|
||||
if (monitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!hasNature) {
|
||||
teaVMPlugin.addNature(new SubProgressMonitor(monitor, 1000), project);
|
||||
}
|
||||
settings.save();
|
||||
} finally {
|
||||
monitor.done();
|
||||
}
|
||||
}
|
||||
|
||||
private void configureProfile(MojoExecution execution, TeaVMProfile profile, IProgressMonitor monitor)
|
||||
throws CoreException {
|
||||
monitor.beginTask("Configuring profile " + profile.getName(), 30);
|
||||
String mainClass = maven.getMojoParameterValue(mavenProject, execution, "mainClass", String.class,
|
||||
new SubProgressMonitor(monitor, 10));
|
||||
profile.setMainClass(mainClass);
|
||||
String targetDir = maven.getMojoParameterValue(mavenProject, execution, "targetDirectory", String.class,
|
||||
new SubProgressMonitor(monitor, 10));
|
||||
profile.setTargetDirectory(targetDir);
|
||||
String targetFileName = maven.getMojoParameterValue(mavenProject, execution, "targetFileName", String.class,
|
||||
new SubProgressMonitor(monitor, 10));
|
||||
profile.setTargetFileName(targetFileName != null ? targetFileName : "classes.js");
|
||||
monitor.done();
|
||||
}
|
||||
|
||||
private String getIdForProfile(MojoExecution pluginExecution) {
|
||||
String executionId = pluginExecution.getExecutionId();
|
||||
if (executionId != null && usedExecutionIds.add(executionId)) {
|
||||
return executionId;
|
||||
}
|
||||
String id;
|
||||
do {
|
||||
id = "maven-" + executionIdGenerator++;
|
||||
} while (!usedExecutionIds.add(id));
|
||||
return id;
|
||||
}
|
||||
}
|
19
teavm-eclipse/teavm-eclipse-m2e-plugin/src/plugin.xml
Normal file
19
teavm-eclipse/teavm-eclipse-m2e-plugin/src/plugin.xml
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2014 Alexey Andreev.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<?eclipse version="3.0"?>
|
||||
<plugin>
|
||||
</plugin>
|
|
@ -59,5 +59,5 @@ Bundle-ClassPath: .,
|
|||
lib/gson-2.2.4.jar,
|
||||
lib/teavm-classlib-0.2-SNAPSHOT.jar,
|
||||
lib/teavm-platform-0.2-SNAPSHOT.jar
|
||||
Export-Package: org.teavm.eclipse.debugger
|
||||
Export-Package: org.teavm.eclipse.debugger,org.teavm.eclipse
|
||||
Bundle-ActivationPolicy: lazy
|
||||
|
|
Loading…
Reference in New Issue
Block a user