[
https://issues.apache.org/jira/browse/MINSTALL-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17245225#comment-17245225
]
Ben Tatham edited comment on MINSTALL-169 at 12/7/20, 2:01 PM:
---------------------------------------------------------------
I took a stab at fixing this, but it is very complicated (and has separate code
for install and deploy cases).
I found that an easier workaround for a custom lifecycle with a custom plugin
is to set the packaging during a mojo itself, which then tricks the
install/deploy plugins to do the right thing:
For those searching later:
{code:java}
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;
...
project.setPackaging("pom")
...
{code}
Note that you should _not_ also set main artifact (`project.setArtifact`) to
the pom file, because this will cause the install/deploy mojos to
install/deploy the pom twice (which will cause problems on deploy with
non-snapshot versions (depending on your repo manager settings).
was (Author: [email protected]):
I took a stab at fixing this, but it is very complicated (and has separate code
for install and deploy cases).
I found that an easier workaround for a custom lifecycle with a custom plugin
is to set the packaging during a mojo itself, which then tricks the
install/deploy plugins to do the right thing:
For those searching later:
```
@Parameter(defaultValue = "${project}", readonly = true)
private MavenProject project;
...
project.setPackaging("pom")
```
Note that you should _not_ also set main artifact (`project.setArtifact`) to
the pom file, because this will cause the install/deploy mojos to
install/deploy the pom twice (which will cause problems on deploy with
non-snapshot versions (depending on your repo manager settings).
> Handle non-pom packaging with only a pom artifact
> -------------------------------------------------
>
> Key: MINSTALL-169
> URL: https://issues.apache.org/jira/browse/MINSTALL-169
> Project: Maven Install Plugin
> Issue Type: Improvement
> Components: install:install
> Reporter: Ben Tatham
> Priority: Major
>
> Note: this story affects maven-install-plugin and maven-deploy-plugin equally.
> Currently, in
> [DefaultProjectInstaller|https://github.com/apache/maven-artifact-transfer/blob/dfb1e61c4f5db6fe167b3d879a37ab5e25c8475c/src/main/java/org/apache/maven/shared/transfer/project/install/internal/DefaultProjectInstaller.java#L82],
> if a project does not have literally "pom" as packaging, then if there are
> no other artifacts, install:install fails (as does deploy:deploy) with
> {code:java}
> NoFileAssignedException: The packaging plugin for this project did not assign
> a main file to the project but it has attachments. Change packaging to
> 'pom'.{code}
>
> However, for some custom lifecycles (and therefore different packaging
> types), we might want to be able to have a lifecycle that just
> installs/deploys the pom file alone with no additional artifacts.
> Further, if a plugin explicitly sets the main artifact (via
> MavenProject.setArtifact) to the `ProjectArtifact`, aka the pom file itself
> (which I tried as a work around), then install and deploy perform the same
> action twice (which would then break deploy, if the maven central repo blocks
> duplicate pushes, as we have setup in our Nexus environment for release
> (non-snapshot) artifacts)
> Our use case might be weird, but we want to be able to use maven to lookup
> version updates for it, even though the artifacts themselves are not in maven
> (our use case is docker, helm charts, etc).
> I see this as a relatively simple fix in the above mentioned class, and am
> happy to contribute a pull request for it.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)