<project>
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>com.salesforce.functions</groupId>
    <artifactId>sf-fx-schema</artifactId>
    <version>1.0.0</version>
    <relativePath>..</relativePath>
  </parent>
  <artifactId>sf-fx-schema-go</artifactId>
  <packaging>pom</packaging>
  <name>com.salesforce.functions:sf-fx-schema-go</name>

  <properties>
    <gen-godir>${project.build.directory}/generated-sources/openapi</gen-godir>
  </properties>

  <dependencies>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>test-go</id>
            <phase>test</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <exec executable="go" dir="${project.basedir}" failonerror="true">
                  <arg value="test" />
                  <arg value="." />
                </exec>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>codegen</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.openapitools</groupId>
            <artifactId>openapi-generator-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>gen-go-openapi</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
                <configuration>
                  <inputSpec>${project.parent.basedir}/schema.json</inputSpec>
                  <output>${gen-godir}</output>
                  <generatorName>go</generatorName>
                  <disallowAdditionalPropertiesIfNotPresent>false</disallowAdditionalPropertiesIfNotPresent>
                  <packageName>sffxschema</packageName>
                  <packageVersion>${project.version}</packageVersion>
                  <templateDirectory>${basedir}/custom_template</templateDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
              <execution>
                <id>gen-go-openapi-clean</id>
                <phase>generate-sources</phase>
                <goals>
                  <goal>run</goal>
                </goals>
                <configuration>
                  <target>
                    <move todir="${project.basedir}">
                      <fileset dir="${gen-godir}"
                          includes="model_*.go" />
                    </move>
                  </target>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>cibuild</id>
      <build>
      </build>
    </profile>
  </profiles>

</project>
