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

    <groupId>com.github.shyiko</groupId>
    <artifactId>ktlint</artifactId>
    <version>0.1.2</version>

    <name>ktlint</name>
    <description>Kotlin linter</description>
    <url>https://github.com/shyiko/ktlint</url>
    <licenses>
        <license>
            <name>MIT</name>
            <url>https://opensource.org/licenses/MIT</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    <scm>
        <connection>scm:git:git@github.com:shyiko/ktlint.git</connection>
        <developerConnection>scm:git:git@github.com:shyiko/ktlint.git</developerConnection>
        <url>git@github.com:shyiko/ktlint.git</url>
    </scm>
    <developers>
        <developer>
            <id>shyiko</id>
            <email>stanley.shyiko@gmail.com</email>
            <name>Stanley Shyiko</name>
        </developer>
    </developers>
    <distributionManagement>
        <repository>
            <id>maven-central</id>
            <name>Sonatype Nexus Staging</name>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
    </distributionManagement>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <kotlin.version>1.0.3</kotlin.version>
        <jgit.version>2.1.0.201209190230-r</jgit.version>
        <args4j.version>2.33</args4j.version>
        <testng.version>6.8.21</testng.version>
        <assertj.version>1.7.1</assertj.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib</artifactId>
            <version>${kotlin.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-compiler-embeddable</artifactId>
            <version>${kotlin.version}</version>
        </dependency>
        <dependency>
            <groupId>args4j</groupId>
            <artifactId>args4j</artifactId>
            <version>${args4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>${testng.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>${assertj.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>central</id>
            <name>bintray</name>
            <url>http://jcenter.bintray.com</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>bintray</name>
            <url>http://jcenter.bintray.com</url>
        </pluginRepository>
    </pluginRepositories>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>kotlin-maven-plugin</artifactId>
                <groupId>org.jetbrains.kotlin</groupId>
                <version>${kotlin.version}</version>
                <executions>
                    <execution>
                        <id>compile</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>test-compile</id>
                        <phase>process-test-sources</phase>
                        <goals>
                            <goal>test-compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.0.2</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <!-- for class.getPackage().getImplementationVersion() -->
                            <Implementation-Version>${project.version}</Implementation-Version>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.7</version>
                <executions>
                    <execution>
                        <id>ktlint</id>
                        <phase>verify</phase>
                        <configuration>
                            <target name="ktlint">
                                <java dir="${basedir}"
                                      classname="com.github.shyiko.ktlint.Main"
                                      classpathref="maven.runtime.classpath"
                                      fork="true"
                                      failonerror="true"
                                      taskname="lint">
                                    <arg value="src/**/*.kt"/>
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>ktlint-format</id>
                        <configuration>
                            <target name="ktlint">
                                <java dir="${basedir}"
                                      classname="com.github.shyiko.ktlint.Main"
                                      classpathref="maven.runtime.classpath"
                                      fork="true"
                                      failonerror="true"
                                      taskname="format">
                                    <arg value="-F"/>
                                    <arg value="src/**/*.kt"/>
                                </java>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.shyiko.usage-maven-plugin</groupId>
                <artifactId>usage-maven-plugin</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <usage>
                        # build "./target/ktlint" (executable jar)
                        ./mvnw -Pcapsule clean package -Dmaven.test.skip=true

                        # test (&amp; check code style)
                        ./mvnw clean verify

                        # publish a new version
                        ./mvnw versions:set -DnewVersion=&lt;version&gt;
                        ./mvnw -Ddeploy=maven-central
                        ./mvnw -Ddeploy=github
                        ./mvnw -Ddeploy=homebrew
                    </usage>
                </configuration>
            </plugin>
        </plugins>
        <extensions>
            <extension>
                <groupId>com.github.shyiko.servers-maven-extension</groupId>
                <artifactId>servers-maven-extension</artifactId>
                <version>1.3.0</version>
            </extension>
            <extension>
                <groupId>com.github.shyiko.usage-maven-plugin</groupId>
                <artifactId>usage-maven-plugin</artifactId>
                <version>1.0.0</version>
            </extension>
        </extensions>
    </build>

    <profiles>
        <profile>
            <id>deploy-to-maven-central</id>
            <activation>
                <property>
                    <name>deploy</name>
                    <value>maven-central</value>
                </property>
            </activation>
            <build>
                <defaultGoal>clean deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.0.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>3.0.2</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <classifier>javadoc</classifier>
                                    <classesDirectory>${basedir}/javadoc</classesDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.7</version>
                        <extensions>true</extensions>
                        <configuration>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <serverId>maven-central</serverId>
                            <skipStagingRepositoryClose>true</skipStagingRepositoryClose>
                            <!--<autoReleaseAfterClose>true</autoReleaseAfterClose>-->
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>capsule</id>
            <activation>
                <property>
                    <name>deploy</name>
                    <value>github</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>2.4.3</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <transformers>
                                        <transformer implementation=
                                                         "org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                        <transformer implementation=
                                                         "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>com.github.shyiko.ktlint.Main</mainClass>
                                        </transformer>
                                    </transformers>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <!--<minimizeJar>true</minimizeJar>-->
                                    <filters>
                                        <filter>
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                        <filter>
                                            <artifact>org.jetbrains.kotlin:kotlin-compiler-embeddable</artifact>
                                            <includes>
                                                <include>**</include>
                                            </includes>
                                        </filter>
                                    </filters>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.skife.maven</groupId>
                        <artifactId>really-executable-jar-maven-plugin</artifactId>
                        <version>1.4.1</version>
                        <configuration>
                            <!--
                            -XX:+TieredCompilation can be used to speed things up but it was reported to cause
                            OOMs and all sort of problems depending on which version of jre6 is used
                            -->
                            <flags>-Xmx512m</flags>
                            <programFile>ktlint</programFile>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>really-executable-jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>deploy-to-github</id>
            <activation>
                <property>
                    <name>deploy</name>
                    <value>github</value>
                </property>
            </activation>
            <build>
                <defaultGoal>clean deploy</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-shade-plugin</artifactId>
                        <version>2.4.3</version>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>shade</goal>
                                </goals>
                                <configuration>
                                    <transformers>
                                        <transformer implementation=
                                            "org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                        <transformer implementation=
                                            "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                            <mainClass>com.github.shyiko.ktlint.Main</mainClass>
                                        </transformer>
                                    </transformers>
                                    <shadedArtifactAttached>true</shadedArtifactAttached>
                                    <createDependencyReducedPom>false</createDependencyReducedPom>
                                    <!--<minimizeJar>true</minimizeJar>-->
                                    <filters>
                                        <filter>
                                            <artifact>*:*</artifact>
                                            <excludes>
                                                <exclude>META-INF/*.SF</exclude>
                                                <exclude>META-INF/*.DSA</exclude>
                                                <exclude>META-INF/*.RSA</exclude>
                                            </excludes>
                                        </filter>
                                        <filter>
                                            <artifact>org.jetbrains.kotlin:kotlin-compiler-embeddable</artifact>
                                            <includes>
                                                <include>**</include>
                                            </includes>
                                        </filter>
                                    </filters>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.skife.maven</groupId>
                        <artifactId>really-executable-jar-maven-plugin</artifactId>
                        <version>1.4.1</version>
                        <configuration>
                            <!--
                            -XX:+TieredCompilation can be used to speed things up but it was reported to cause
                            OOMs and all sort of problems depending on which version of jre6 is used
                            -->
                            <flags>-Xmx512m</flags>
                            <programFile>ktlint</programFile>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>package</phase>
                                <goals>
                                    <goal>really-executable-jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>de.jutzig</groupId>
                        <artifactId>github-release-plugin</artifactId>
                        <version>1.1.1</version>
                        <configuration>
                            <description>${project.version}</description>
                            <releaseName>${project.version}</releaseName>
                            <tag>${project.version}</tag>
                            <artifact>${project.build.directory}/${project.artifactId}</artifact>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>release</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>deploy-to-homebrew</id>
            <activation>
                <property>
                    <name>deploy</name>
                    <value>homebrew</value>
                </property>
            </activation>
            <build>
                <defaultGoal>antrun:run</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.7</version>
                        <configuration>
                            <target name="deploy-to-homebrew">
                                <exec executable="${project.basedir}/.deploy-to-homebrew" failonerror="true">
                                    <env key="VERSION" value="${project.version}"/>
                                    <env key="GITHUB_TOKEN" value="${settings.servers.github.privateKey}"/>
                                </exec>
                            </target>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
