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;
}
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);
}
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;
}
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;
}
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));
}
Aggregations