Save target type in Kotlin Builder
This commit is contained in:
@@ -10,5 +10,6 @@
|
||||
<orderEntry type="library" scope="PROVIDED" name="intellij-core" level="project" />
|
||||
<orderEntry type="library" name="kotlin-runtime" level="project" />
|
||||
<orderEntry type="library" exported="" name="cli-parser" level="project" />
|
||||
<orderEntry type="library" name="jps" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.cli.common.modules
|
||||
public interface Module {
|
||||
public fun getModuleName(): String
|
||||
|
||||
public fun getModuleType(): String
|
||||
|
||||
public fun getOutputDirectory(): String
|
||||
|
||||
public fun getSourceFiles(): List<String>
|
||||
|
||||
+6
-1
@@ -18,7 +18,11 @@ package org.jetbrains.kotlin.cli.common.modules
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public class ModuleBuilder(private val name: String, private val outputDir: String) : Module {
|
||||
public class ModuleBuilder(
|
||||
private val name: String,
|
||||
private val outputDir: String,
|
||||
private val type: String
|
||||
) : Module {
|
||||
private val sourceFiles = ArrayList<String>()
|
||||
private val classpathRoots = ArrayList<String>()
|
||||
private val javaSourceRoots = ArrayList<String>()
|
||||
@@ -46,5 +50,6 @@ public class ModuleBuilder(private val name: String, private val outputDir: Stri
|
||||
override fun getClasspathRoots(): List<String> = classpathRoots
|
||||
override fun getAnnotationsRoots(): List<String> = annotationsRoots
|
||||
override fun getModuleName(): String = name
|
||||
override fun getModuleType(): String = type
|
||||
}
|
||||
|
||||
|
||||
+17
-3
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.cli.common.modules;
|
||||
import com.intellij.openapi.util.io.StreamUtil;
|
||||
import com.intellij.util.SmartList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jps.builders.java.JavaModuleBuildTargetType;
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollectorUtil;
|
||||
import org.jetbrains.kotlin.cli.common.messages.OutputMessageUtil;
|
||||
@@ -40,6 +41,7 @@ public class ModuleXmlParser {
|
||||
public static final String MODULES = "modules";
|
||||
public static final String MODULE = "module";
|
||||
public static final String NAME = "name";
|
||||
public static final String TYPE = "type";
|
||||
public static final String OUTPUT_DIR = "outputDir";
|
||||
public static final String SOURCES = "sources";
|
||||
public static final String JAVA_SOURCE_ROOTS = "javaSourceRoots";
|
||||
@@ -126,10 +128,22 @@ public class ModuleXmlParser {
|
||||
|
||||
setCurrentState(new InsideModule(
|
||||
getAttribute(attributes, NAME, qName),
|
||||
getAttribute(attributes, OUTPUT_DIR, qName)
|
||||
getAttribute(attributes, OUTPUT_DIR, qName),
|
||||
getType(attributes, qName)
|
||||
));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getType(@NotNull Attributes attributes, @NotNull String tag) {
|
||||
String value = attributes.getValue(TYPE);
|
||||
|
||||
assert value != null &&
|
||||
(JavaModuleBuildTargetType.PRODUCTION.getTypeId().equals(value) ||
|
||||
JavaModuleBuildTargetType.TEST.getTypeId().equals(value)): "Unknown value of module type: " + value;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElement(String uri, @NotNull String localName, @NotNull String qName) throws SAXException {
|
||||
if (MODULE.equalsIgnoreCase(qName) || MODULES.equalsIgnoreCase(qName)) {
|
||||
@@ -141,8 +155,8 @@ public class ModuleXmlParser {
|
||||
private class InsideModule extends DefaultHandler {
|
||||
|
||||
private final ModuleBuilder moduleBuilder;
|
||||
private InsideModule(String name, String outputDir) {
|
||||
this.moduleBuilder = new ModuleBuilder(name, outputDir);
|
||||
private InsideModule(String name, String outputDir, @NotNull String type) {
|
||||
this.moduleBuilder = new ModuleBuilder(name, outputDir, type);
|
||||
modules.add(moduleBuilder);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user