mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Add Maven importer to IDEA
This commit is contained in:
parent
c9355a8eda
commit
a2ebaf7d18
|
@ -7,6 +7,7 @@
|
|||
<property key="Bundle-Description" value="Implementation of metaprogramming API" />
|
||||
<property key="Export-Package" value="org.teavm.metaprogramming.*" />
|
||||
<property key="Bundle-Name" value="TeaVM metaprogramming API implementation" />
|
||||
<property key="Include-Resource" value="META-INF/services/org.teavm.vm.spi.TeaVMPlugin=$MODULE_DIR$/src/main/resources/META-INF/services/org.teavm.vm.spi.TeaVMPlugin" />
|
||||
</additionalProperties>
|
||||
<additionalJARContents />
|
||||
</configuration>
|
||||
|
|
|
@ -222,7 +222,7 @@ public class TeaVMTool implements BaseTeaVMTool {
|
|||
}
|
||||
|
||||
public Collection<String> getClasses() {
|
||||
return vm != null ? vm.getClasses() : Collections.<String>emptyList();
|
||||
return vm != null ? vm.getClasses() : Collections.emptyList();
|
||||
}
|
||||
|
||||
public Collection<String> getUsedResources() {
|
||||
|
@ -361,6 +361,7 @@ public class TeaVMTool implements BaseTeaVMTool {
|
|||
TeaVMProblemRenderer.describeProblems(vm, log);
|
||||
}
|
||||
if (debugInformationGenerated) {
|
||||
assert debugEmitter != null;
|
||||
DebugInformation debugInfo = debugEmitter.getDebugInformation();
|
||||
try (OutputStream debugInfoOut = new FileOutputStream(new File(targetDirectory,
|
||||
targetFileName + ".teavmdbg"))) {
|
||||
|
@ -369,6 +370,7 @@ public class TeaVMTool implements BaseTeaVMTool {
|
|||
log.info("Debug information successfully written");
|
||||
}
|
||||
if (sourceMapsFileGenerated) {
|
||||
assert debugEmitter != null;
|
||||
DebugInformation debugInfo = debugEmitter.getDebugInformation();
|
||||
String sourceMapsFileName = targetFileName + ".map";
|
||||
writer.append("\n//# sourceMappingURL=").append(sourceMapsFileName);
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*
|
||||
* Copyright 2016 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.
|
||||
*/
|
||||
package org.teavm.idea.maven;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.module.ModuleServiceManager;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.idea.maven.importing.MavenImporter;
|
||||
import org.jetbrains.idea.maven.importing.MavenRootModelAdapter;
|
||||
import org.jetbrains.idea.maven.model.MavenPlugin;
|
||||
import org.jetbrains.idea.maven.project.MavenProject;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectChanges;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsProcessorTask;
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsTree;
|
||||
import org.teavm.idea.TeaVMConfigurationStorage;
|
||||
import org.teavm.idea.jps.model.TeaVMJpsConfiguration;
|
||||
|
||||
public class TeaVMMavenImporter extends MavenImporter {
|
||||
private static final Logger logger = Logger.getInstance(TeaVMMavenImporter.class);
|
||||
|
||||
public TeaVMMavenImporter() {
|
||||
super("org.teavm", "teavm-maven-plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preProcess(Module module, MavenProject mavenProject, MavenProjectChanges changes,
|
||||
IdeModifiableModelsProvider modifiableModelsProvider) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(IdeModifiableModelsProvider modifiableModelsProvider, Module module,
|
||||
MavenRootModelAdapter rootModel, MavenProjectsTree mavenModel, MavenProject mavenProject,
|
||||
MavenProjectChanges changes, Map<MavenProject, String> mavenProjectToModuleName,
|
||||
List<MavenProjectsProcessorTask> postTasks) {
|
||||
TeaVMConfigurationStorage configurationStorage = ModuleServiceManager.getService(module,
|
||||
TeaVMConfigurationStorage.class);
|
||||
if (configurationStorage == null) {
|
||||
logger.warn("Could not load component to retrieve TeaVM build configuration");
|
||||
return;
|
||||
}
|
||||
|
||||
TeaVMJpsConfiguration configuration = configurationStorage.getState();
|
||||
|
||||
for (MavenPlugin mavenPlugin : mavenProject.getPlugins()) {
|
||||
if (mavenPlugin.getGroupId().equals(myPluginGroupID)
|
||||
&& mavenPlugin.getArtifactId().equals(myPluginArtifactID)) {
|
||||
updateConfiguration(mavenPlugin, configuration);
|
||||
}
|
||||
}
|
||||
|
||||
configurationStorage.loadState(configuration);
|
||||
}
|
||||
|
||||
private void updateConfiguration(MavenPlugin plugin, TeaVMJpsConfiguration configuration) {
|
||||
if (plugin.getConfigurationElement() != null) {
|
||||
updateConfiguration(plugin.getConfigurationElement(), configuration);
|
||||
}
|
||||
for (MavenPlugin.Execution execution : plugin.getExecutions()) {
|
||||
if (execution.getGoals().contains("compile")) {
|
||||
if (execution.getConfigurationElement() != null) {
|
||||
updateConfiguration(execution.getConfigurationElement(), configuration);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateConfiguration(Element source, TeaVMJpsConfiguration configuration) {
|
||||
configuration.setEnabled(true);
|
||||
for (Element child : source.getChildren()) {
|
||||
switch (child.getName()) {
|
||||
case "sourceFilesCopied":
|
||||
configuration.setSourceFilesCopied(Boolean.parseBoolean(child.getTextTrim()));
|
||||
break;
|
||||
case "sourceMapsGenerated":
|
||||
configuration.setSourceMapsFileGenerated(Boolean.parseBoolean(child.getTextTrim()));
|
||||
break;
|
||||
case "minifying":
|
||||
configuration.setMinifying(Boolean.parseBoolean(child.getTextTrim()));
|
||||
break;
|
||||
case "targetDirectory":
|
||||
configuration.setTargetDirectory(child.getTextTrim());
|
||||
break;
|
||||
case "mainClass":
|
||||
configuration.setMainClass(child.getTextTrim());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,8 @@
|
|||
<version>1.0</version>
|
||||
<vendor email="info@teavm.org" url="http://teavm.org">TeaVM community</vendor>
|
||||
|
||||
<depends>org.jetbrains.idea.maven</depends>
|
||||
|
||||
<description><![CDATA[
|
||||
Enter short description for your plugin here.<br>
|
||||
<em>most HTML tags may be used</em>
|
||||
|
@ -30,4 +32,8 @@
|
|||
<compileServer.plugin classpath="jps/teavm-jps-plugin.jar;teavm-all.jar"/>
|
||||
<buildProcess.parametersProvider implementation="org.teavm.idea.TeaVMJPSConfigurator"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
||||
<importer implementation="org.teavm.idea.maven.TeaVMMavenImporter"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
Loading…
Reference in New Issue
Block a user