@Nullable
  public static Artifact addArtifact(@NotNull ModifiableArtifactModel artifactModel,
                                     @NotNull ArtifactType type,
                                     @NotNull ArtifactTemplate artifactTemplate) {
    final ArtifactTemplate.NewArtifactConfiguration configuration = artifactTemplate.createArtifact();
    if (configuration == null) {
      return null;
    }

    final String baseName = configuration.getArtifactName();
    String name = generateUniqueArtifactName(baseName, artifactModel);

    ArtifactType actualType = configuration.getArtifactType();
    if (actualType == null) {
      actualType = type;
    }
    final ModifiableArtifact artifact = artifactModel.addArtifact(name, actualType, configuration.getRootElement());
    artifactTemplate.setUpArtifact(artifact, configuration);
    return artifact;
  }
@Nullable
  public static Artifact addArtifact(@NotNull ModifiableArtifactModel artifactModel,
                                     @NotNull ArtifactType type,
                                     @NotNull ArtifactTemplate artifactTemplate)