use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class JpsSdkTableSerializer method saveSdk.
private static <P extends JpsElement> void saveSdk(final JpsSdk<P> sdk, Element sdkTag) {
JpsLibrary library = sdk.getParent();
sdkTag.setAttribute("version", "2");
setAttributeValue(sdkTag, NAME_TAG, library.getName());
JpsSdkPropertiesSerializer<P> serializer = getSdkPropertiesSerializer(sdk.getSdkType());
setAttributeValue(sdkTag, TYPE_TAG, serializer.getTypeId());
String versionString = sdk.getVersionString();
if (versionString != null) {
setAttributeValue(sdkTag, VERSION_TAG, versionString);
}
setAttributeValue(sdkTag, HOME_PATH_TAG, sdk.getHomePath());
Element rootsTag = new Element(ROOTS_TAG);
for (JpsLibraryRootTypeSerializer rootTypeSerializer : getRootTypeSerializers()) {
Element rootTypeTag = new Element(rootTypeSerializer.getTypeId());
Element compositeTag = new Element(ROOT_TAG);
compositeTag.setAttribute(TYPE_ATTRIBUTE, COMPOSITE_TYPE);
List<JpsLibraryRoot> roots = library.getRoots(rootTypeSerializer.getType());
for (JpsLibraryRoot root : roots) {
compositeTag.addContent(new Element(ROOT_TAG).setAttribute(TYPE_ATTRIBUTE, SIMPLE_TYPE).setAttribute(URL_ATTRIBUTE, root.getUrl()));
}
rootTypeTag.addContent(compositeTag);
rootsTag.addContent(rootTypeTag);
}
sdkTag.addContent(rootsTag);
Element additionalTag = new Element(ADDITIONAL_TAG);
serializer.saveProperties(sdk.getSdkProperties(), additionalTag);
sdkTag.addContent(additionalTag);
}
use of org.jetbrains.jps.model.JpsElement in project intellij-community by JetBrains.
the class JpsSdkTableSerializer method createSdk.
private static <P extends JpsElement> JpsLibrary createSdk(String name, JpsSdkPropertiesSerializer<P> loader, Element sdkElement) {
String versionString = getAttributeValue(sdkElement, VERSION_TAG);
String homePath = getAttributeValue(sdkElement, HOME_PATH_TAG);
Element propertiesTag = sdkElement.getChild(ADDITIONAL_TAG);
P properties = loader.loadProperties(propertiesTag);
return JpsElementFactory.getInstance().createSdk(name, homePath, versionString, loader.getType(), properties);
}
Aggregations