Ejemplo n.º 1
0
 @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(),
           new Comparator<ArtifactPropertiesState>() {
             @Override
             public int compare(
                 @NotNull ArtifactPropertiesState o1, @NotNull ArtifactPropertiesState o2) {
               return o1.getId().compareTo(o2.getId());
             }
           });
     }
     state.getArtifacts().add(artifactState);
   }
   return state;
 }
Ejemplo n.º 2
0
  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;
  }
Ejemplo n.º 3
0
 private InvalidArtifact createInvalidArtifact(ArtifactState state, String errorMessage) {
   final InvalidArtifact artifact = new InvalidArtifact(state, errorMessage);
   ProjectLoadingErrorsNotifier.getInstance(myProject)
       .registerError(new ArtifactLoadingErrorDescription(myProject, artifact));
   UnknownFeaturesCollector.getInstance(myProject)
       .registerUnknownFeature(
           "com.intellij.packaging.artifacts.ArtifactType", state.getArtifactType());
   return artifact;
 }