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

	Copyright (c) 2021 Contributors to Eclipse Foundation.
    Copyright (c) 2017, 2021 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 Mojarra implementation jar.

 -->
<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.glassfish</groupId>
        <artifactId>mojarra-parent</artifactId>
        <version>4.0.0</version>
    </parent>

   <artifactId>jakarta.faces</artifactId>
   <packaging>jar</packaging>

   <name>Mojarra ${project.version}</name>
   <description>EE4J Compatible Implementation for Jakarta Faces API</description>

   <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <mojarra.logstrings.version>${project.version}</mojarra.logstrings.version>
    </properties>

   <!-- ###  D E P E N D E N C I E S  ### -->
   <dependencies>
        <!-- Jakarta EE 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>
        </dependency>
        
        
        <!-- TEST DEPENDENCIES -->
        
        <dependency>
            <groupId>org.glassfish.expressly</groupId>
            <artifactId>expressly</artifactId>
            <version>5.0.0-M1</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymockclassextension</artifactId>
            <version>3.2</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-api-easymock</artifactId>
            <version>2.0.9</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.powermock</groupId>
            <artifactId>powermock-module-junit4</artifactId>
            <version>2.0.9</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.9.4</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>commons-digester</groupId>
            <artifactId>commons-digester</artifactId>
            <version>2.1</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

   <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
                <excludes>
                    <exclude>**/LogStrings*.properties</exclude>
                </excludes>
            </resource>
            <!-- Sets the Main Faces version into the log strings -->
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/LogStrings*.properties</include>
                </includes>
            </resource>
        </resources>
        <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>net.alchim31.maven</groupId>
                                        <artifactId>yuicompressor-maven-plugin</artifactId>
                                        <versionRange>[1.5,)</versionRange>
                                        <goals>
                                            <goal>compress</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <execute>
                                            <runOnIncremental>false</runOnIncremental>
                                        </execute>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
        
            <!-- ###  C O M P R E S S  /  M I N I F Y   faces.js  ###   -->
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.5.1</version>
                <executions>
                    <execution>
                        <id>minify-faces-js</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>compress</goal>
                        </goals>
                        <configuration>
                            <nosuffix>true</nosuffix>
                            <preProcessAggregates>true</preProcessAggregates>
                            <aggregations>
                                <aggregation>
                                    <includes>
                                        <include>${project.basedir}/src/main/resources/META-INF/resources/jakarta.faces/faces-uncompressed.js</include>
                                    </includes>
                                    <output>${project.build.directory}/generated-resources/yui/faces.js</output>
                                </aggregation>
                            </aggregations>
                            <includes>
                                <include>*.js</include>
                            </includes>
                            <sourceDirectory>${project.build.directory}/generated-resources/yui</sourceDirectory>
                            <outputDirectory>${project.build.directory}/generated-resources/yui/META-INF/resources/jakarta.faces/</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            
            <!-- Adds the paths where the source and resources generated above was stored -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>generate-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${project.build.directory}/generated-resources/yui</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <trimStackTrace>false</trimStackTrace>
                    <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
                </configuration>
            </plugin>
     
            
            <!-- Creates the OSGi MANIFEST.MF file -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <version>5.1.4</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <instructions>
                        <Bundle-SymbolicName>org.glassfish.jakarta.faces</Bundle-SymbolicName>
                        <Bundle-Version>${project.version}</Bundle-Version>
                        <Bundle-Name>Mojarra Faces Implementation ${project.version}</Bundle-Name>
                        <Bundle-Description>Eclipse Faces Implementation (jakarta.faces/4.0) ${project.version}</Bundle-Description>
                        
                        <Specification-Title>Jakarta Faces</Specification-Title>
                        <Specification-Version>4.0</Specification-Version>
                        
                        <Implementation-Title>Mojarra</Implementation-Title> 
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Vendor>Eclipse</Implementation-Vendor> 
                        <Implementation-Vendor-Id>org.glassfish</Implementation-Vendor-Id>
                        
                        <Extension-Name>jakarta.faces</Extension-Name>
                        
                        <Export-Package>
                            jakarta.faces.*,
                            com.sun.faces.*
                        </Export-Package>
                        
                        <Import-Package>
                            jakarta.faces.*,
                            com.sun.faces.*,
                            jakarta.servlet.annotation.*;resolution:=optional,
                            jakarta.servlet.*,
                            jakarta.el.*,
                            jakarta.inject.*,
                            jakarta.enterprise.inject.*,
                            jakarta.enterprise.util.*,
                            jakarta.enterprise.context.*,
                            jakarta.annotation.processing.*,
                            jakarta.annotation.*,
                            javax.crypto.*,
                            jakarta.websocket.*;resolution:=optional,
                            jakarta.json.*;resolution:=optional,
                            jakarta.validation.*;resolution:=optional,
                            jakarta.enterprise.event;resolution:=optional,
                            jakarta.ejb.*;resolution:=optional,
                            jakarta.persistence.*;resolution:=optional,
                            javax.xml.*,
                            org.w3c.dom.*,
                            com.sun.enterprise.*;resolution:=optional,
                            org.jboss.weld.*;resolution:=optional,
                            org.xml.sax.*,
                            javax.naming.*
                        </Import-Package>
                        <!--
                            Allow Mojarra to load alternative AnnotationProvider, FaceletConfigResourceProvider,
                            FacesConfigResourceProvider, CDIUtil, and ApplicationConfigurationPopulator SPI
                            implementations. Mojarra provides default implementations, so each capability is marked as
                            optional.
                        -->
                        <Require-Capability>
                            osgi.serviceloader;filter:="(osgi.serviceloader=com.sun.faces.spi.AnnotationProvider)";
                            resolution:=optional;cardinality:=multiple,
                            osgi.serviceloader;filter:="(osgi.serviceloader=com.sun.faces.spi.FaceletConfigResourceProvider)";
                            resolution:=optional;cardinality:=multiple,
                            osgi.serviceloader;filter:="(osgi.serviceloader=com.sun.faces.spi.FacesConfigResourceProvider)";
                            resolution:=optional;cardinality:=multiple,
                            osgi.serviceloader;filter:="(osgi.serviceloader=jakarta.faces.application.ApplicationConfigurationPopulator)";
                            resolution:=optional;cardinality:=multiple,
                            osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)";resolution:=optional
                        </Require-Capability>
                    </instructions>
                </configuration>
            </plugin>
            
            <!-- Adds the manifest file created by the org.apache.felix:maven-bundle-plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.2</version>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                    <excludes>
                        <exclude>**/*.java</exclude>
                        <exclude>**/*.html</exclude>
                    </excludes>
                </configuration>
            </plugin>
            
            <!-- Creates the source jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <!-- 
               Create Javadoc for API jar
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.3.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <configuration>
                            <excludePackageNames>com</excludePackageNames>
                        </configuration>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
