Import Spring Boot BOM properties

Using Spring Boot's Bill of Materials dependency

Inheriting from Spring Boot's starter parent project (org.springframework.boot:spring-boot-starter-parent) may not always be possible. If your organization mandates a specific parent project, or when using multimodule projects, you may need to resort to the alternative, which is to import Spring Boot's BOM project. According to https://docs.spring.io/spring-boot/docs/current/reference/html/using-boot-build-systems.html, this can be done using:

<project>
  [...]
  <dependencyManagement>
     <dependencies>
        [...]
        <dependency>
            <!-- Import dependency management from Spring Boot -->
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>1.5.8.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        [...]
    </dependencies>
  </dependencyManagement>
  [...]
</project>

However, properties defined in this project, such as spring.version, are not available in your own project. This can be very useful for making references to dependencies being brought to your project through the Spring Boot BOM.

To import these properties, you can use the following configuration:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <groupId>com.github.jpmsilva.ppmp</groupId>
        <artifactId>pom-properties-maven-plugin</artifactId>
        <version>0.0.2-SNAPSHOT</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-dependency-pom</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <dependencies>
            <dependency>
              <groupId>org.springframework.boot</groupId>
              <artifactId>spring-boot-dependencies</artifactId>
              <version>1.5.8.RELEASE</version>
            </dependency>
          </dependencies>
        </configuration>
      </plugin>
    </plugins>
    [...]
  </build>
  [...]
</project>

Spring Boot's own version can be turned into a project property, to facilitate future version bumps.