<?xml version="1.0" encoding="UTF-8"?>
<!--

     Copyright 2023 Red Hat

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

         https://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.

-->
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jboss</groupId>
        <artifactId>jboss-parent</artifactId>
        <version>50</version>
    </parent>

    <groupId>org.jboss.elemento</groupId>
    <artifactId>elemento-parent</artifactId>
    <version>2.3.0</version>
    <packaging>pom</packaging>
    <name>Elemento Parent</name>
    <description>Elemental builder API and other goodies for GWT and J2CL</description>
    <url>https://hal-console.gitbook.io/elemento</url>
    <inceptionYear>2023</inceptionYear>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <organization>
        <name>Red Hat</name>
        <url>https://developers.redhat.com/</url>
    </organization>

    <developers>
        <developer>
            <name>Harald Pehl</name>
            <id>hpehl</id>
            <email>hpehl@redhat.com</email>
            <organization>Red Hat</organization>
            <timezone>+1</timezone>
        </developer>
        <developer>
            <name>Claudio Miranda</name>
            <id>claudio4j</id>
            <email>claudio@redhat.com</email>
            <organization>Red Hat</organization>
            <timezone>-3</timezone>
        </developer>
        <developer>
            <name>Ignacio Baca Moreno-Torres</name>
            <id>ibaca</id>
            <email>ignacio@bacamt.com</email>
            <timezone>+1</timezone>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com:${github.org}/${github.name}.git</connection>
        <developerConnection>scm:git:git@github.com:${github.org}/${github.name}.git</developerConnection>
        <url>https://github.com/${github.org}/${github.name}</url>
        <tag>HEAD</tag>
    </scm>
    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/${github.org}/${github.name}/issues</url>
    </issueManagement>
    <distributionManagement>
        <snapshotRepository>
            <id>central</id>
            <url>https://central.sonatype.com/repository/maven-snapshots</url>
        </snapshotRepository>
    </distributionManagement>

    <properties>
        <!-- Dependency versions -->
        <version.checkstyle.config>1.0.8.Final</version.checkstyle.config>
        <version.elemental2>1.3.2</version.elemental2>
        <version.gwt.event>1.0.0-RC1</version.gwt.event>
        <version.gwt.safehtml>1.0.0-RC1</version.gwt.safehtml>
        <version.junit>6.0.0</version.junit>

        <!-- Plugin versions -->
        <version.central.publishing.plugin>0.9.0</version.central.publishing.plugin>
        <version.editorconfig.plugin>0.1.3</version.editorconfig.plugin>
        <version.gwt.plugin>1.2.0</version.gwt.plugin>
        <version.impsort.plugin>1.12.0</version.impsort.plugin>
        <version.javadoc.plugin>3.12.0</version.javadoc.plugin>
        <version.keepachangelog>2.1.1</version.keepachangelog>
        <version.license.plugin>5.0.0</version.license.plugin>
        <version.shade.plugin>3.6.1</version.shade.plugin>

        <!-- Build related -->
        <encoding>UTF-8</encoding>
        <github.org>hal</github.org>
        <github.name>elemento</github.name>
        <java.version>21</java.version>
        <javadoc.options/>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.release>${java.version}</maven.compiler.release>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.min.version>3.9.9</maven.min.version>
        <project.build.sourceEncoding>${encoding}</project.build.sourceEncoding>
        <project.reporting.outputEncoding>${encoding}</project.reporting.outputEncoding>
    </properties>

    <modules>
        <module>build-config</module>
        <module>code-parent</module>
        <module>core</module>
        <module>flow</module>
        <module>logger</module>
        <module>mathml</module>
        <module>router</module>
        <module>router-processor</module>
        <module>router-processor-cdi</module>
        <module>router-processor-common</module>
        <module>svg</module>
    </modules>

    <!-- No dependencies! Dependencies are managed in core-parent -->
    <dependencies/>

    <build>
        <pluginManagement>
            <plugins>
                <!-- Ordered by artifactID -->
                <plugin>
                    <groupId>org.ec4j.maven</groupId>
                    <artifactId>editorconfig-maven-plugin</artifactId>
                    <version>${version.editorconfig.plugin}</version>
                    <configuration>
                        <excludes>
                            <exclude>**/.parcel-cache/**</exclude>
                            <exclude>**/node/**</exclude>
                            <exclude>**/node_modules/**</exclude>
                        </excludes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>net.ltgt.gwt.maven</groupId>
                    <artifactId>gwt-maven-plugin</artifactId>
                    <version>${version.gwt.plugin}</version>
                    <extensions>true</extensions>
                </plugin>
                <plugin>
                    <groupId>net.revelc.code</groupId>
                    <artifactId>impsort-maven-plugin</artifactId>
                    <version>${version.impsort.plugin}</version>
                    <configuration>
                        <groups>java.,javax.,jakarta.,org.,io.,com.</groups>
                        <removeUnused>true</removeUnused>
                        <staticAfter>true</staticAfter>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>co.enear.maven.plugins</groupId>
                    <artifactId>keepachangelog-maven-plugin</artifactId>
                    <version>${version.keepachangelog}</version>
                </plugin>
                <plugin>
                    <groupId>com.mycila</groupId>
                    <artifactId>license-maven-plugin</artifactId>
                    <version>${version.license.plugin}</version>
                    <configuration>
                        <aggregate>true</aggregate>
                        <strictCheck>true</strictCheck>
                        <useDefaultExcludes>true</useDefaultExcludes>
                        <mapping>
                            <parcelrc>DOUBLESLASH_STYLE</parcelrc>
                        </mapping>
                        <licenseSets>
                            <licenseSet>
                                <header>build-config/src/main/resources/etc/license.txt</header>
                                <excludes>
                                    <exclude>LICENSE</exclude>
                                    <exclude>README.md</exclude>
                                    <exclude>**/*.ftl</exclude>
                                    <exclude>**/*.pem</exclude>
                                    <exclude>**/*license*.txt</exclude>
                                    <exclude>**/.parcel-cache/**</exclude>
                                    <exclude>**/node/**</exclude>
                                    <exclude>**/node_modules/**</exclude>
                                    <exclude>**/src/demo/java/**</exclude>
                                    <exclude>**/src/test/resources/**/*.java</exclude>
                                </excludes>
                            </licenseSet>
                        </licenseSets>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <configuration>
                        <configLocation>wildfly-checkstyle/checkstyle.xml</configLocation>
                        <consoleOutput>true</consoleOutput>
                        <failsOnError>true</failsOnError>
                        <includeTestSourceDirectory>true</includeTestSourceDirectory>
                        <excludes>**/*$logger.java,**/*$bundle.java</excludes>
                        <useFile/>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>org.wildfly.checkstyle</groupId>
                            <artifactId>wildfly-checkstyle-config</artifactId>
                            <version>${version.checkstyle.config}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-enforcer-plugin</artifactId>
                    <configuration>
                        <rules>
                            <bannedRepositories>
                                <message>To build this project, don't use maven repositories over HTTP. Please use HTTPS
                                    in your settings.xml or run the build with property insecure.repositories=WARN
                                </message>
                                <level>ERROR</level>
                                <bannedRepositories>
                                    <bannedRepository>http://*</bannedRepository>
                                </bannedRepositories>
                                <bannedPluginRepositories>
                                    <bannedPluginRepository>http://*</bannedPluginRepository>
                                </bannedPluginRepositories>
                            </bannedRepositories>
                            <requireMavenVersion>
                                <message>To build this project Maven ${maven.min.version} (or greater) is required.
                                    Please install it.
                                </message>
                                <version>${maven.min.version}</version>
                            </requireMavenVersion>
                            <requireJavaVersion>
                                <message>To build this project JDK ${maven.compiler.source} (or greater) is required.
                                    Please install it.
                                </message>
                                <version>${maven.compiler.source}</version>
                            </requireJavaVersion>
                        </rules>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>${version.javadoc.plugin}</version>
                    <configuration combine.self="override">
                        <additionalOptions>${javadoc.options}</additionalOptions>
                        <detectLinks>true</detectLinks>
                        <doclint>none</doclint>
                        <failOnError>false</failOnError>
                        <links>
                            <link>https://hal.github.io/elemento/apidocs/</link>
                            <link>https://www.gwtproject.org/javadoc/latest/</link>
                            <link>https://javadoc.io/doc/org.gwtproject.event/gwt-event/${version.gwt.event}/</link>
                            <link>https://javadoc.io/doc/org.gwtproject.safehtml/gwt-safehtml/${version.gwt.safehtml}/</link>
                            <link>https://javadoc.io/doc/com.google.elemental2/elemental2-core/${version.elemental2}/</link>
                            <link>https://javadoc.io/doc/com.google.elemental2/elemental2-dom/${version.elemental2}/</link>
                            <link>https://javadoc.io/doc/com.google.elemental2/elemental2-webstorage/${version.elemental2}/
                            </link>
                        </links>
                        <show>public</show>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>${version.shade.plugin}</version>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <!-- Ordered by artifactID -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforcer-enforce</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-demos</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.basedir}/src/demo/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.ec4j.maven</groupId>
                <artifactId>editorconfig-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>editorconfig-format</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>editorconfig-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.revelc.code</groupId>
                <artifactId>impsort-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>impsort-sort</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>sort</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>impsort-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>license-format</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>license-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>checkstyle-check</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>quick-build</id>
            <activation>
                <property>
                    <name>quickly</name>
                </property>
            </activation>
            <properties>
                <checkstyle.skip>true</checkstyle.skip>
                <editorconfig.skip>true</editorconfig.skip>
                <enforcer.skip>true</enforcer.skip>
                <impsort.skip>true</impsort.skip>
                <license.skip>true</license.skip>
                <maven.javadoc.skip>true</maven.javadoc.skip>
                <skip.gwt>true</skip.gwt>
                <skipITs>true</skipITs>
                <skipTests>true</skipTests>
            </properties>
        </profile>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Semantically ordered -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-enforcer-plugin</artifactId>
                        <configuration>
                            <rules>
                                <requireReleaseDeps>
                                    <message>No Snapshots Allowed!</message>
                                </requireReleaseDeps>
                            </rules>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent gpg from using pinentry programs -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${version.central.publishing.plugin}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <autoPublish>true</autoPublish>
                            <waitUntil>published</waitUntil>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>snippets</id>
            <properties>
                <javadoc.options>--snippet-path ${project.basedir}/src/demo/java</javadoc.options>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>copy-apidocs</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <copy todir="target/reports/apidocs/org/jboss/elemento"
                                              overwrite="true"
                                              failonerror="false">
                                            <fileset dir="core/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                            <fileset dir="flow/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                            <fileset dir="logger/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                            <fileset dir="mathml/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                            <fileset dir="router/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                            <fileset dir="svg/target/reports/apidocs/org/jboss/elemento">
                                                <exclude name="**/class-use/**"/>
                                                <exclude name="package-*.html"/>
                                            </fileset>
                                        </copy>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>samples</id>
            <modules>
                <module>samples</module>
            </modules>
        </profile>
    </profiles>

    <repositories>
        <repository>
            <id>central-snapshots</id>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>oss-snapshots</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>oss-snapshots-01</id>
            <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
</project>
