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

    Copyright (c) 2022, 2022 Contributors to Eclipse Foundation.
    Copyright (c) 2017, 2022 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<!--

    Project to create the Jakarta Faces API jar and docs (vdldocs, jsdocs, renderkit docs).

    This depends on a Mojarra build being available in the version set by mojarra.version

 -->

<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.eclipse.ee4j</groupId>
        <artifactId>project</artifactId>
        <version>1.0.6</version>
        <relativePath />
    </parent>

    <groupId>jakarta.faces</groupId>
    <artifactId>jakarta.faces-api</artifactId>
    <version>4.0.0</version>

    <name>Jakarta Faces</name>
    <description>
        Jakarta Faces defines an MVC framework for building user interfaces for web applications,
        including UI components, state management, event handing, input validation, page navigation, and
        support for internationalization and accessibility.
    </description>
    <url>https://github.com/eclipse-ee4j/faces-api</url>
    <inceptionYear>1997</inceptionYear>
    <licenses>
        <license>
            <name>EPL 2.0</name>
            <url>http://www.eclipse.org/legal/epl-2.0</url>
            <distribution>repo</distribution>
        </license>
        <license>
            <name>GPL2 w/ CPE</name>
            <url>https://www.gnu.org/software/classpath/license.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <id>atijms</id>
            <name>Arjan Tijms</name>
            <email>arjan.tijms@gmail.com</email>
            <roles>
                <role>Project-Lead</role>
                <role>comitter</role>
                <role>developer</role>
            </roles>
            <timezone>+1</timezone>
        </developer>

        <developer>
            <id>balusc</id>
            <name>Bauke Scholtz</name>
            <email>balusc@gmail.com</email>
            <roles>
                <role>comitter</role>
                <role>developer</role>
            </roles>
            <timezone>+4</timezone>
        </developer>
    </developers>
    <contributors>
        <contributor>
            <name>Thomas Andraschko</name>
        </contributor>
        <contributor>
            <name>Manfred Riem</name>
        </contributor>
        <contributor>
            <name>Christoph Straßer</name>
        </contributor>
        <contributor>
            <name>Emil Lefkof</name>
        </contributor>
    </contributors>

    <mailingLists>
        <mailingList>
            <name>Jakarta Faces Specification Mailing List</name>
            <post>https://accounts.eclipse.org/mailing-list/faces-dev</post>
        </mailingList>
    </mailingLists>

    <properties>
        <mojarra.version>4.0.0-M7</mojarra.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <version>6.0.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.websocket</groupId>
            <artifactId>jakarta.websocket-api</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.websocket</groupId>
            <artifactId>jakarta.websocket-client-api</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.el</groupId>
            <artifactId>jakarta.el-api</artifactId>
            <version>5.0.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.validation</groupId>
            <artifactId>jakarta.validation-api</artifactId>
            <version>3.0.1</version>
            <scope>provided</scope>
        </dependency>

        

        <!-- Optional -->
        
        <dependency>
            <groupId>jakarta.transaction</groupId>
            <artifactId>jakarta.transaction-api</artifactId>
            <version>2.0.1-RC1</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>jakarta.json</groupId>
            <artifactId>jakarta.json-api</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>jakarta.ejb</groupId>
            <artifactId>jakarta.ejb-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>jakarta.persistence</groupId>
            <artifactId>jakarta.persistence-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>jakarta.xml.ws</groupId>
            <artifactId>jakarta.xml.ws-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>jakarta.annotation</groupId>
            <artifactId>jakarta.annotation-api</artifactId>
            <version>2.1.0</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <version>4.0.0</version>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>


        <!-- Depend on the source jar of the full implementation Mojarra jar. This is used for unpacking and re-compiling. 
            This jar is created by executing mvn clean install in the [mojarra home]/impl project. -->
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>jakarta.faces</artifactId>
            <version>${mojarra.version}</version>
            <classifier>sources</classifier>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>META-INF/README</exclude>
                    <exclude>${findbugs.exclude}</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>${project.basedir}/..</directory>
                <includes>
                    <include>LICENSE.md</include>
                    <include>NOTICE.md</include>
                </includes>
                <targetPath>META-INF</targetPath>
            </resource>
            <resource>
                <directory>${project.basedir}</directory>
                <includes>
                    <include>LICENSE.md</include>
                    <include>NOTICE.md</include>
                </includes>
                <targetPath>META-INF</targetPath>
            </resource>
        </resources>
        
        <plugins>
            <!-- Sets minimal Maven version -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.6.0</version>
                                </requireMavenVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Restricts the Java version to 11 - API remains at Java 11 for now. -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.0</version>
                <configuration>
                    <source>11</source>
                    <target>11</target>
                    <compilerArgument>-Xlint:unchecked</compilerArgument>
                </configuration>
            </plugin>
            
            <!-- Clean unpacked sources jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <!-- Clean any previously unpacked sources -->
                    <execution>
                        <id>clean</id>
                        <phase>clean</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <delete dir="src/main/java" />
                                <delete dir="src/main/resources" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            

            <!-- Unpack the sources jar that was build and installed by the Mojarra project. This way we can compile that 
                source again in this project, but for the final artifact jar we only include the jakarta.* classes then. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                    </execution>
                </executions>

                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>org.glassfish</groupId>
                            <artifactId>jakarta.faces</artifactId>
                            <version>${mojarra.version}</version>
                            <classifier>sources</classifier>
                            <outputDirectory>src/main/java</outputDirectory>
                            <includes>**/*.java</includes>
                        </artifactItem>

                        <artifactItem>
                            <groupId>org.glassfish</groupId>
                            <artifactId>jakarta.faces</artifactId>
                            <version>${mojarra.version}</version>
                            <classifier>sources</classifier>
                            <outputDirectory>src/main/resources</outputDirectory>
                            <excludes>**/*.java</excludes>
                        </artifactItem>
                    </artifactItems>
                </configuration>
            </plugin>



            <!-- Create API binary jar For the final artifact jar we only include the jakarta.* classes and resources that 
                we compiled from the unpackaged implementation source attachment jar. See the maven-dependency-plugin for this unpackaging. 
                This effectively gives us the API jar. -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <includes>
                        <include>jakarta/**</include>
                        <include>META-INF/LICENSE.md</include>
                        <include>META-INF/NOTICE.md</include>
                    </includes>
                </configuration>
            </plugin>

            <!-- Create sources for API jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>generate-api-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>com/**</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Create Javadoc for API jar -->
            <!-- Result will be saved in /target/apidocs -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-api-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <source>11</source>
                            <additionalJOption>-Xdoclint:none</additionalJOption>
                            <description>Jakarta Faces API documentation</description>
                            <doctitle>Jakarta Faces API documentation</doctitle>
                            <windowtitle>Jakarta Faces API documentation</windowtitle>
                            <header><![CDATA[<br>Jakarta Faces API v${project.version}]]></header>
                            <bottom><![CDATA[
Comments to: <a href="mailto:faces-dev@eclipse.org">faces-dev@eclipse.org</a>.<br>
Copyright &#169; 2019, 2022 Eclipse Foundation. All rights reserved.<br>
Use is subject to <a href="{@docRoot}/doc-files/speclicense.html" target="_top">license terms</a>.]]>
                            </bottom>
                            <docfilessubdirs>true</docfilessubdirs>
                            <groups>
                                <group>
                                    <title>Jakarta Faces API Documentation</title>
                                    <packages>
                                        jakarta.faces.*
                                    </packages>
                                </group>
                            </groups>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>



    <profiles>
        <profile>
            <id>docs</id>
            <build>
                <plugins>
                    <!-- Create JS docs -->
                    <!-- result will be saved in /target/site/jsdoc -->
                    <plugin>
                        <groupId>com.phasebash.jsdoc</groupId>
                        <artifactId>jsdoc3-maven-plugin</artifactId>
                        <version>1.2.0</version>
                        <executions>
                            <execution>
                                <id>generate-jsdoc</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>jsdoc3</goal>
                                </goals>
                                <configuration>
                                    <includePrivate>false</includePrivate>
                                    <lenient>true</lenient>
                                    <configFile>${project.build.directory}/../src/main/jsdoc/conf.json</configFile>
                                    <sourceFiles>
                                        <sourceFile>src/main/resources/META-INF/resources/jakarta.faces/faces-uncompressed.js</sourceFile>
                                    </sourceFiles>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Create Renderkit docs -->
                    <!-- Result will be saved in /target/renderkitdoc  -->
                    <plugin>
                        <groupId>org.omnifaces</groupId>
                        <artifactId>renderkitdoc-maven-plugin</artifactId>
                        <version>1.0</version>
                        <executions>
                            <execution>
                                <id>generate-renderkitdoc</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <facesConfig>${project.basedir}/src/main/resources/com/sun/faces/standard-html-renderkit.xml</facesConfig>
                            <schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
                        </configuration>
                    </plugin>
                    <!-- Post-process RKD - override stylesheet.css of renderkitdoc  -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.2.0</version>
                        <executions>
                            <execution>
                                <id>post-process-renderkitdoc</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/main/renderkitdoc</directory>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.directory}/renderkitdoc</outputDirectory>
                                    <overwrite>true</overwrite>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>


                    <!-- Create VDL docs -->
                    <!-- Result will be saved in /target/vdldoc  -->

                    <!-- Pre-process VDL - copy faces-api.css for vdldoc  -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>generate-vdldoc-pre-process</id>
                                <phase>test</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>src/main/vdldoc</directory>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.directory}/vdldoc</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- Run actual core VDL -->
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <execution>
                                <id>generate-vdldoc</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <includePluginDependencies>true</includePluginDependencies>
                            <mainClass>org.omnifaces.vdldoc.Main</mainClass>
                            <arguments>
                                <argument>-d</argument>
                                <argument>${project.build.directory}/vdldoc</argument>
                                <argument>-windowtitle</argument>
                                <argument>Jakarta Faces ${project.version} VDL Documentation</argument>
                                <argument>-css</argument>
                                <argument>faces-api.css</argument>
                                <argument>-f</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.facelets.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.core.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.html.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.passthrough.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/faces.composite.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/tags.core.taglib.xml</argument>
                                <argument>src/main/resources/com/sun/faces/metadata/taglib/tags.functions.taglib.xml</argument>
                            </arguments>
                        </configuration>
                        <dependencies>
                            <dependency>
                                <groupId>org.omnifaces</groupId>
                                <artifactId>vdldoc</artifactId>
                                <version>3.1</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
    
    
        <profile>
            <id>only-eclipse</id>
            <activation>
                <property>
                    <name>m2e.version</name>
                </property>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on 
                            the Maven build itself. -->
                        <plugin>
                            <groupId>org.eclipse.m2e</groupId>
                            <artifactId>lifecycle-mapping</artifactId>
                            <version>1.0.0</version>
                            <configuration>
                                <lifecycleMappingMetadata>
                                    <pluginExecutions>
                                        <pluginExecution>
                                            <pluginExecutionFilter>
                                                <groupId>org.apache.maven.plugins</groupId>
                                                <artifactId>maven-dependency-plugin</artifactId>
                                                <versionRange>[3.0.2,)</versionRange>
                                                <goals>
                                                    <goal>unpack</goal>
                                                </goals>
                                            </pluginExecutionFilter>
                                            <action>
                                                <execute>
                                                    <runOnIncremental>false</runOnIncremental>
                                                </execute>
                                            </action>
                                        </pluginExecution>
                                    </pluginExecutions>
                                </lifecycleMappingMetadata>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>
</project>
