Пример #1
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;
  }
 @NotNull
 private static Artifact findOrCreateWebArtifact(AppEngineFacet appEngineFacet) {
   Module module = appEngineFacet.getModule();
   ArtifactType webArtifactType =
       AppEngineWebIntegration.getInstance().getAppEngineWebArtifactType();
   final Collection<Artifact> artifacts = ArtifactUtil.getArtifactsContainingModuleOutput(module);
   for (Artifact artifact : artifacts) {
     if (webArtifactType.equals(artifact.getArtifactType())) {
       return artifact;
     }
   }
   ArtifactManager artifactManager = ArtifactManager.getInstance(module.getProject());
   PackagingElementFactory elementFactory = PackagingElementFactory.getInstance();
   ArtifactRootElement<?> root = elementFactory.createArtifactRootElement();
   elementFactory
       .getOrCreateDirectory(root, "WEB-INF/classes")
       .addOrFindChild(elementFactory.createModuleOutput(module));
   return artifactManager.addArtifact(module.getName(), webArtifactType, root);
 }