Search in sources :

Example 1 with ArtifactPropertiesState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState in project intellij-community by JetBrains.

the class ArtifactManagerImpl method serializeProperties.

@Nullable
private static <S> ArtifactPropertiesState serializeProperties(ArtifactPropertiesProvider provider, ArtifactProperties<S> properties) {
    final ArtifactPropertiesState state = new ArtifactPropertiesState();
    state.setId(provider.getId());
    final Element options = new Element("options");
    XmlSerializer.serializeInto(properties.getState(), options, new SkipDefaultValuesSerializationFilters());
    if (options.getContent().isEmpty() && options.getAttributes().isEmpty())
        return null;
    state.setOptions(options);
    return state;
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState) SkipDefaultValuesSerializationFilters(com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters) Element(org.jdom.Element) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ArtifactPropertiesState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState in project android by JetBrains.

the class JpsAndroidApplicationArtifactPropertiesSerializer method doLoadProperties.

private static JpsAndroidApplicationArtifactProperties doLoadProperties(List<ArtifactPropertiesState> stateList) {
    final ArtifactPropertiesState state = findAndroidApplicationProperties(stateList);
    if (state == null) {
        return null;
    }
    final Element options = state.getOptions();
    if (options == null) {
        return null;
    }
    return XmlSerializer.deserialize(options, JpsAndroidApplicationArtifactPropertiesImpl.class);
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState) Element(org.jdom.Element)

Example 3 with ArtifactPropertiesState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState in project intellij-community by JetBrains.

the class ArtifactManagerImpl method loadArtifact.

private ArtifactImpl loadArtifact(ArtifactState state) {
    ArtifactType type = ArtifactType.findById(state.getArtifactType());
    if (type == null) {
        return createInvalidArtifact(state, "Unknown artifact type: " + state.getArtifactType());
    }
    final Element element = state.getRootElement();
    final String artifactName = state.getName();
    final CompositePackagingElement<?> rootElement;
    if (element != null) {
        try {
            rootElement = (CompositePackagingElement<?>) deserializeElement(element);
        } catch (UnknownPackagingElementTypeException e) {
            return createInvalidArtifact(state, "Unknown element: " + e.getTypeId());
        }
    } else {
        rootElement = type.createRootElement(artifactName);
    }
    final ArtifactImpl artifact = new ArtifactImpl(artifactName, type, state.isBuildOnMake(), rootElement, state.getOutputPath());
    final List<ArtifactPropertiesState> propertiesList = state.getPropertiesList();
    for (ArtifactPropertiesState propertiesState : propertiesList) {
        final ArtifactPropertiesProvider provider = ArtifactPropertiesProvider.findById(propertiesState.getId());
        if (provider != null) {
            deserializeProperties(artifact.getProperties(provider), propertiesState);
        } else {
            return createInvalidArtifact(state, "Unknown artifact properties: " + propertiesState.getId());
        }
    }
    return artifact;
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState) Element(org.jdom.Element)

Example 4 with ArtifactPropertiesState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState in project intellij-community by JetBrains.

the class ArtifactManagerImpl method getState.

@Override
public ArtifactManagerState getState() {
    final ArtifactManagerState state = new ArtifactManagerState();
    for (Artifact artifact : getAllArtifactsIncludingInvalid()) {
        final ArtifactState artifactState;
        if (artifact instanceof InvalidArtifact) {
            artifactState = ((InvalidArtifact) artifact).getState();
        } else {
            artifactState = new ArtifactState();
            artifactState.setBuildOnMake(artifact.isBuildOnMake());
            artifactState.setName(artifact.getName());
            artifactState.setOutputPath(artifact.getOutputPath());
            artifactState.setRootElement(serializePackagingElement(artifact.getRootElement()));
            artifactState.setArtifactType(artifact.getArtifactType().getId());
            for (ArtifactPropertiesProvider provider : artifact.getPropertiesProviders()) {
                final ArtifactPropertiesState propertiesState = serializeProperties(provider, artifact.getProperties(provider));
                if (propertiesState != null) {
                    artifactState.getPropertiesList().add(propertiesState);
                }
            }
            Collections.sort(artifactState.getPropertiesList(), Comparator.comparing(ArtifactPropertiesState::getId));
        }
        state.getArtifacts().add(artifactState);
    }
    return state;
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState) ArtifactManagerState(org.jetbrains.jps.model.serialization.artifact.ArtifactManagerState) ArtifactState(org.jetbrains.jps.model.serialization.artifact.ArtifactState)

Example 5 with ArtifactPropertiesState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState in project android by JetBrains.

the class JpsAndroidApplicationArtifactPropertiesSerializer method saveProperties.

@Override
public void saveProperties(JpsAndroidApplicationArtifactProperties properties, List<ArtifactPropertiesState> stateList) {
    final ArtifactPropertiesState state = findAndroidApplicationProperties(stateList);
    if (state == null) {
        return;
    }
    state.setOptions(XmlSerializer.serialize(properties));
}
Also used : ArtifactPropertiesState(org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState)

Aggregations

ArtifactPropertiesState (org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState)9 Element (org.jdom.Element)5 SkipDefaultValuesSerializationFilters (com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters)1 Nullable (org.jetbrains.annotations.Nullable)1 ArtifactManagerState (org.jetbrains.jps.model.serialization.artifact.ArtifactManagerState)1 ArtifactState (org.jetbrains.jps.model.serialization.artifact.ArtifactState)1