<?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/maven-v4_0_0.xsd">
    <parent>
        <artifactId>components</artifactId>
        <groupId>org.wso2.am.microgw</groupId>
        <version>3.0.2</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>org.wso2.micro.gateway.tools</artifactId>
    <name>Micro Gateway Tools</name>
    <packaging>pom</packaging>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>go-linux-build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>go</executable>
                            <workingDirectory>${basedir}/target</workingDirectory>
                            <arguments>
                                <argument>build</argument>
                                <argument>-o</argument>
                                <argument>${basedir}/target/go-tools/tools</argument>
                                <argument>main/go/tools</argument>
                            </arguments>
                            <environmentVariables>
                                <GOOS>linux</GOOS>
                                <GOARCH>amd64</GOARCH>
                                <GOPATH>${basedir}/</GOPATH>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>go-windows-build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>go</executable>
                            <workingDirectory>${basedir}/target</workingDirectory>
                            <arguments>
                                <argument>build</argument>
                                <argument>-o</argument>
                                <argument>${basedir}/target/go-tools/tools.exe</argument>
                                <argument>main/go/tools</argument>
                            </arguments>
                            <environmentVariables>
                                <GOOS>windows</GOOS>
                                <GOARCH>amd64</GOARCH>
                                <GOPATH>${basedir}/</GOPATH>
                            </environmentVariables>
                        </configuration>
                    </execution>
                    <execution>
                        <id>go-osx-build</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>go</executable>
                            <workingDirectory>${basedir}/target</workingDirectory>
                            <arguments>
                                <argument>build</argument>
                                <argument>-o</argument>
                                <argument>${basedir}/target/go-tools/tools-osx</argument>
                                <argument>main/go/tools</argument>
                            </arguments>
                            <environmentVariables>
                                <GOOS>darwin</GOOS>
                                <GOARCH>amd64</GOARCH>
                                <GOPATH>${basedir}/</GOPATH>
                            </environmentVariables>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>tools</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attached</goal>
                        </goals>
                        <configuration>
                            <descriptorSourceDirectory>${basedir}/assembly</descriptorSourceDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
