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

Closed
wants to merge 1 commit into 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.

Copy link

@EnigmaTriton EnigmaTriton Jun 13, 2024

Choose a reason for hiding this comment

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

According to the documentation, packaging designate the “Type of the artifact to be deployed. Retrieved from the element of the POM file if a POM file specified. Defaults to the file extension if it is not specified via command line or POM.”

The way I read it, it means that the packaging tag takes precedence (whether from command line or from the POM), followed by the extension of the file to upload as a fallback.

I just hit this issue (MDEPLOY-311) because we generate a zip file using the truezip plugin (that relies on the extension) and then we need to deploy using a different extension.
The .epub ebooks (used for documentation) are really .zip files with a specific content but this is true for quite a lot of other formats as well so there really is a use-case for using <packaging> with a different extension than the one on the deployed file.

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?

@cstamas
Copy link
Member

cstamas commented Aug 14, 2024

Superded by #71

@cstamas cstamas closed this Aug 14, 2024
cstamas added a commit that referenced this pull request Aug 15, 2024
The packaging was not really considered. Borrow UT from PR #42, thanks!

Changes:
* honor packaging to calculate classifier (optionally) and extension
* add param "extension" to override Maven calculated extension explicitly
* switch to SLF4J logging

---

https://issues.apache.org/jira/browse/MDEPLOY-311
@sratz
Copy link
Author

sratz commented Aug 15, 2024

Awesome, thanks!

@sratz sratz deleted the packaging branch August 15, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants