Enforcer requirePropertyDiverges not propagated to descendants?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Enforcer requirePropertyDiverges not propagated to descendants?

Mark Raynsford
Hello.

I'm trying to use the Enforcer plugin to ensure that projects set a
${project.description} that is different to their parent. I'm using
an organization-wide POM, and the rule is specified here:

  https://github.com/io7m/primogenitor/blob/develop/pom.xml#L540

I have an example multi-module project that uses that root POM here:

  https://github.com/io7m/primogenitor-example-20170304

If I fail to set a description in the "root" POM of that project
(in other words, if I remove
https://github.com/io7m/primogenitor-example-20170304/blob/master/pom.xml#L20),
the Enforcer rule fails the build correctly. However, if I leave
that description intact but then fail to set a different
(or indeed any) description in the mod-a POM
(https://github.com/io7m/primogenitor-example-20170304/blob/master/mod-a/pom.xml),
the Enforcer plugin doesn't catch it. I would expect the linked example
project to fail to build, but it doesn't!

Am I doing something wrong? I thought the purpose of the
requirePropertyDiverges rule was to check the current project against
its immediate parent. If this is correct, then something appears to be
wrong with the plugin...

M

attachment0 (871 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Enforcer requirePropertyDiverges not propagated to descendants?

Hervé BOUTEMY
first, you'll have to talk about rules, not only the plugin: there are many
rules, some implemented by the plugin and some implemented by MojoHaus extra-
enforcer-rules

then: MojoHaus requirePropertyDiverges [1] requires that the property value is
different, not that it is not empty

IIUC what you're trying to do, you'll need both Maven requireProperty [2] and
MojoHaus requirePropertyDiverge [1]

Regards,

Hervé

[1] http://www.mojohaus.org/extra-enforcer-rules/requirePropertyDiverges.html

[2] http://maven.apache.org/enforcer/enforcer-rules/requireProperty.html

Le samedi 4 mars 2017, 21:00:03 CET [hidden email] a écrit :

> Hello.
>
> I'm trying to use the Enforcer plugin to ensure that projects set a
> ${project.description} that is different to their parent. I'm using
> an organization-wide POM, and the rule is specified here:
>
>   https://github.com/io7m/primogenitor/blob/develop/pom.xml#L540
>
> I have an example multi-module project that uses that root POM here:
>
>   https://github.com/io7m/primogenitor-example-20170304
>
> If I fail to set a description in the "root" POM of that project
> (in other words, if I remove
> https://github.com/io7m/primogenitor-example-20170304/blob/master/pom.xml#L2
> 0), the Enforcer rule fails the build correctly. However, if I leave
> that description intact but then fail to set a different
> (or indeed any) description in the mod-a POM
> (https://github.com/io7m/primogenitor-example-20170304/blob/master/mod-a/pom
> .xml), the Enforcer plugin doesn't catch it. I would expect the linked
> example project to fail to build, but it doesn't!
>
> Am I doing something wrong? I thought the purpose of the
> requirePropertyDiverges rule was to check the current project against
> its immediate parent. If this is correct, then something appears to be
> wrong with the plugin...
>
> M



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

Reply | Threaded
Open this post in threaded view
|

Re: Enforcer requirePropertyDiverges not propagated to descendants?

Mark Raynsford
Hello.

On 2017-03-05T01:18:34 +0100
Hervé BOUTEMY <[hidden email]> wrote:

> first, you'll have to talk about rules, not only the plugin: there are many
> rules, some implemented by the plugin and some implemented by MojoHaus extra-
> enforcer-rules

Right, yes. It's the requirePropertyDiverges rule in the
extra-enforcer-rules package in this case.

>
> then: MojoHaus requirePropertyDiverges [1] requires that the property value is
> different, not that it is not empty
>
> IIUC what you're trying to do, you'll need both Maven requireProperty [2] and
> MojoHaus requirePropertyDiverge [1]

That seems wrong, somehow, and it doesn't match the behaviour that I
posted. If I don't define a property, then the property (if any) will
be inherited from an ancestor project, yes? The problem I'm having is
that the requirePropertyDiverges rule seems to stop working after one
level of inheritance. See these three example cases:

0. Project A defines a property P. Project B inherits from
   A and doesn't redefine or declare P. The requirePropertyDiverges rule
   correctly rejects this case and the build fails.

   https://github.com/io7m/requirePropertyDiverges-20170305/tree/master/case-0

   ^^ Building this project should fail, and it does.

1. Project A defines a property P. Project B inherits from A and
   redefines P with a different value. The requirePropertyDiverges rule
   correctly accepts this case and the build succeeds.

   https://github.com/io7m/requirePropertyDiverges-20170305/tree/master/case-1

   ^^ Building this project should succeed, and it does.

2. Project A defines a property P. Project B inherits from A and
   redefines P with a different value. Project C inherits from B
   and doesn't redefine or declare P. This case *should* fail,
   because in C, P is inherited from B and therefore has not diverged.

   https://github.com/io7m/requirePropertyDiverges-20170305/tree/master/case-2

   ^^ Building this project should fail, but it doesn't.

M

attachment0 (871 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Enforcer requirePropertyDiverges not propagated to descendants?

Curtis Rueden
Hi,

For what it's worth, I agree that the requirePropertyDiverges rule is
difficult to use (and maybe buggy?). After playing with it some months ago,
I concluded that it was not going to work for me. That's why I ended up
writing my own rule.

If you want to ensure that the description is set in each child POM, maybe
the scijava-maven-plugin's requireElements rule _can_ help you here? Or do
you, again, only want to set the description in some intermediate POM layer?

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - https://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden


On Sun, Mar 5, 2017 at 3:31 AM, <[hidden email]> wrote:

> Hello.
>
> On 2017-03-05T01:18:34 +0100
> Hervé BOUTEMY <[hidden email]> wrote:
>
> > first, you'll have to talk about rules, not only the plugin: there are
> many
> > rules, some implemented by the plugin and some implemented by MojoHaus
> extra-
> > enforcer-rules
>
> Right, yes. It's the requirePropertyDiverges rule in the
> extra-enforcer-rules package in this case.
>
> >
> > then: MojoHaus requirePropertyDiverges [1] requires that the property
> value is
> > different, not that it is not empty
> >
> > IIUC what you're trying to do, you'll need both Maven requireProperty
> [2] and
> > MojoHaus requirePropertyDiverge [1]
>
> That seems wrong, somehow, and it doesn't match the behaviour that I
> posted. If I don't define a property, then the property (if any) will
> be inherited from an ancestor project, yes? The problem I'm having is
> that the requirePropertyDiverges rule seems to stop working after one
> level of inheritance. See these three example cases:
>
> 0. Project A defines a property P. Project B inherits from
>    A and doesn't redefine or declare P. The requirePropertyDiverges rule
>    correctly rejects this case and the build fails.
>
>    https://github.com/io7m/requirePropertyDiverges-20170305/tr
> ee/master/case-0
>
>    ^^ Building this project should fail, and it does.
>
> 1. Project A defines a property P. Project B inherits from A and
>    redefines P with a different value. The requirePropertyDiverges rule
>    correctly accepts this case and the build succeeds.
>
>    https://github.com/io7m/requirePropertyDiverges-20170305/tr
> ee/master/case-1
>
>    ^^ Building this project should succeed, and it does.
>
> 2. Project A defines a property P. Project B inherits from A and
>    redefines P with a different value. Project C inherits from B
>    and doesn't redefine or declare P. This case *should* fail,
>    because in C, P is inherited from B and therefore has not diverged.
>
>    https://github.com/io7m/requirePropertyDiverges-20170305/tr
> ee/master/case-2
>
>    ^^ Building this project should fail, but it doesn't.
>
> M
>
Reply | Threaded
Open this post in threaded view
|

Re: Enforcer requirePropertyDiverges not propagated to descendants?

Mark Raynsford
On 2017-03-06T10:58:30 -0600
Curtis Rueden <[hidden email]> wrote:

> Hi,
>
> For what it's worth, I agree that the requirePropertyDiverges rule is
> difficult to use (and maybe buggy?). After playing with it some months ago,
> I concluded that it was not going to work for me. That's why I ended up
> writing my own rule.
>
> If you want to ensure that the description is set in each child POM, maybe
> the scijava-maven-plugin's requireElements rule _can_ help you here? Or do
> you, again, only want to set the description in some intermediate POM layer?
https://github.com/io7m/primogenitor/commit/021b5a9a6577c02346d85242b77db31f88f8e25c

:D

"A better fix would be to use scijava's requireElements rule and just
assume that anyone capable of creating new elements would be capable of
making them different from the ancestor."

M

attachment0 (871 bytes) Download Attachment