Search in sources :

Example 16 with JpsElement

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);
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element) JpsLibrary(org.jetbrains.jps.model.library.JpsLibrary) JpsLibraryRoot(org.jetbrains.jps.model.library.JpsLibraryRoot)

Example 17 with JpsElement

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);
}
Also used : JpsElement(org.jetbrains.jps.model.JpsElement) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) Element(org.jdom.Element)

Aggregations

JpsElement (org.jetbrains.jps.model.JpsElement)17 Element (org.jdom.Element)7 JpsModuleSourceRoot (org.jetbrains.jps.model.module.JpsModuleSourceRoot)5 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)4 JavaSourceRootProperties (org.jetbrains.jps.model.java.JavaSourceRootProperties)4 SourceFolder (com.intellij.openapi.roots.SourceFolder)3 File (java.io.File)3 JpsAndroidApplicationArtifactProperties (org.jetbrains.jps.android.model.JpsAndroidApplicationArtifactProperties)3 JpsContentEntry (com.intellij.project.model.impl.module.content.JpsContentEntry)2 JpsSourceFolder (com.intellij.project.model.impl.module.content.JpsSourceFolder)2 AndroidArtifactSigningMode (org.jetbrains.android.compiler.artifact.AndroidArtifactSigningMode)2 NotNull (org.jetbrains.annotations.NotNull)2 JpsAndroidModuleExtension (org.jetbrains.jps.android.model.JpsAndroidModuleExtension)2 JpsArtifact (org.jetbrains.jps.model.artifact.JpsArtifact)2 JpsLibrary (org.jetbrains.jps.model.library.JpsLibrary)2 JpsRootModel (com.intellij.project.model.impl.module.JpsRootModel)1 HashMap (com.intellij.util.containers.HashMap)1 HashSet (com.intellij.util.containers.HashSet)1 THashSet (gnu.trove.THashSet)1 TObjectLongHashMap (gnu.trove.TObjectLongHashMap)1