Hi, > 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.
The way I solved this problem with my project builds is to create a custom requireElements enforcer rule, part of the scijava-maven-plugin [1], which lets you require the existence of particular elements in the POM itself—not an ancestor. Here is the configuration we use: https://github.com/scijava/pom-scijava-base/blob/pom- scijava-base-3.0.0/pom.xml#L610-L628 In this way, I ensure that all projects which extend our parent add all the useful metadata and properties needed for successful builditude. We released scijava-maven-plugin 1.0.0 on Maven Central; feel free to use it if it helps you. Regards, Curtis [1] https://github.com/scijava/scijava-maven-plugin/blob/ scijava-maven-plugin-1.0.0/src/main/java/org/scijava/maven/plugin/enforcer/ RequireElements.java#L55-L61 -- Curtis Rueden LOCI software architect - https://loci.wisc.edu/software ImageJ2 lead, Fiji maintainer - https://imagej.net/User:Rueden On Wed, Mar 1, 2017 at 12:35 PM, <org.apache.maven.u...@io7m.com> wrote: > 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/blo > b/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/blo > b/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 >