use of org.jetbrains.jps.model.serialization.impl.JpsModuleSerializationDataExtensionImpl in project android by JetBrains.
the class AndroidBuilderTest method addAndroidModule.
private Pair<JpsModule, Path> addAndroidModule(String moduleName, String[] sourceRoots, String contentRootDir, String dstContentRootDir, JpsSdk<? extends JpsElement> androidSdk, String testDirName) {
final String testDataRoot = getTestDataDirForCurrentTest(testDirName);
final String projectRoot = testDataRoot + "/project";
final String moduleContentRoot = contentRootDir != null ? new File(projectRoot, contentRootDir).getPath() : projectRoot;
final String dstRoot = dstContentRootDir != null ? "root/" + dstContentRootDir : "root";
final String root = copyToProject(moduleContentRoot, dstRoot);
final String outputPath = getAbsolutePath("out/production/" + moduleName);
final String testOutputPath = getAbsolutePath("out/test/" + moduleName);
final JpsModule module = addModule(moduleName, ArrayUtil.EMPTY_STRING_ARRAY, outputPath, testOutputPath, androidSdk);
module.getContentRootsList().addUrl(JpsPathUtil.pathToUrl(root));
for (String sourceRoot : sourceRoots) {
final String sourceRootName = new File(sourceRoot).getName();
final String copiedSourceRoot = copyToProject(moduleContentRoot + "/" + sourceRoot, dstRoot + "/" + sourceRootName);
module.addSourceRoot(JpsPathUtil.pathToUrl(copiedSourceRoot), JavaSourceRootType.SOURCE);
}
final JpsAndroidModuleProperties properties = new JpsAndroidModuleProperties();
properties.MANIFEST_FILE_RELATIVE_PATH = "/AndroidManifest.xml";
properties.RES_FOLDER_RELATIVE_PATH = "/res";
properties.ASSETS_FOLDER_RELATIVE_PATH = "/assets";
properties.LIBS_FOLDER_RELATIVE_PATH = "/libs";
properties.GEN_FOLDER_RELATIVE_PATH_APT = "/gen";
properties.GEN_FOLDER_RELATIVE_PATH_AIDL = "/gen";
properties.PACK_TEST_CODE = false;
module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE, new JpsModuleSerializationDataExtensionImpl(Paths.get(root)));
module.getContainer().setChild(JpsAndroidModuleExtensionImpl.KIND, new JpsAndroidModuleExtensionImpl(properties));
return Pair.create(module, Paths.get(root));
}
use of org.jetbrains.jps.model.serialization.impl.JpsModuleSerializationDataExtensionImpl in project intellij-community by JetBrains.
the class JpsProjectLoader method loadModule.
@Nullable
private static JpsModule loadModule(@NotNull File file, @NotNull Element moduleRoot, List<String> paths, @Nullable JpsSdkType<?> projectSdkType, Map<String, String> pathVariables) {
String name = FileUtil.getNameWithoutExtension(file);
final String typeId = moduleRoot.getAttributeValue("type");
final JpsModulePropertiesSerializer<?> serializer = getModulePropertiesSerializer(typeId);
final JpsModule module = createModule(name, moduleRoot, serializer);
module.getContainer().setChild(JpsModuleSerializationDataExtensionImpl.ROLE, new JpsModuleSerializationDataExtensionImpl(file.getParentFile()));
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
extension.loadModuleOptions(module, moduleRoot);
}
String baseModulePath = FileUtil.toSystemIndependentName(file.getParent());
String classpath = moduleRoot.getAttributeValue(CLASSPATH_ATTRIBUTE);
if (classpath == null) {
JpsModuleRootModelSerializer.loadRootModel(module, JDomSerializationUtil.findComponent(moduleRoot, "NewModuleRootManager"), projectSdkType);
} else {
for (JpsModelSerializerExtension extension : JpsModelSerializerExtension.getExtensions()) {
JpsModuleClasspathSerializer classpathSerializer = extension.getClasspathSerializer();
if (classpathSerializer != null && classpathSerializer.getClasspathId().equals(classpath)) {
String classpathDir = moduleRoot.getAttributeValue(CLASSPATH_DIR_ATTRIBUTE);
final JpsMacroExpander expander = createModuleMacroExpander(pathVariables, file);
classpathSerializer.loadClasspath(module, classpathDir, baseModulePath, expander, paths, projectSdkType);
}
}
}
JpsFacetSerializer.loadFacets(module, JDomSerializationUtil.findComponent(moduleRoot, "FacetManager"));
return module;
}
Aggregations