public void addArtifact(Artifact artifact, File src) {
throwExceptionIfArtifactOrSrcIsNull(artifact, src);
PublishArtifact publishArtifact = new MavenArtifact(artifact, src);
ArtifactKey artifactKey = new ArtifactKey(publishArtifact);
if (this.artifacts.containsKey(artifactKey)) {
throw new InvalidUserDataException(String.format("A POM cannot have multiple artifacts with the same type and classifier. Already have %s, trying to add %s.",
this.artifacts.get(artifactKey), publishArtifact));
}
if (publishArtifact.getClassifier() != null) {
addArtifact(publishArtifact);
assignArtifactValuesToPom(artifact, pom, false);
return;
}
if (this.artifact != null) {
// Choose the 'main' artifact based on its type.
if (!PACKAGING_TYPES.contains(artifact.getType())) {
addArtifact(publishArtifact);
return;
}
if (PACKAGING_TYPES.contains(this.artifact.getType())) {
throw new InvalidUserDataException("A POM can not have multiple main artifacts. " +
"Already have " + this.artifact + ", trying to add " + publishArtifact);
}
addArtifact(this.artifact);
}