String artifactExtension = moduleArtifact.getArtifactHandler().getExtension();
String type = getTypeString(moduleArtifact.getType(), artifactClassifier, artifactExtension);
String artifactName = getArtifactName(artifactId, artifactVersion, artifactClassifier, artifactExtension);
ArtifactBuilder artifactBuilder = new ArtifactBuilder(artifactName).type(type);
File artifactFile = moduleArtifact.getFile();
// for pom projects take the file from the project if the artifact file is null
if (isPomProject(moduleArtifact) && moduleArtifact.equals(project.getArtifact())) {
artifactFile = project.getFile(); // project.getFile() returns the project pom file
}
org.jfrog.build.api.Artifact artifact = artifactBuilder.build();
String groupId = moduleArtifact.getGroupId();
String deploymentPath = getDeploymentPath(groupId, artifactId, artifactVersion, artifactClassifier, artifactExtension);
// If excludeArtifactsFromBuild and the PatternMatcher found conflict, add the excluded artifact to the excluded artifact set.
if (excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath, patterns)) {
module.addExcludedArtifact(artifact);
} else {
module.addArtifact(artifact);
}
if (isPublishArtifacts(artifactFile)) {
addDeployableArtifact(artifact, artifactFile, moduleArtifact.getGroupId(),
artifactId, artifactVersion, artifactClassifier, artifactExtension);
}
/*
* In case of non packaging Pom project module, we need to create the pom file from the ProjectArtifactMetadata on the Artifact
*/
if (!isPomProject(moduleArtifact)) {
for (ArtifactMetadata metadata : moduleArtifact.getMetadataList()) {
if (metadata instanceof ProjectArtifactMetadata) { // the pom metadata
File pomFile = ((ProjectArtifactMetadata) metadata).getFile();
artifactBuilder.type("pom");
String pomFileName = StringUtils.removeEnd(artifactName, artifactExtension) + "pom";
artifactBuilder.name(pomFileName);
org.jfrog.build.api.Artifact pomArtifact = artifactBuilder.build();
deploymentPath = getDeploymentPath(groupId, artifactId, artifactVersion, artifactClassifier, "pom");
if (excludeArtifactsFromBuild && PatternMatcher.pathConflicts(deploymentPath, patterns)) {
module.addExcludedArtifact(pomArtifact);
} else {
module.addArtifact(pomArtifact);