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

    <artifactId>maven-settings-decoder</artifactId>
    <description>maven settings.xml decoder for gradle</description>
    <groupId>cn.home1.tools</groupId>
    <name>maven-settings-decoder</name>
    <packaging>pom</packaging>
    <url>https://github.com/ci-and-cd/maven-settings-decoder</url>
    <version>1.1.0</version>

    <ciManagement>
        <system>Travis CI</system>
        <url>https://travis-ci.org/ci-and-cd/maven-settings-decoder</url>
    </ciManagement>

    <developers>
        <developer>
            <name>Haolun Zhang</name>
            <url>https://github.com/chshawkn</url>
        </developer>
    </developers>

    <issueManagement>
        <system>GitHub Issues</system>
        <url>https://github.com/ci-and-cd/maven-settings-decoder/issues</url>
    </issueManagement>

    <licenses>
        <license>
            <name>MIT License</name>
            <url>http://www.opensource.org/licenses/mit-license.php</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <modules>
        <module>maven-settings-decoder-cipher</module>
        <module>maven-settings-decoder-cli</module>
        <module>maven-settings-decoder-core</module>
    </modules>

    <scm>
        <connection>scm:git:https://github.com/ci-and-cd/maven-settings-decoder.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/ci-and-cd/maven-settings-decoder.git</developerConnection>
        <url>https://github.com/ci-and-cd/maven-settings-decoder</url>
        <tag>HEAD</tag>
    </scm>

    <properties>
        <java.version>1.8</java.version>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <sonar.host.url>https://sonarqube.com</sonar.host.url>

        <version.maven-assembly-plugin>3.0.0</version.maven-assembly-plugin>
        <version.maven-compiler-plugin>3.5.1</version.maven-compiler-plugin>
        <version.maven-gpg-plugin>1.6</version.maven-gpg-plugin>
        <version.maven-jar-plugin>3.0.2</version.maven-jar-plugin>
        <version.maven-shade-plugin>2.4.3</version.maven-shade-plugin>
        <version.gitflow-maven-plugin>1.11.0</version.gitflow-maven-plugin>

        <version.commons-cli>1.3.1</version.commons-cli>
        <version.junit>4.12</version.junit>
        <version.logback>1.2.3</version.logback>
        <version.maven-settings>3.3.9</version.maven-settings>
        <version.plexus-cipher>1.7</version.plexus-cipher>
    </properties>

    <build>
        <plugins>
            <!-- see: https://github.com/KimJejun/gitflow-maven-plugin -->
            <plugin>
                <groupId>com.amashchenko.maven.plugin</groupId>
                <artifactId>gitflow-maven-plugin</artifactId>
                <configuration>
                    <tychoBuild>false</tychoBuild>

                    <installProject>false</installProject>
                    <verbose>false</verbose>

                    <gitFlowConfig>
                        <productionBranch>master</productionBranch>
                        <developmentBranch>develop</developmentBranch>
                        <featureBranchPrefix>feature/</featureBranchPrefix>
                        <releaseBranchPrefix>release/</releaseBranchPrefix>
                        <hotfixBranchPrefix>hotfix/</hotfixBranchPrefix>
                        <supportBranchPrefix>support/</supportBranchPrefix>
                        <versionTagPrefix>v</versionTagPrefix>
                    </gitFlowConfig>

                    <commitMessages>
                        <featureStartMessage>updating versions for feature branch</featureStartMessage>
                        <featureFinishMessage>updating versions for development branch</featureFinishMessage>

                        <hotfixStartMessage>updating versions for hotfix</hotfixStartMessage>
                        <hotfixFinishMessage>updating for next development version</hotfixFinishMessage>

                        <releaseStartMessage>updating versions for release</releaseStartMessage>
                        <releaseFinishMessage>updating for next development version</releaseFinishMessage>

                        <tagHotfixMessage>tagging hotfix</tagHotfixMessage>
                        <tagReleaseMessage>tagging release</tagReleaseMessage>
                    </commitMessages>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <compilerVersion>${java.version}</compilerVersion>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <showDeprecation>true</showDeprecation>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>com.amashchenko.maven.plugin</groupId>
                    <artifactId>gitflow-maven-plugin</artifactId>
                    <version>${version.gitflow-maven-plugin}</version>
                </plugin>
                <plugin><artifactId>maven-assembly-plugin</artifactId><version>${version.maven-assembly-plugin}</version></plugin>
                <plugin><artifactId>maven-compiler-plugin</artifactId><version>${version.maven-compiler-plugin}</version></plugin>
                <plugin><artifactId>maven-gpg-plugin</artifactId><version>${version.maven-gpg-plugin}</version></plugin>
                <plugin><artifactId>maven-jar-plugin</artifactId><version>${version.maven-jar-plugin}</version></plugin>
                <plugin><artifactId>maven-shade-plugin</artifactId><version>${version.maven-shade-plugin}</version></plugin>
            </plugins>
        </pluginManagement>
    </build>

    <dependencies>
        <dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><scope>test</scope></dependency>
        <dependency><groupId>junit</groupId><artifactId>junit</artifactId><scope>test</scope></dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency><groupId>${project.groupId}</groupId><artifactId>maven-settings-decoder-cipher</artifactId><version>${project.version}</version></dependency>
            <dependency><groupId>${project.groupId}</groupId><artifactId>maven-settings-decoder-core</artifactId><version>${project.version}</version></dependency>
            <dependency><groupId>ch.qos.logback</groupId><artifactId>logback-classic</artifactId><version>${version.logback}</version></dependency>
            <dependency><groupId>commons-cli</groupId><artifactId>commons-cli</artifactId><version>${version.commons-cli}</version></dependency>
            <dependency><groupId>org.apache.maven</groupId><artifactId>maven-settings</artifactId><version>${version.maven-settings}</version></dependency>
            <dependency><groupId>org.sonatype.plexus</groupId><artifactId>plexus-cipher</artifactId><version>${version.plexus-cipher}</version></dependency>

            <dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>${version.junit}</version></dependency>
        </dependencies>
    </dependencyManagement>

    <profiles>
        <profile>
            <id>gpg2-arguments</id>
            <activation><property><name>gpg.loopback</name><value>true</value></property></activation>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <configuration>
                            <gpgArguments>
                                <gpgArgument>--use-agent</gpgArgument>
                                <gpgArgument>--pinentry-mode</gpgArgument>
                                <gpgArgument>loopback</gpgArgument>
                            </gpgArguments>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>gpg-for-travis-and-maven-central</id>
            <activation><property><name>gpg.executable</name></property></activation>
            <properties>
                <!-- Do not set gpg.executable here -->
                <!--<gpg.executable>gpg</gpg.executable>-->
                <gpg.keyname>${env.CI_OPT_GPG_KEYNAME}</gpg.keyname>
                <gpg.passphrase>${env.CI_OPT_GPG_PASSPHRASE}</gpg.passphrase>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <executions>
                            <execution><id>sign-artifacts</id><phase>verify</phase><goals><goal>sign</goal></goals></execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>release-and-publish-to-ossrh</id>
            <activation>
                <activeByDefault>true</activeByDefault>
                <property><name>!release-and-publish-to-github</name></property>
            </activation>
            <distributionManagement>
                <repository>
                    <id>ossrh-staging</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
                </repository>
                <snapshotRepository>
                    <id>ossrh-snapshots</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.10.4</version>
                        <configuration>
                            <failOnError>false</failOnError>
                            <charset>${project.build.sourceEncoding}</charset>
                            <encoding>${project.build.sourceEncoding}</encoding>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>aggregate</id>
                                <goals>
                                    <goal>aggregate</goal>
                                </goals>
                                <phase>site</phase>
                                <configuration>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <!--https://maven.apache.org/plugins/maven-source-plugin/test-jar-no-fork-mojo.html-->
                                    <!--jar会执行此插件绑定的maven默认生命周期：@Execute( phase = LifecyclePhase.GENERATE_SOURCES )
                                    ，这里使用jar-no-fork避免这个问题  -->
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh-snapshots</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!--
        <![CDATA[
        Usage:
        1. Execute following command and put output (encrypted master password) into ~/.m2/settings-security.xml
           mvn -emp ${master_password}
        2. mvn -ep ${your_github_password}
        3. Put following content into ~/.m2/settings.xml
            <server>
                <id>github-${your_github_username}</id>
                <username>${your_github_account_email}</username>
                <password>{encrypted_your_github_password}</password>
            </server>
        4. To publish a release
           Following actions can be automated using the maven-release-plugin
             1. Commit any modifications
             2. Remove the -SNAPSHOT from the version number
             3. Deploy the module to the release-repository
             4. Tag the source code with the version number
             5. Increment the version number and append -SNAPSHOT
            see: https://dzone.com/articles/configuring-the-maven-release-plugin-to-skip-tests

              mvn -DpreparationGoals=compile -Darguments="" release:prepare
              mvn -Darguments="-DskipTests" release:perform

            Delete tag on release failed, see: https://www.abeautifulsite.net/how-to-delete-a-tag-on-github
            Example:
              git tag -d ${tag}
              git push origin :${tag}
        5. To publish a snapshot
           mvn -Dmaven.test.skip=true clean package deploy

        Note:
        Create a empty mvn-repo branch on github
        git checkout \-\-orphan mvn-repo
        git rm -rf .
        git commit \-\-allow-empty -m "root commit"
        git push origin mvn-repo

        Create gpg key on mac
        brew install gpg
        execute gpg \-\-list-keys to create trustdb.gpg
        gpg \-\-list-keys

        see: http://lijingsen.cn/2015/09/03/how-to-generate-gpg-signature-with-maven/
        see: https://www.gnupg.org/documentation/manuals/gnupg-devel/Unattended-GPG-key-generation.html
cat >maven_gpg_key_with_default_algorithms <<EOF
%echo Generating a default key
Key-Type: default
Subkey-Type: default
Name-Real: home1.cn
Name-Comment: with passphrase
Name-Email: opensource@home1.cn
Expire-Date: 0
Passphrase: passphrase
%pubring maven_gpg_key.pub
%secring maven_gpg_key.sec
# Do a commit here, so that we can later print "done" :-)
%commit
%echo done
EOF gpg2 \-\-batch \-\-gen-key maven_gpg_key_with_default_algorithms gpg \-\-allow-secret-key-import \-\-import ./maven_gpg_key.sec gpg \-\-import ./maven_gpg_key.pub # List public keys gpg \-\-list-keys # List private keys gpg \-\-list-secret-keys Put following content into ~/.m2/settings.xml To get gpg.keyname: gpg \-\-list-secret-keys | grep -E '^sec' | awk '{print $2}' | awk -F/ '{print $2}'
            gpg \-\-list-keys | grep -E '^pub' | awk '{print $2}' | awk -F/ '{print $2}'

        <servers>
            <server>
                <id>gpg.passphrase</id>
                <passphrase>${gpg.passphrase}</passphrase>
            </server>
        </servers>
        <profile>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <gpg.keyname>${gpg.keyname}</gpg.keyname>
            </properties>
        </profile>
        ]]>
        -->
        <profile>
            <id>release-and-publish-to-github</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property><name>release-and-publish-to-github</name></property>
            </activation>
            <properties>
                <!-- github server corresponds to entry in ~/.m2/settings.xml -->
                <github.global.server>github</github.global.server>
            </properties>
            <!-- see: http://stackoverflow.com/questions/14013644/hosting-a-maven-repository-on-github -->
            <distributionManagement>
                <repository>
                    <id>internal.repo</id>
                    <name>Temporary Staging Repository</name>
                    <url>file://${project.build.directory}/mvn-repo</url>
                </repository>
            </distributionManagement>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>2.5.3</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.apache.maven.scm</groupId>
                                <artifactId>maven-scm-provider-gitexe</artifactId>
                                <version>1.9.5</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <mavenExecutorId>forked-path</mavenExecutorId>
                            <goals>deploy</goals>
                            <useReleaseProfile>false</useReleaseProfile>
                            <arguments>${arguments}</arguments>
                        </configuration>
                    </plugin>
                    <plugin>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>2.8.2</version>
                        <configuration>
                            <altDeploymentRepository>internal.repo::default::file://${project.build.directory}/mvn-repo
                            </altDeploymentRepository>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.github.github</groupId>
                        <artifactId>site-maven-plugin</artifactId>
                        <version>0.12</version>
                        <configuration>
                            <!-- git commit message -->
                            <message>Maven artifacts for ${project.version}</message>
                            <merge>true</merge>
                            <!-- disable webpage processing -->
                            <noJekyll>true</noJekyll>
                            <!-- matches distribution management repository url above -->
                            <outputDirectory>${project.build.directory}/mvn-repo</outputDirectory>
                            <!-- remote branch name -->
                            <branch>refs/heads/mvn-repo</branch>
                            <includes>
                                <include>**/*</include>
                            </includes>
                            <!-- github repo name -->
                            <repositoryName>${project.artifactId}</repositoryName>
                            <!-- github username  -->
                            <repositoryOwner>ci-and-cd</repositoryOwner>
                        </configuration>
                        <executions>
                            <!-- run site-maven-plugin's 'site' target as part of the build's normal 'deploy' phase -->
                            <execution>
                                <goals>
                                    <goal>site</goal>
                                </goals>
                                <phase>deploy</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
