Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MDEPLOY-311] Pass on 'packaging' when creating artifact to upload #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sratz
Copy link

@sratz sratz commented Jul 3, 2023

Fixes a regression introduced in
16541da [MDEPLOY-296] which caused the -Dpackaging property to be ignored when uploading the artifact. Instead, the packaging type during upload was always derived from the file name.


Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MDEPLOY-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MDEPLOY-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@sratz
Copy link
Author

sratz commented Aug 30, 2023

Ping - any feedback on this PR / issue?

@slawekjaranowski
Copy link
Member

your assumptions is wrong,
generally packaging may be different then deployed file extension, eg
packaging ejb has extension jar

@@ -276,6 +276,45 @@ public void testDeployIfArtifactIsNotJar() throws Exception {
assertTrue(file.exists());
}

public void testDeployFileIfPackagingIsSet() throws Exception {
File testPom = new File(getBasedir(), "target/test-classes/unit/deploy-file-packaging/plugin-config.xml");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is missing in PR

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

Artifact mainArtifact = new DefaultArtifact(
groupId, artifactId, classifier, isFilePom ? "pom" : getExtension(file), version)
.setFile(file);
Artifact mainArtifact = new DefaultArtifact(groupId, artifactId, classifier, packaging, version).setFile(file);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of getExtension(file) we can use artifactType.getExtension() as improvements

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at java doc: https://maven.apache.org/resolver/apidocs/org/eclipse/aether/artifact/DefaultArtifact.html#%3Cinit%3E(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)

fourth parameter is a file extension not packaging

But for some reason, before 16541da, packaging was used as the file extension. Are you saying that was never intended and was a bug?

If so, is there any way to get the old behavior back in maven-deploy-plugin 3.0?

artifactType.getExtension() won't solve the problem, as this is only working known packagings. It does not cover the case -Dpackaging=completelarbitrary where no artifactType is known.

I have uploaded an alternative proposal: If we have an artifactType use its extension, otherwise fall back to packaging for unknown types.

Fixes a regression introduced in
16541da [MDEPLOY-296]
which caused the -Dpackaging property to be ignored when uploading the
artifact. Instead, the packaging type during upload was always derived
from the file name.
@cstamas
Copy link
Member

cstamas commented Oct 23, 2023

Something is fishy about this PR, but I think I understand the intent.... is the generated POM/packaging wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants