<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <artifactId>cthul</artifactId>
        <groupId>org.cthul</groupId>
        <version>1.0</version>
    </parent>
    <groupId>org.cthul</groupId>
    <artifactId>cthul-matchers</artifactId>
    <version>1.0</version>
    <name>Cthul Matchers</name>
    <url>http://cthul.org</url>
    <description>
        Provides hamcrest.org matchers for strings and exceptions,
        allows matching code blocks, and provides several utilities for
        combining matchers.
    </description>
    <distributionManagement>
        <site>
            <id>cthul-matcher-maven-docs</id>
            <url>${project.url.docs}matcher/</url>
        </site>
    </distributionManagement>
    <properties>
        <generated-matcher-dir>${project.build.directory}/generated-sources/hamcrest</generated-matcher-dir>
    </properties>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
            </plugin>
        </plugins>    
    </build>
    <profiles>
        <profile>
            <id>gen-matcher</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>add-matcher-source</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>add-source</goal>
                                </goals>
                                <configuration>
                                    <sources>
                                        <source>${generated-matcher-dir}</source>
                                    </sources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>generate-matcher-dir</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <target>
                                        <mkdir dir="${generated-matcher-dir}"/>
                                    </target>
                                </configuration>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>1.2</version>
                        <executions>
                            <execution>
                                <id>generate-matchers-class</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <mainClass>org.hamcrest.generator.config.XmlConfigurator</mainClass>
                                    <includePluginDependencies>true</includePluginDependencies>
                                    <arguments>
                                        <argument>${project.build.sourceDirectory}/../hamcrest/CthulMatchers.xml</argument>
                                        <argument>${project.build.sourceDirectory}</argument>
                                        <argument>org.cthul.matchers.CthulMatchers</argument>
                                        <argument>${generated-matcher-dir}</argument>
                                    </arguments>
                                    <sourceRoot>${generated-matcher-dir}</sourceRoot>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.hamcrest</groupId>
                                <artifactId>hamcrest-generator</artifactId>
                                <version>${project.dependencies.hamcrest.version}</version>
                                <scope>runtime</scope>
                            </dependency>    
                        </dependencies>
                    </plugin>
                    <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>compile-generated-matchers</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>compile</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <dependencies>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-library</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.sf.twip</groupId>
            <artifactId>twip</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>
