<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>eu.ciechanowiec</groupId>
        <artifactId>sling.rocket.parent</artifactId>
        <version>18.0.0</version>
    </parent>

    <artifactId>sling.rocket.login-form</artifactId>
    <packaging>jar</packaging>

    <name>Sling Rocket - Custom Login Form</name>
    <description>Custom login form that overrides the default one used by Apache Sling</description>

    <dependencies>
        <dependency>
            <groupId>org.apache.sling</groupId>
            <artifactId>org.apache.sling.auth.form</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-license-and-readme-to-jar</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}</directory>
                                    <includes>
                                        <include>LICENSE.txt</include>
                                        <include>login-form.png</include>
                                        <include>README.adoc</include>
                                        <include>docinfo.html</include>
                                        <include>docinfo-footer.html</include>
                                    </includes>
                                    <!-- To enable variables in the resources files
                                         (https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html): -->
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>biz.aQute.bnd</groupId>
                <artifactId>bnd-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bnd-process</id>
                        <goals>
                            <goal>bnd-process</goal>
                        </goals>
                        <configuration>
                            <bnd><![CDATA[
Bundle-Category: ${bundle.category}
Bundle-Description: ${project.description}
Bundle-DocURL: ${url}
Bundle-Name: ${project.name}
Bundle-SymbolicName: ${project.groupId}.${project.artifactId}
Bundle-Version: ${project.version}
Import-Package: !lombok,*
Fragment-Host: org.apache.sling.auth.form; bundle-version="${org.apache.sling.auth.form.version}"

# reproducible builds (https://github.com/bndtools/bnd/issues/3521)
-noextraheaders: true
                                ]]></bnd>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>remove-and-rename-shaded</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <copy file="${project.build.directory}/${project.build.finalName}.jar"
                                      tofile="${project.build.directory}/${project.build.finalName}-sources.jar"/>
                                <copy file="${project.build.directory}/${project.build.finalName}.jar"
                                      tofile="${project.build.directory}/${project.build.finalName}-javadoc.jar"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/${project.build.finalName}-sources.jar</file>
                                    <type>jar</type>
                                    <classifier>sources</classifier>
                                </artifact>
                                <artifact>
                                    <file>${project.build.directory}/${project.build.finalName}-javadoc.jar</file>
                                    <type>jar</type>
                                    <classifier>javadoc</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
