Hi,

> I do actually want to enforce this, the issue is that I only want to
> enforce it as far as the first ancestor.

Sorry if you stated otherwise in your writeup, but my understanding is that
you want to define some empty properties in your new root POM, and then
ensure they are _not_ empty in the next level down. Right?

If so, then I think the requireProperty rule should be sufficient. You can
write:

  <properties>
    <io7m.previous.version />
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>enforce-property</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireProperty>
                  <property>io7m.previous.version</property>
                  <message>You must define the io7m.previous.version
property!</message>
                  <regex>.+</regex>
                  <regexMessage>You must set the io7m.previous.version
property!</regexMessage>
                </requireProperty>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Regards,
Curtis

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


On Thu, Mar 2, 2017 at 2:50 AM, <org.apache.maven.u...@io7m.com> wrote:

> Hello!
>
> On 2017-03-01T15:49:10 -0600
> Curtis Rueden <ctrue...@wisc.edu> wrote:
> >
> > If what you want is to ensure the property is simply non-empty, or
> matching
> > a particular regex, then take a look at the requireProperty enforcer rule
> > [1].
> >
> > Or if your goal is to make sure that a property value _differs_ from the
> > value defined in an ancestor, the requirePropertyDiverges rule [2] might
> be
> > for you.
>
> I do actually want to enforce this, the issue is that I only want to
> enforce it as far as the first ancestor. My current projects look like
> this (where indentation indicates inheritance):
>
>   + io7m-jtensors
>     + io7m-jtensors-core
>     + io7m-jtensors-tests
>     + io7m-jtensors-ieee754b16
>     + ...
>   + io7m-r2
>     + io7m-r2-core
>     + io7m-r2-shaders
>     + ...
>
> I want to move to:
>
>   + io7m-ancestor
>     + io7m-jtensors
>       + io7m-jtensors-core
>       + io7m-jtensors-tests
>       + io7m-jtensors-ieee754b16
>       + ...
>     + io7m-r2
>       + io7m-r2-core
>       + io7m-r2-shaders
>       + ...
>
> So I want to enforce that io7m-jtensors and io7m-r2 override the
> required properties (and elements such as issueManagement), but I don't
> want to propagate that requirement to the individual submodules of
> io7m-jtensors such as io7m-jtensors-core, because this would introduce
> pointless redundancy. I have around 50 top-level projects to manage in
> this form, so any redundancy that can be eliminated really needs to be!
>
> I'm not sure the enforcer plugin is able to express this "only redefine
> once" aspect of the above. Am I wrong?
>
> M
>

Reply via email to