johanhaleby / occurrent

Unintrusive Event Sourcing Library for the JVM
https://occurrent.org
120 stars 16 forks source link

add Occurrent BOM #140

Closed gavvvr closed 1 year ago

gavvvr commented 1 year ago

Hi @johanhaleby

I've prepared the BOM (#21) which includes all the current modules (except for 'example/**' and 'test-support')

Used the following Groovy script to double-check myself:

import groovy.ant.FileNameFinder
import groovy.xml.XmlSlurper

import java.nio.file.Paths

static void main(String[] args) {
  def scanPath = "projects/occurrent"

  def pomFilesOfInterest = new FileNameFinder().getFileNames(scanPath, '**/pom.xml', '**/example/** **/test-support/**')

  def jarModulePoms = []
  for (final def pomFilePath in pomFilesOfInterest) {
    def pom = new XmlSlurper().parse(pomFilePath)
    if (pom.packaging != "pom") {
      jarModulePoms << [pomFilePath, pom.artifactId]
    }
  }

  Collections.sort(jarModulePoms, (t1,t2) -> Paths.get(t1[0]) <=> Paths.get(t2[0]))

  for (final def pom in jarModulePoms) {
    println "${pom[0]} - ${pom[1]}"
  }
}
johanhaleby commented 1 year ago

Adding a bom is a great idea, thank you! However, in other projects I maintain, such as rest-assured, the bom is generated automagically by this plugin (if I'm not mistaken):

<plugin>
    <groupId>io.sundr</groupId>
    <artifactId>sundr-maven-plugin</artifactId>
    <version>${sundrio.version}</version>
    <executions>
        <execution>
            <goals>
                <goal>generate-bom</goal>
            </goals>
            <configuration>
                <boms>
                    <bom>
                        <artifactId>rest-assured-bom</artifactId>
                        <name>REST Assured: BOM</name>
                        <description>Centralized dependencyManagement for the Rest Assured Project</description>
                        <properties>
                            <skipStagingRepositoryClose>true</skipStagingRepositoryClose>
                            <sonar.skip>true</sonar.skip>
                        </properties>
                        <modules>
                            <excludes>
                                <exclude>io.rest-assured.examples:*</exclude>
                            </excludes>
                        </modules>
                    </bom>
                </boms>
            </configuration>
        </execution>
    </executions>
</plugin>

Here we've also instructed the plugin to exclude the "examples" project. The nice thing with this is that I don't have to remember to update the bom project on every new module. Does this make sense here as well?

gavvvr commented 1 year ago

Hi @johanhaleby

Interesting, never saw this plugin before. Some popular projects I've inspected before creating this PR maintain manual list of modules.

Sundr plugin should be very convenient, when you have high degree of modularization (like this project). It's nice that it also supports exclusions. I will adjust this PR later

gavvvr commented 1 year ago

Hi @johanhaleby

This one works well and produces the same result as manual list I've prepared before. I only had to correct a name for one example module. By default, the sundr maven plugin's goal is automatically tied to VALIDATE lifecycle phase

johanhaleby commented 1 year ago

@gavvvr Thanks again for this PR! Very helpful!