<?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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <!-- ************************************************************* -->
    <!-- *** POM Relationships *************************************** -->
    <!-- ************************************************************* -->

    <parent>
        <groupId>org.nuiton</groupId>
        <artifactId>mavenpom</artifactId>
        <version>2.0.7</version>
    </parent>

    <artifactId>mavenpom4redmine</artifactId>

    <!-- add this in your pom
    <parent>
        <groupId>org.nuiton</groupId>
        <artifactId>mavenpom4redmine</artifactId>
        <version>XXX</version>
    </parent>
    -->

    <!-- ************************************************************* -->
    <!-- *** Project Information ************************************* -->
    <!-- ************************************************************* -->

    <name>Mavenpom4redmine</name>

    <description>Ancestor of all projects of Code Lutin based on a redmine developpment environnement</description>

    <inceptionYear>2010</inceptionYear>

    <!-- ************************************************************* -->
    <!-- *** Build Environment  ************************************** -->
    <!-- ************************************************************* -->

    <!-- Build Environment : Environment Information -->

    <issueManagement>
        <system>redmine</system>
        <url>${redmine.url}/projects/${projectId}/issues</url>
    </issueManagement>

    <!--Any mailing lists for the project-->
    <!--on redmine platform (nuiton or chorem) we normalize it to 3 lists -->
    <!--commits, devel and users -->
    <mailingLists>
        <mailingList>
            <name>${listId}-commits</name>
            <subscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-commits</subscribe>
            <unsubscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-commits</unsubscribe>
            <post>${listId}-commits@list.${platform}</post>
            <archive>http://list.${platform}/pipermail/${listId}-commits/</archive>
        </mailingList>

        <mailingList>
            <name>${listId}-devel</name>
            <subscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-devel</subscribe>
            <unsubscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-devel</unsubscribe>
            <post>${listId}-devel@list.${platform}</post>
            <archive>http://list.${platform}/pipermail/${listId}-devel/</archive>
        </mailingList>

        <mailingList>
            <name>${listId}-users</name>
            <subscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-users</subscribe>
            <unsubscribe>http://list.${platform}/cgi-bin/mailman/listinfo/${listId}-users</unsubscribe>
            <post>${listId}-users@list.${platform}</post>
            <archive>http://list.${platform}/pipermail/${listId}-users/</archive>
        </mailingList>
    </mailingLists>

    <!-- ************************************************************* -->
    <!-- *** Build Settings ****************************************** -->
    <!-- ************************************************************* -->

    <properties>

        <!-- the redmine plateform used (nuiton.org or chorem.org) -->
        <platform>nuiton.org</platform>

        <!-- redmine configuration -->
        <redmine.safe>false</redmine.safe>
        <redmine.url>http://www.${platform}</redmine.url>
        <redmine.projectId>${projectId}</redmine.projectId>
        <redmine.xmlPath>${maven.gen.dir}/changes/changes.xml</redmine.xmlPath>
        <redmine.collectedArtifacts>target/collect-artifacts.txt</redmine.collectedArtifacts>
        <redmine.collectedAttachments>target/collect-attachments.txt</redmine.collectedAttachments>
        <redmine.deploymentUrl>${repository.home.url}</redmine.deploymentUrl>

        <!-- extra files to include in release -->
        <redmine.releaseFiles />

        <!-- use this for a lib extra files -->
        <redmine.libReleaseFiles>
            target/${project.artifactId}-${project.version}-deps.zip,
            target/${project.artifactId}-${project.version}-full.zip
        </redmine.libReleaseFiles>

    </properties>

    <packaging>pom</packaging>

    <reporting>
        <plugins>

            <plugin>
                <groupId>org.codehaus.sonar-plugins</groupId>
                <artifactId>maven-report</artifactId>
                <version>0.1</version>
                <configuration>
                    <sonar.host.url>http://hudson.${platform}/sonar</sonar.host.url>
                </configuration>
            </plugin>
        </plugins>
    </reporting>
    
    <!-- ************************************************************* -->
    <!-- *** Maven Environment *************************************** -->
    <!-- ************************************************************* -->

    <!--Distribution-->
    <distributionManagement>
        <site>
            <id>nuiton</id>
            <!-- l'héritage sur les poms donnera la bonne url pour tous les poms
                 qui héritent de ce pom (/artifactId est rajouté) mais cela ne
                 fonctionne pas pour mavenpom lui-même (voir profile internal)
            -->
            <url>scpexe://${platform}/var/lib/redmine-${platform}/project-site/</url>
        </site>
    </distributionManagement>

    <!-- Maven Environment : profiles -->
    <profiles>

        <!-- perform only on a release stage when using the maven-release-plugin -->
        <profile>
            <id>redmine-build-release-profile</id>
            <activation>
                <property>
                    <name>performRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <!-- fails if redmine goals are not ok -->
                <redmine.safe>true</redmine.safe>
            </properties>

            <reporting>
                <plugins>

                    <plugin>
                        <artifactId>maven-changes-plugin</artifactId>
                        <version>2.3</version>
                        <configuration>
                            <issueLinkTemplatePerSystem>
                                <redmine>${redmine.issueLinkTemplate}</redmine>
                            </issueLinkTemplatePerSystem>
                            <xmlPath>${redmine.xmlPath}</xmlPath>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>changes-report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>

                    <!-- generate issues report -->
                    <plugin>
                        <groupId>org.nuiton.jredmine</groupId>
                        <artifactId>maven-jredmine-plugin</artifactId>
                        <version>${jredmine.version}</version>
                        <configuration>
                            <columnNames>
                                key,summary,status,assignee,tracker,priority,version,category,createdOn
                            </columnNames>
                        </configuration>
                        <reportSets>
                            <reportSet>
                                <reports>
                                    <report>issues-report</report>
                                </reports>
                            </reportSet>
                        </reportSets>
                    </plugin>

                </plugins>
            </reporting>
            <build>

                <plugins>

                    <!--
                     - obtain redmine username
                     - collect all artifacts attached to build for announcements
                     -->
                    <plugin>
                        <groupId>org.nuiton</groupId>
                        <artifactId>maven-helper-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>get-redmine-login</id>
                                <goals>
                                    <goal>share-server-secret</goal>
                                </goals>
                                <phase>initialize</phase>
                                <configuration>
                                    <serverId>redmine-${platform}</serverId>
                                    <usernameOut>redmine.username</usernameOut>
                                    <!-- TC-20100124 just expose username, no need
                                         password -->
                                    <!--<passwordOut>redmine.password</passwordOut>-->
                                </configuration>
                            </execution>
                            <execution>
                                <id>collect-build-artifacts</id>
                                <goals>
                                    <goal>collect-files</goal>
                                </goals>
                                <phase>install</phase>
                                <configuration>
                                    <descriptionFile>${redmine.collectedArtifacts}</descriptionFile>
                                    <includeAttached>true</includeAttached>
                                    <includeSiteAttached>true</includeSiteAttached>
                                </configuration>
                            </execution>
                            <execution>
                                <id>collect-build-attachements</id>
                                <goals>
                                    <goal>collect-files</goal>
                                </goals>
                                <phase>install</phase>
                                <configuration>
                                    <extraFiles>${redmine.releaseFiles}</extraFiles>
                                    <descriptionFile>${redmine.collectedAttachments}</descriptionFile>
                                    <includeAttached>false</includeAttached>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                      - generate changes.xml file from redmine
                      -->
                    <plugin>
                        <groupId>org.nuiton.jredmine</groupId>
                        <artifactId>maven-jredmine-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jredmine-generate-changes</id>
                                <goals>
                                    <goal>generate-changes</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <generateOnce>true</generateOnce>
                                    <actionMapping>fix:1, add:2</actionMapping>
                                    <statusIds>3,4,5</statusIds>
                                </configuration>
                            </execution>

                        </executions>

                    </plugin>

                </plugins>

            </build>
        </profile>

        <!-- launch this profile after a release:perform on target/checkout -->
        <profile>
            <id>redmine-pre-release-profile</id>
            <activation>
                <property>
                    <name>performRedminePreRelease</name>
                    <value>true</value>
                </property>
            </activation>
            <properties>
                <!-- fails if redmine goals are not ok -->
                <redmine.safe>true</redmine.safe>

                <dryRun>true</dryRun>
                <redmine.dryRun>${dryRun}</redmine.dryRun>
            </properties>

            <build>

                <defaultGoal>validate</defaultGoal>

                <plugins>

                    <!--
                     - obtain redmine login
                     -->
                    <plugin>
                        <groupId>org.nuiton</groupId>
                        <artifactId>maven-helper-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>get-redmine-login</id>
                                <goals>
                                    <goal>share-server-secret</goal>
                                </goals>
                                <phase>validate</phase>
                                <configuration>
                                    <serverId>redmine-${platform}</serverId>
                                    <passwordOut>redmine.password</passwordOut>
                                    <usernameOut>redmine.username</usernameOut>
                                </configuration>
                            </execution>

                        </executions>
                    </plugin>

                    <!--
                      - publish attachments
                      - generate release announcements
                      -->
                    <plugin>
                        <groupId>org.nuiton.jredmine</groupId>
                        <artifactId>maven-jredmine-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jredmine-pre-release</id>
                                <goals>
                                    <goal>publish-attachments</goal>
                                    <goal>generate-news-announcement</goal>
                                    <goal>generate-email-announcement</goal>
                                </goals>
                                <phase>validate</phase>
                                <inherited>false</inherited>
                                <configuration>

                                    <filesFromProperties>${redmine.collectedAttachments}</filesFromProperties>

                                    <urlDownload>${redmine.url}/projects/list_files/${projectId}</urlDownload>
                                    <artifactsFile>${redmine.collectedArtifacts}</artifactsFile>

                                </configuration>
                            </execution>
                        </executions>

                    </plugin>

                </plugins>

            </build>
        </profile>

        <!-- perform a redmine release after a successfull release -->
        <profile>
            <id>redmine-release-profile</id>
            <activation>
                <property>
                    <name>performRedmineRelease</name>
                    <value>true</value>
                </property>
            </activation>

            <properties>
                <!-- fails if redmine goals are not ok -->
                <redmine.safe>true</redmine.safe>

                <dryRun>true</dryRun>
                <redmine.dryRun>${dryRun}</redmine.dryRun>
            </properties>
            <build>

                <defaultGoal>validate</defaultGoal>
                
                <plugins>

                    <!--
                     - obtain redmine login
                     - send release email
                     -->
                    <plugin>
                        <groupId>org.nuiton</groupId>
                        <artifactId>maven-helper-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>get-redmine-login</id>
                                <goals>
                                    <goal>share-server-secret</goal>
                                </goals>
                                <phase>validate</phase>
                                <configuration>
                                    <serverId>redmine-${platform}</serverId>
                                    <passwordOut>redmine.password</passwordOut>
                                    <usernameOut>redmine.username</usernameOut>
                                </configuration>
                            </execution>
                            <execution>
                                <id>send-release-email</id>
                                <goals>
                                    <goal>send-email</goal>
                                </goals>
                                <phase>validate</phase>
                                <inherited>false</inherited>
                                <configuration>

                                    <!-- for a multi-module just run on root project -->
                                    <runOnce>true</runOnce>

                                    <emailTitle>[ANN] - ${project.name} ${project.version} released</emailTitle>
                                    <emailContentFile>
                                        target/generated-sources/announcement/release-email-announcement.vm
                                    </emailContentFile>
                                    <mailSender>
                                        <name>${platform} Release Notification</name>
                                        <email>noreply@${platform}</email>
                                    </mailSender>
                                    <toAddresses>
                                        <item>${listId}-users@list.${platform}</item>
                                        <item>${listId}-devel@list.${platform}</item>
                                        <item>announce-${platform}@list.${platform}</item>
                                    </toAddresses>
                                    <smtpHost>smtp</smtpHost>
                                    <!-- fix bug #146 -->
                                    <encoding>iso-8859-1</encoding>

                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!-- 
                     - update version in redmine
                     - publish the release news announcement in redmine
                    -->
                    <plugin>
                        <groupId>org.nuiton.jredmine</groupId>
                        <artifactId>maven-jredmine-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jredmine-release</id>
                                <goals>
                                    <goal>update-version</goal>
                                    <goal>publish-news</goal>
                                </goals>
                                <phase>validate</phase>
                            </execution>
                        </executions>
                        <configuration>

                            <!-- for a multi-module just run on root project -->
                            <runOnce>true</runOnce>

                            <!-- udpate-version -->
                            <closeVersion>true</closeVersion>

                            <!-- publish-news -->
                            <newsContentFile>
                                target/generated-sources/announcement/release-news-announcement.vm
                            </newsContentFile>
                            <newsSummary>${project.description}</newsSummary>
                            <newsTitle>${project.name} ${project.version} released</newsTitle>

                        </configuration>
                    </plugin>

                </plugins>

            </build>
        </profile>

        <!-- perform a redmine release after a successfull release -->
        <profile>
            <id>redmine-next-version-profile</id>
            <activation>
                <property>
                    <name>redmineNextVersion</name>
                    <value>true</value>
                </property>
            </activation>

            <properties>

            </properties>
            <build>

                <defaultGoal>validate</defaultGoal>

                <plugins>

                    <!--
                     - obtain redmine login
                     -->
                    <plugin>
                        <groupId>org.nuiton</groupId>
                        <artifactId>maven-helper-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>get-redmine-login</id>
                                <goals>
                                    <goal>share-server-secret</goal>
                                </goals>
                                <phase>validate</phase>
                                <inherited>false</inherited>
                                <configuration>
                                    <serverId>redmine-${platform}</serverId>
                                    <passwordOut>redmine.password</passwordOut>
                                    <usernameOut>redmine.username</usernameOut>
                                    <!-- for a multi-module just run on root project -->
                                    <runOnce>true</runOnce>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                      create next version if necessary and transfert all opened issued from a previous version
                     if given
                    -->
                    <plugin>
                        <groupId>org.nuiton.jredmine</groupId>
                        <artifactId>maven-jredmine-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>jredmine-next-version</id>
                                <goals>
                                    <goal>next-version</goal>
                                </goals>
                                <phase>validate</phase>
                                <inherited>false</inherited>
                            </execution>
                        </executions>
                        <configuration>

                            <!-- for a multi-module just run on root project -->
                            <runOnce>true</runOnce>

                        </configuration>
                    </plugin>

                </plugins>

            </build>
        </profile>

        <profile>
            <id>internal</id>
            <activation>
                <property>
                    <name>internal</name>
                    <value>true</value>
                </property>
            </activation>
            <distributionManagement>
                <site>
                    <id>nuiton</id>
                    <url>
                        scpexe://nuiton.org/var/lib/redmine-nuiton/project-site/mavenpom/mavenpom4redmine
                    </url>
                </site>
            </distributionManagement>
        </profile>


    </profiles>

</project>
