mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
new project model: javaee facets added
This commit is contained in:
@@ -2,6 +2,7 @@ package org.jetbrains.jps.model.module;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.model.JpsElementProperties;
|
||||
import org.jetbrains.jps.model.JpsNamedElement;
|
||||
import org.jetbrains.jps.model.JpsReferenceableElement;
|
||||
|
||||
@@ -17,6 +18,9 @@ public interface JpsFacet extends JpsNamedElement, JpsReferenceableElement<JpsFa
|
||||
@NotNull
|
||||
JpsFacetType<?> getType();
|
||||
|
||||
@Nullable
|
||||
<P extends JpsElementProperties> P getProperties(@NotNull JpsFacetType<P> type);
|
||||
|
||||
void delete();
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -43,6 +43,11 @@ public class JpsFacetImpl extends JpsNamedCompositeElementBase<JpsFacetImpl> imp
|
||||
return myContainer.getChild(TYPED_DATA_KIND).getType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <P extends JpsElementProperties> P getProperties(@NotNull JpsFacetType<P> type) {
|
||||
return myContainer.getChild(TYPED_DATA_KIND).getProperties(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParentFacet(@NotNull JpsFacet facet) {
|
||||
myContainer.setChild(PARENT_FACET_REFERENCE, facet.createReference());
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ import java.util.List;
|
||||
*/
|
||||
public class JpsGlobalSerializationTest extends JpsSerializationTestCase {
|
||||
public void testLoadSdks() throws IOException {
|
||||
JpsGlobalLoader.loadGlobalSettings(myModel.getGlobal(), getTestDataPath("config/options"));
|
||||
JpsGlobalLoader.loadGlobalSettings(myModel.getGlobal(), getTestDataFileAbsolutePath("jps/model-serialization/testData/config/options"));
|
||||
final List<JpsLibrary> libraries = myModel.getGlobal().getLibraryCollection().getLibraries();
|
||||
assertEquals(3, libraries.size());
|
||||
assertEquals("Gant", libraries.get(0).getName());
|
||||
|
||||
+10
-12
@@ -1,11 +1,11 @@
|
||||
package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import org.jetbrains.jps.model.JpsProject;
|
||||
import org.jetbrains.jps.model.java.JpsJavaSdkType;
|
||||
import org.jetbrains.jps.model.library.JpsLibrary;
|
||||
import org.jetbrains.jps.model.module.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ import java.util.List;
|
||||
*/
|
||||
public class JpsModuleSerializationTest extends JpsSerializationTestCase {
|
||||
public void test() {
|
||||
loadProject("iprProject/iprProject.ipr");
|
||||
loadProject("/jps/model-serialization/testData/iprProject/iprProject.ipr");
|
||||
final JpsModule module = assertOneElement(myModel.getProject().getModules());
|
||||
assertEquals("iprProject", module.getName());
|
||||
|
||||
@@ -28,14 +28,12 @@ public class JpsModuleSerializationTest extends JpsSerializationTestCase {
|
||||
assertInstanceOf(dependencies.get(2), JpsLibraryDependency.class);
|
||||
assertInstanceOf(dependencies.get(3), JpsLibraryDependency.class);
|
||||
}
|
||||
|
||||
private void loadProject(final String path) {
|
||||
try {
|
||||
final String projectPath = getTestDataPath(path);
|
||||
JpsProjectLoader.loadProject(myModel.getProject(), Collections.<String, String>emptyMap(), projectPath);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public void _testLoadIdeaProject() {
|
||||
long start = System.currentTimeMillis();
|
||||
final JpsProject project = myModel.getProject();
|
||||
loadProject(PathManager.getHomePath());
|
||||
assertTrue(project.getModules().size() > 0);
|
||||
System.out.println("Time: " + (System.currentTimeMillis() - start));
|
||||
}
|
||||
}
|
||||
|
||||
+34
-6
@@ -2,20 +2,48 @@ package org.jetbrains.jps.model.serialization;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.vfs.VfsUtilCore;
|
||||
import com.intellij.util.PathUtil;
|
||||
import org.jetbrains.jps.model.JpsModelTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class JpsSerializationTestCase extends JpsModelTestCase {
|
||||
protected static String getTestDataPath(String relativePath) {
|
||||
File baseDir = new File(PathManager.getHomePath());
|
||||
final File communityDir = new File(baseDir, "community");
|
||||
if (communityDir.exists()) {
|
||||
baseDir = communityDir;
|
||||
private String myProjectHomePath;
|
||||
|
||||
protected void loadProject(final String relativePath) {
|
||||
final String path = getTestDataFileAbsolutePath(relativePath);
|
||||
|
||||
myProjectHomePath = FileUtilRt.toSystemIndependentName(path);
|
||||
if (myProjectHomePath.endsWith(".ipr")) {
|
||||
myProjectHomePath = PathUtil.getParentPath(myProjectHomePath);
|
||||
}
|
||||
return FileUtilRt.toSystemIndependentName(baseDir.getAbsolutePath()) + "/jps/model-serialization/testData/" + relativePath;
|
||||
try {
|
||||
JpsProjectLoader.loadProject(myModel.getProject(), Collections.<String, String>emptyMap(), path);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getUrl(String relativePath) {
|
||||
return VfsUtilCore.pathToUrl(myProjectHomePath + "/" + relativePath);
|
||||
}
|
||||
|
||||
protected static String getTestDataFileAbsolutePath(String relativePath) {
|
||||
File baseDir = new File(PathManager.getHomePath());
|
||||
File file = new File(baseDir, FileUtilRt.toSystemDependentName(relativePath));
|
||||
if (!file.exists()) {
|
||||
final File communityDir = new File(baseDir, "community");
|
||||
if (communityDir.exists()) {
|
||||
file = new File(communityDir, FileUtilRt.toSystemDependentName(relativePath));
|
||||
}
|
||||
}
|
||||
return FileUtilRt.toSystemDependentName(file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user