Hello.

I'm looking to move to an organization-wide parent POM but am not sure
how to handle the following configuration case.

The japicmp [0] plugin takes a configuration parameter that specifies
the previous version of a module against which the current version of
the module will be checked for API compatibility. I believe it can
sometimes infer the correct version by itself, but for the sake of
explanation here, let's assume that it can't and that I need to specify
it myself. This isn't a japicmp plugin issue, it's just a specific
example of a more general problem regarding the scope and definitions
of properties.

I have a parent pom:

https://github.com/io7m/maven-parent-properties-20170301/blob/develop/pom.xml

... which contains a definition like this:

<project>
  ...
  <properties>
    <io7m.previousVersion></io7m.previousVersion>
  </properties>

  ...

  <build>
    <pluginManagement>
      <plugins>
        <!-- Verify API compatibility -->
        <plugin>
          <groupId>com.github.siom79.japicmp</groupId>
          <artifactId>japicmp-maven-plugin</artifactId>
          <version>0.9.4</version>
          <executions>
            <execution>
              <phase>verify</phase>
              <goals>
                <goal>cmp</goal>
              </goals>
              <configuration>
                <oldVersion>
                  <dependency>
                    <groupId>${project.groupId}</groupId>
                    <artifactId>${project.artifactId}</artifactId>
                    <version>${io7m.previousVersion}</version>
                    <type>jar</type>
                  </dependency>
                </oldVersion>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>
</project>

I then have an example project that inherits from the parent:

https://github.com/io7m/maven-parent-properties-20170301/blob/develop/mod-a/pom.xml

<project>
  <parent>
    <groupId>com.io7m.experimental</groupId>
    <artifactId>maven-parent-properties-20170301</artifactId>
    <version>1.0.0</version>
  </parent>

  <artifactId>mod-a</artifactId>
  <properties>
    <io7m.previousVersion>0.9.0</io7m.previousVersion>
  </properties>

  <build>
    <plugins>
      <plugin>
        <groupId>com.github.siom79.japicmp</groupId>
        <artifactId>japicmp-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
</project>

Note that the child project must override the io7m.previousVersion
property from the parent. Is this the correct way to handle this? The
downside to this is that if a project forgets to override the property
value, it won't get a sensible "You didn't define this property" error
because it's already defined with an empty value in the parent. If I
don't define the property in the parent, many IDEs get upset at the
presence of an undefined property in the POM.

Any advice would be appreciated.

M

[0] https://siom79.github.io/japicmp/MavenPlugin.html

Attachment: pgpMdi3j13ccx.pgp
Description: OpenPGP digital signature

Reply via email to