<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Licensed to the Apache Software Foundation (ASF) under one
  ~ or more contributor license agreements. See the NOTICE file
  ~ distributed with this work for additional information
  ~ regarding copyright ownership. The ASF licenses this file
  ~ to you 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
  ~
  ~ http://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.apache.ws.commons.axiom</groupId>
        <artifactId>axiom</artifactId>
        <version>1.4.0</version>
    </parent>

    <artifactId>distribution</artifactId>
    <packaging>pom</packaging>

    <name>Distribution</name>

    <properties>
        <skipDeploy>true</skipDeploy>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-api</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-impl</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-dom</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-compat</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-jaxb</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>axiom-all</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>devguide</artifactId>
            <version>${project.version}</version>
            <type>pdf</type>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>userguide</artifactId>
            <version>${project.version}</version>
            <type>pdf</type>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>apidocs</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <classifier>javadoc</classifier>
        </dependency>
    </dependencies>

    <build>
        <finalName>axiom-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.gmavenplus</groupId>
                <artifactId>gmavenplus-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-timestamp</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <script>
                                    import java.util.Date 
                                    import java.text.MessageFormat 
                                    project.properties['build_date'] = MessageFormat.format("{0,date,MMMMM dd, yyyy}", new Date())
                                </script>
                            </scripts>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-release-note</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>execute</goal>
                        </goals>
                        <configuration>
                            <scripts>
                                <!-- Process the release note for the current release, converting relative URLs to absolute ones -->
                                <script><![CDATA[
                                    def release_version = project.version.replaceAll("-SNAPSHOT", "")
                                    def release_note = new File(project.basedir, "../src/site/markdown/release-notes/" + release_version + ".md")
                                    new File(project.build.directory).mkdirs()
                                    def out = new File(project.build.directory, "RELEASE-NOTE.txt").newPrintWriter('UTF-8')
                                    release_note.readLines('UTF-8').each({ line ->
                                        def m = line =~ /^(\[.*\]: *)(.*)/
                                        if (m) {
                                            line = m[0][1] + new URL(new URL("http://ws.apache.org/axiom/release-notes/"), m[0][2])
                                        }
                                        out.println(line)
                                    })
                                    out.close()
                                ]]></script>
                            </scripts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bin</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/assembly/bin.xml</descriptor>
                                <descriptor>src/main/assembly/src.xml</descriptor>
                            </descriptors>
                            <tarLongFileMode>gnu</tarLongFileMode>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.nicoulaj.maven.plugins</groupId>
                <artifactId>checksum-maven-plugin</artifactId>
                <version>1.11</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>artifacts</goal>
                        </goals>
                        <configuration>
                            <algorithms>
                                <algorithm>SHA-512</algorithm>
                            </algorithms>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
