Skip to content

Commit

Permalink
Issue a warning if unexpected extension override met in deploy-file
Browse files Browse the repository at this point in the history
  • Loading branch information
cstamas committed Aug 14, 2024
1 parent 87ce4fd commit 49da36b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/org/apache/maven/plugins/deploy/DeployFileMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
import org.eclipse.aether.deployment.DeploymentException;
import org.eclipse.aether.repository.RemoteRepository;
import org.eclipse.aether.util.artifact.SubArtifact;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Installs the artifact in the remote repository.
Expand All @@ -63,6 +65,7 @@
*/
@Mojo(name = "deploy-file", requiresProject = false, threadSafe = true)
public class DeployFileMojo extends AbstractDeployMojo {
private final Logger log = LoggerFactory.getLogger(DeployFileMojo.class);
/**
* GroupId of the artifact to be deployed. Retrieved from POM file if specified.
*/
Expand Down Expand Up @@ -205,7 +208,7 @@ void initProperties() throws MojoExecutionException {
JarEntry entry = jarEntries.nextElement();

if (pomEntry.matcher(entry.getName()).matches()) {
getLog().debug("Using " + entry.getName() + " as pomFile");
log.debug("Using " + entry.getName() + " as pomFile");
foundPom = true;
String base = file.getName();
if (base.indexOf('.') > 0) {
Expand All @@ -224,7 +227,7 @@ void initProperties() throws MojoExecutionException {
}

if (!foundPom) {
getLog().info("pom.xml not found in " + file.getName());
log.info("pom.xml not found in " + file.getName());
}
} catch (IOException e) {
// ignore, artifact not packaged by Maven
Expand All @@ -243,7 +246,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (Boolean.parseBoolean(skip)
|| ("releases".equals(skip) && !ArtifactUtils.isSnapshot(version))
|| ("snapshots".equals(skip) && ArtifactUtils.isSnapshot(version))) {
getLog().info("Skipping artifact deployment");
log.info("Skipping artifact deployment");
return;
}

Expand Down Expand Up @@ -289,6 +292,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mainArtifactExtension = packaging;
}
}
if (extension != null && !Objects.equals(extension, mainArtifactExtension)) {
log.warn(
"Main artifact extension should be '{}' but was overridden to '{}'",
mainArtifactExtension,
extension);
}
Artifact mainArtifact = new DefaultArtifact(
groupId, artifactId, classifier, extension != null ? extension : mainArtifactExtension, version)
.setFile(file);
Expand All @@ -306,10 +315,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
deployRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", pomFile));
} else if (generatePom) {
temporaryPom = generatePomFile();
getLog().debug("Deploying generated POM");
log.debug("Deploying generated POM");
deployRequest.addArtifact(new SubArtifact(mainArtifact, "", "pom", temporaryPom));
} else {
getLog().debug("Skipping deploying POM");
log.debug("Skipping deploying POM");
}
}

Expand Down

0 comments on commit 49da36b

Please sign in to comment.