Search in sources :

Example 1 with ArtifactState

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

the class ArtifactManagerImpl method loadState.

@Override
public void loadState(ArtifactManagerState managerState) {
    List<ArtifactState> artifactStates = managerState.getArtifacts();
    final List<ArtifactImpl> artifacts = new ArrayList<>(artifactStates.size());
    if (!artifactStates.isEmpty()) {
        AccessToken token = ReadAction.start();
        try {
            for (ArtifactState state : artifactStates) {
                artifacts.add(loadArtifact(state));
            }
        } finally {
            token.finish();
        }
    }
    if (myLoaded) {
        final ArtifactModelImpl model = new ArtifactModelImpl(this, artifacts);
        doCommit(model);
    } else {
        myModel.setArtifactsList(artifacts);
        myLoaded = true;
    }
}
Also used : ArtifactState(org.jetbrains.jps.model.serialization.artifact.ArtifactState)

Example 2 with ArtifactState

use of org.jetbrains.jps.model.serialization.artifact.ArtifactState 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)

Aggregations

ArtifactState (org.jetbrains.jps.model.serialization.artifact.ArtifactState)2 ArtifactManagerState (org.jetbrains.jps.model.serialization.artifact.ArtifactManagerState)1 ArtifactPropertiesState (org.jetbrains.jps.model.serialization.artifact.ArtifactPropertiesState)1