Re: packaging type generating the current pom

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: packaging type generating the current pom

rfscholte
Hi Olivier,

assuming this bom file is not used by the reactor, it should be possible  
to possible to generate it in the root pom and attach it with its own  
GA[1][2].
The javadoc content says this piece of code is deprecated, probably  
because it introduces some magic where it is hard to determine where the  
file is coming from. I think we should be able to allow this and in case  
of pom.xml let Maven add some XML comment saying it was provided as part  
of project GA(V)

Is this less hackish?

Robert


[1]  
https://maven.apache.org/ref/3.5.0/maven-core/apidocs/org/apache/maven/project/MavenProject.html#addAttachedArtifact(org.apache.maven.artifact.Artifact)

[2]  
https://maven.apache.org/ref/3.5.0/maven-core/apidocs/org/apache/maven/project/DefaultMavenProjectHelper.html#attachArtifact(org.apache.maven.project.MavenProject,%20org.apache.maven.artifact.Artifact)


On Fri, 09 Jun 2017 08:35:11 +0200, Olivier Lamy <[hidden email]> wrote:

> Hi,
> Not sure how to do that in a non hackhish way.
> My current goal: generate a bom style pom with all reactor projects in
> dptMngt section.
> As people are lazy to write dptMngt section in theirs poms they delegate  
> to
> others with this pom.
> So as I'm lazy too I don't want to write/maintain this pom neither so I
> prefer using a plugin for that :-)
> So I create a new packaging type bom and enable it on a pom.
> The plugin simply generate a pom.xml file with all content and the
> calculated dptMngt section.
> The only way I found to replace the current pom is to use:  
> project.setFile(
> the new pom file)
>
> Any other way?
>
> Cheers

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: packaging type generating the current pom

olamy
Hi Robert
Sorry for late reply.
Well this doesn't work (see source here [1]) you can attach an artifact
with his own GAV.
And it's neither possible to change GAV of an attached artifact.

Caused by: java.lang.UnsupportedOperationException: Cannot change the
groupId for an attached artifact. It is derived from the main artifact.at
org.apache.maven.project.artifact.AttachedArtifact.setGroupId(AttachedArtifact.java:110)

So at this stage the only solution I have is to attach an artifact with a
new classifier "bom"....

Cheers
Olivier

[1]
https://github.com/apache/maven/blob/eb6b212b567c287734a2dbbef3c113fe650f1def/maven-core/src/main/java/org/apache/maven/project/DefaultMavenProjectHelper.java#L101



On 9 June 2017 at 19:56, Robert Scholte <[hidden email]> wrote:

> Hi Olivier,
>
> assuming this bom file is not used by the reactor, it should be possible
> to possible to generate it in the root pom and attach it with its own
> GA[1][2].
> The javadoc content says this piece of code is deprecated, probably
> because it introduces some magic where it is hard to determine where the
> file is coming from. I think we should be able to allow this and in case of
> pom.xml let Maven add some XML comment saying it was provided as part of
> project GA(V)
>
> Is this less hackish?
>
> Robert
>
>
> [1] https://maven.apache.org/ref/3.5.0/maven-core/apidocs/org/ap
> ache/maven/project/MavenProject.html#addAttachedArtifact(
> org.apache.maven.artifact.Artifact)
>
> [2] https://maven.apache.org/ref/3.5.0/maven-core/apidocs/org/ap
> ache/maven/project/DefaultMavenProjectHelper.html#
> attachArtifact(org.apache.maven.project.MavenProject,%
> 20org.apache.maven.artifact.Artifact)
>
>
> On Fri, 09 Jun 2017 08:35:11 +0200, Olivier Lamy <[hidden email]> wrote:
>
> Hi,
>> Not sure how to do that in a non hackhish way.
>> My current goal: generate a bom style pom with all reactor projects in
>> dptMngt section.
>> As people are lazy to write dptMngt section in theirs poms they delegate
>> to
>> others with this pom.
>> So as I'm lazy too I don't want to write/maintain this pom neither so I
>> prefer using a plugin for that :-)
>> So I create a new packaging type bom and enable it on a pom.
>> The plugin simply generate a pom.xml file with all content and the
>> calculated dptMngt section.
>> The only way I found to replace the current pom is to use:
>> project.setFile(
>> the new pom file)
>>
>> Any other way?
>>
>> Cheers
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Olivier Lamy
http://twitter.com/olamy | http://linkedin.com/in/olamy
Loading...