<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  Mavenpom
  %%
  Copyright (C) 2009 - 2010 CodeLutin
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as
  published by the Free Software Foundation, either version 3 of the
  License, or (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Lesser Public License for more details.

  You should have received a copy of the GNU General Lesser Public
  License along with this program.  If not, see
  <http://www.gnu.org/licenses/lgpl-3.0.html>.
  #L%
-->
<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.nuiton</groupId>
    <artifactId>mavenpom</artifactId>
    <version>6.1</version>
  </parent>

  <artifactId>mavenpom4redmine</artifactId>
  <packaging>pom</packaging>

  <name>Mavenpom4redmine</name>
  <description>Ancestor of all projects of Code Lutin based on a redmine
    developpment environnement
  </description>
  <inceptionYear>2010</inceptionYear>
  <!-- add this in your pom
    <parent>
        <groupId>org.nuiton</groupId>
        <artifactId>mavenpom4redmine</artifactId>
        <version>XXX</version>
    </parent>
    -->
  <modules>
    <module>mavenpom4redmineAndCentral</module>
  </modules>

  <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-->

  <properties>

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

    <license.licenseName>lgpl_v3</license.licenseName>

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

    <!-- since v 4.0, can execute som mojo not on root module -->
    <redmine.runOnlyOnRoot>false</redmine.runOnlyOnRoot>
    <helper.runOnlyOnRoot>false</helper.runOnlyOnRoot>

    <!-- issues status to include in changelog -->
    <redmine.statusIds>3,4,5</redmine.statusIds>

    <!-- 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>

    <!-- Post Release configuration (by default do not send - publish) -->

    <skipPostRelease>true</skipPostRelease>
    <skipReleasePublishAttachments>
      ${skipPostRelease}
    </skipReleasePublishAttachments>
    <skipReleaseUpdateVersion>${skipPostRelease}</skipReleaseUpdateVersion>
    <skipReleaseSendEmail>${skipPostRelease}</skipReleaseSendEmail>
    <skipReleasePublishNews>${skipPostRelease}</skipReleasePublishNews>

  </properties>

  <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>${changesPluginVersion}</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>jredmine-maven-plugin</artifactId>
            <version>${jredminePluginVersion}</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>helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>get-redmine-login</id>
                <goals>
                  <goal>share-server-secret</goal>
                </goals>
                <phase>initialize</phase>
                <configuration>
                  <serverId>redmine-forge.${platform}</serverId>
                  <privateKeyOut>redmine.apiKey</privateKeyOut>
                </configuration>
              </execution>
              <execution>
                <id>collect-build-artifacts</id>
                <goals>
                  <goal>collect-files</goal>
                </goals>
                <phase>verify</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>verify</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>jredmine-maven-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, update:4</actionMapping>
                </configuration>
              </execution>

            </executions>

          </plugin>

        </plugins>

      </build>
    </profile>

    <!-- For post-release actions -->
    <profile>
      <id>post-release-profile</id>
      <properties>

        <!-- templates location -->
        <redmine.templateDirectory>
          https://doc.nuiton.org/mavenpom/announcement/redmine
        </redmine.templateDirectory>
      </properties>

      <build>

        <defaultGoal>validate</defaultGoal>

        <plugins>

          <!--
          - obtain redmine login
          - send announcement email
          -->
          <plugin>
            <groupId>org.nuiton</groupId>
            <artifactId>helper-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>get-redmine-login</id>
                <goals>
                  <goal>share-server-secret</goal>
                </goals>
                <phase>validate</phase>
                <configuration>
                  <serverId>redmine-forge.${platform}</serverId>
                  <privateKeyOut>redmine.apiKey</privateKeyOut>
                </configuration>
              </execution>

              <execution>
                <id>send-release-email</id>
                <goals>
                  <goal>send-email</goal>
                </goals>
                <phase>install</phase>
                <!--inherited>false</inherited-->
                <configuration>

                  <!-- for a multi-module just run on root project -->
                  <runOnce>true</runOnce>
                  <skipSendEmail>${skipReleaseSendEmail}</skipSendEmail>

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

                </configuration>
              </execution>

            </executions>
          </plugin>

          <!--
          - publish attachments
          - generate news announcement
          - generate email announcement
          - update version
          - publish news announcement
          - create next version
          -->
          <plugin>
            <groupId>org.nuiton.jredmine</groupId>
            <artifactId>jredmine-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>publish-attachments</id>
                <goals>
                  <goal>publish-attachments</goal>
                </goals>
                <phase>verify</phase>
                <configuration>
                  <filesFromProperties>
                    ${redmine.collectedAttachments}
                  </filesFromProperties>

                  <skipPublishAttachments>
                    ${skipReleasePublishAttachments}
                  </skipPublishAttachments>
                </configuration>
              </execution>
              <execution>
                <id>generate-announcements</id>
                <goals>
                  <goal>generate-news-announcement</goal>
                  <goal>generate-email-announcement</goal>
                </goals>
                <phase>verify</phase>
                <configuration>
                  <announceParameters>
                    <releaseProjectGroupId>
                      ${session.topLevelProject.groupId}
                    </releaseProjectGroupId>
                    <releaseProjectArtifactId>
                      ${session.topLevelProject.artifactId}
                    </releaseProjectArtifactId>
                    <releaseProjectVersion>
                      ${session.topLevelProject.version}
                    </releaseProjectVersion>
                  </announceParameters>
                  <skipGenerateEmailAnnouncement>
                    ${skipReleaseSendEmail}
                  </skipGenerateEmailAnnouncement>
                  <skipGenerateNewsAnnouncement>
                    ${skipReleasePublishNews}
                  </skipGenerateNewsAnnouncement>
                  <urlDownload>
                    ${redmine.url}/projects/${projectId}/files
                  </urlDownload>
                  <artifactsFile>${redmine.collectedArtifacts}</artifactsFile>
                </configuration>
              </execution>

              <execution>
                <id>jredmine-release</id>
                <goals>
                  <goal>update-version</goal>
                  <goal>publish-news</goal>
                </goals>
                <phase>install</phase>
                <configuration>
                  <!-- for a multi-module just run on root project -->
                  <runOnce>true</runOnce>
                  <skipUpdateVersion>
                    ${skipReleaseUpdateVersion}
                  </skipUpdateVersion>
                  <skipPublishNews>${skipReleasePublishNews}</skipPublishNews>

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

                  <!-- publish-news -->
                  <newsContentFile>
                    target/generated-sources/announcement/release-news-announcement.vm
                  </newsContentFile>
                  <newsSummary>${project.description}</newsSummary>
                  <newsTitle>
                    ${releaseAnnouncementTitle}
                  </newsTitle>
                </configuration>
              </execution>
            </executions>

          </plugin>

        </plugins>

      </build>
    </profile>

    <!-- To publish attachments in redmine -->
    <profile>
      <id>redmine-publish-attachments-profile</id>
      <activation>
        <property>
          <name>publishAttachments</name>
          <value>true</value>
        </property>
      </activation>

      <build>

        <defaultGoal>validate</defaultGoal>

        <plugins>

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

            </executions>
          </plugin>

          <!--
          - publish attachments
          - generate release announcements
          -->
          <plugin>
            <groupId>org.nuiton.jredmine</groupId>
            <artifactId>jredmine-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>publish-attachments</id>
                <goals>
                  <goal>update-version</goal>
                  <goal>publish-attachments</goal>
                </goals>
                <phase>validate</phase>
                <configuration>
                  <closeVersion>false</closeVersion>
                </configuration>
              </execution>
            </executions>

          </plugin>

        </plugins>

      </build>
    </profile>

  </profiles>
</project>
