[
https://issues.apache.org/jira/browse/MNG-5384?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17408684#comment-17408684
]
Tuomas Kiviaho commented on MNG-5384:
-------------------------------------
bq. Maven 2 had this hack embedded inside of it, but with Maven 3 the project
attachments list doesn't contain test-jar until it is actually added to the
project. I had to patch MBUILDHELPER-41 to be able attach this artifact prior
packaging phase and remove it at prepare-package so that the actual attachment
could be added to the project.
Maven 3.8.2 seems to have finally fixed [Adding serval times the same artifact
via MavenProjectHelper (attachArtifact) keep adding to the List duplicate
artifacts|https://issues.apache.org/jira/browse/MNG-5868] which was apparently
raised due to the same problem that I mentioned above even though my use case
would have been solved by having either the mentioned declarative artifacts or
having capability to detach artifacts.
The fix for my use case clearly still a hack that is needed even without the
detaching part since test-jar would be otherwise missing, but at least for now
everything seems to be working.
[~olamy] The commit
[5f048234ff44dbf70fcad9f17834c64866f452e1|https://git-wip-us.apache.org/repos/asf?p=maven.git;a=commitdiff;h=5f048234ff44dbf70fcad9f17834c64866f452e1]
made the list un-modifiable thus broke my MBUILDHELPER-41 patch in the process
but the benefit of that is that the use case above can now be fixed without the
Mojo patch since I do not have to worry about any duplicates being present at
later phases.
Would the detaching of an attached artifact via a dedicated public method make
any sense now that the direct modification of participating artifacts was made
impossible?
> Declarative artifacts
> ---------------------
>
> Key: MNG-5384
> URL: https://issues.apache.org/jira/browse/MNG-5384
> Project: Maven
> Issue Type: New Feature
> Components: Artifacts and Repositories, POM, Reactor and Workspace
> Affects Versions: 3.0.4
> Reporter: Tuomas Kiviaho
> Priority: Major
> Fix For: Issues to be reviewed for 4.x
>
>
> Currently there's no way to know which attachments a project is going to have
> beforehand. Lack of this feature is currently patched inside Aether where
> test-jar for instance has a special treatment prior packaging phase so that
> we can get a file pointer to ${project.target.testOutputDirectory}.
> Maven 2 had this hack embedded inside of it, but with Maven 3 the project
> attachments list doesn't contain test-jar until it is actually added to the
> project. I had to patch MBUILDHELPER-41 to be able attach this artifact prior
> packaging phase and remove it at prepare-package so that the actual
> attachment could be added to the project.
> I propose that POM could have a section similar to {{build.finalName}} where
> you'd list the attacments that the project is going to introduce. For
> backwards compatibility this of course would not be required. Plugins such as
> jar, sources and javadoc could kick in automatically when pom contains the
> respective declarations (race conditions would arise between
> maven-bundle-plugin and jar for instance).
--
This message was sent by Atlassian Jira
(v8.3.4#803005)