<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>de.cuioss</groupId>
        <artifactId>cui-java-bom</artifactId>
        <version>0.9.2</version>
    </parent>

    <artifactId>cui-java-parent</artifactId>
    <packaging>pom</packaging>
    <name>cui java parent</name>
    <description>Parent pom for simple java-projects</description>

    <properties>
        <maven.javadoc.plugin.failOnError>true</maven.javadoc.plugin.failOnError>
        <!-- See https://docs.oracle.com/en/java/javase/17/docs/specs/man/javadoc.html#additional-options-provided-by-the-standard-doclet-->
        <maven.javadoc.plugin.doclint>html</maven.javadoc.plugin.doclint>
        <!-- See https://maven.apache.org/plugins/maven-javadoc-plugin/javadoc-mojo.html#legacymode -->
        <maven.javadoc.plugin.legacyMode>false</maven.javadoc.plugin.legacyMode>
        <!-- The automatic module name to be set. Must be corresponding to 
            the one defined at module.info -->
        <maven.jar.plugin.automatic.module.name>
            ${project.groupId}.${project.artifactId}
        </maven.jar.plugin.automatic.module.name>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <configuration>
                        <sourcepath>src/main/java</sourcepath>
                        <source>${maven.compiler.source}</source>
                        <linksource>true</linksource>
                        <quiet>true</quiet>
                        <notimestamp>true</notimestamp>
                        <splitindex>true</splitindex>
                        <doctitle>${project.name}</doctitle>
                        <!--https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#BEJEFABE -->
                        <doclint>${maven.javadoc.plugin.doclint}</doclint>
                    </configuration>
                    <executions>
                        <execution>
                            <id>attach-javadocs</id>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-jar-plugin</artifactId>
                    <configuration>
                        <excludes>
                            <exclude>**/log4j2.xml</exclude>
                            <!-- Exclude eclipse workspace files -->
                            <exclude>**/*.jsfdia</exclude>
                        </excludes>
                        <archive>
                            <index>true</index>
                            <manifest>
                                <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            </manifest>
                            <manifestEntries>
                                <Automatic-Module-Name>
                                    ${maven.jar.plugin.automatic.module.name}
                                </Automatic-Module-Name>
                                <Build-Time>${maven.build.timestamp}</Build-Time>
                                <Build-User>${user.name}</Build-User>
                                <!--suppress UnresolvedMavenProperty -->
                                <Build-Maven>Maven ${maven.version}</Build-Maven>
                                <Build-Java>${java.version}</Build-Java>
                                <Build-OS>${os.name}</Build-OS>
                                <!--suppress UnresolvedMavenProperty -->
                                <Build-Number>${buildNumber}</Build-Number>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>buildnumber-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>io.smallrye</groupId>
                        <artifactId>jandex-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-site-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release-snapshot</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>buildnumber-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>io.smallrye</groupId>
                        <artifactId>jandex-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>javadoc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>buildnumber-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>io.smallrye</groupId>
                        <artifactId>jandex-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>

                </plugins>
            </build>
        </profile>
        <profile>
            <id>sonar</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>@{argLine} -Xms64m -Xmx1024m</argLine>
                            <redirectTestOutputToFile>true</redirectTestOutputToFile>
                            <printSummary>true</printSummary>
                            <trimStackTrace>false</trimStackTrace>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.sonarsource.scanner.maven</groupId>
                        <artifactId>sonar-maven-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- This profile is needed for multi-module-projects, -->
            <id>javadoc-mm-reporting</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <configuration>
                            <source>${maven.compiler.source}</source>
                            <linksource>true</linksource>
                            <quiet>true</quiet>
                            <notimestamp>true</notimestamp>
                            <failOnError>${maven.javadoc.plugin.failOnError}</failOnError>
                            <doclint>${maven.javadoc.plugin.doclint}</doclint>
                            <splitindex>true</splitindex>
                            <doctitle>${project.name}</doctitle>
                            <doclint>none</doclint>
                            <legacyMode>${maven.javadoc.plugin.legacyMode}</legacyMode>
                            <links>
                                <link>https://jakarta.ee/specifications/platform/10/apidocs/</link>
                            </links>
                        </configuration>
                        <executions>
                            <execution>
                                <id>aggregate</id>
                                <goals>
                                    <goal>aggregate</goal>
                                </goals>
                                <phase>site</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
            <reporting>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <reportSets>
                            <reportSet>
                                <id>aggregate</id>
                                <inherited>false</inherited>
                                <reports>
                                    <report>aggregate</report>
                                </reports>
                            </reportSet>
                            <reportSet>
                                <id>default</id>
                                <reports>
                                    <report>javadoc</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>
                </plugins>
            </reporting>
        </profile>
        <profile>
            <!-- Usage: ./mvnw -Prewrite-prepare-release rewrite:run -->
            <!-- Unifies some aspect like coding, formatting, and header-->
            <id>rewrite-prepare-release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.openrewrite.maven</groupId>
                        <artifactId>rewrite-maven-plugin</artifactId>
                        <configuration>
                            <activeRecipes>
                                <recipe>org.openrewrite.java.AddApache2LicenseHeader</recipe>
                                <recipe>org.openrewrite.java.format.AutoFormat</recipe>
                                <recipe>org.openrewrite.java.RemoveUnusedImports</recipe>
                                <recipe>org.openrewrite.java.OrderImports</recipe>
                            </activeRecipes>
                        </configuration>
                        <executions>
                            <execution>
                                <id>rewrite</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Usage: ./mvnw -Prewrite-modernize rewrite:run -->
            <!-- Modifies the codebase to Best-Practices -->
            <id>rewrite-modernize</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.openrewrite.maven</groupId>
                        <artifactId>rewrite-maven-plugin</artifactId>
                        <configuration>
                            <activeRecipes>
                                <recipe>org.openrewrite.java.migrate.util.JavaUtilAPIs</recipe>
                                <recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
                                <recipe>org.openrewrite.java.testing.junit5.JUnit5BestPractices</recipe>
                                <recipe>org.openrewrite.java.migrate.util.OptionalNotEmptyToIsPresent</recipe>
                                <recipe>org.openrewrite.java.migrate.util.OptionalNotPresentToIsEmpty</recipe>
                                <recipe>org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList</recipe>
                                <recipe>org.openrewrite.java.migrate.util.UseLocaleOf</recipe>
                                <recipe>org.openrewrite.java.migrate.util.UseMapOf</recipe>
                            </activeRecipes>
                        </configuration>
                        <executions>
                            <execution>
                                <id>rewrite</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- Used for local coverage tests. An addition not replacement for the sonar build -->
            <id>coverage</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>prepare-agent</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>report</id>
                                <goals>
                                    <goal>report</goal>
                                </goals>
                                <phase>test</phase>
                                <configuration>
                                    <formats>
                                        <format>XML</format>
                                        <format>HTML</format>
                                    </formats>
                                </configuration>
                            </execution>
                            <execution>
                                <id>check</id>
                                <goals>
                                    <goal>check</goal>
                                </goals>
                                <phase>verify</phase>
                                <configuration>
                                    <rules>
                                        <rule>
                                            <element>BUNDLE</element>
                                            <limits>
                                                <limit>
                                                    <counter>INSTRUCTION</counter>
                                                    <value>COVEREDRATIO</value>
                                                    <minimum>0.80</minimum>
                                                </limit>
                                                <limit>
                                                    <counter>BRANCH</counter>
                                                    <value>COVEREDRATIO</value>
                                                    <minimum>0.80</minimum>
                                                </limit>
                                            </limits>
                                        </rule>
                                    </rules>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <argLine>${argLine}</argLine>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

