<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>
  <parent>
    <artifactId>citrus-test-api-generator</artifactId>
    <groupId>org.citrusframework</groupId>
    <version>5.0.0-M2</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>citrus-openapi-codegen</artifactId>
  <packaging>jar</packaging>

  <name>Citrus :: Tools :: Test API Generator :: Codegen</name>
  <description>Generates a Citrus Test-API for OpenAPI and WSDL specifications.</description>

  <properties>
    <openapi-java-folder>${project.build.directory}/openapi-java-resources</openapi-java-folder>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-http</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-openapi</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-spring</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-ws</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-test-api-core</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>tools.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
    </dependency>
    <dependency>
      <groupId>org.openapitools</groupId>
      <artifactId>openapi-generator</artifactId>
      <version>${org.openapitools.version}</version>
    </dependency>
    <dependency>
      <groupId>wsdl4j</groupId>
      <artifactId>wsdl4j</artifactId>
    </dependency>

    <!-- Test scoped dependencies -->
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-groovy</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-junit-jupiter</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-validation-binary</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-validation-groovy</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-validation-json</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.citrusframework</groupId>
      <artifactId>citrus-validation-text</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-test</artifactId>
      <version>${spring.boot.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>commons-fileupload</groupId>
      <artifactId>commons-fileupload</artifactId>
      <version>1.6.0</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${maven.helper.plugin.version}</version>
        <executions>
          <execution>
            <id>add-generated-test-resources</id>
            <phase>generate-test-resources</phase>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>${project.build.directory}/generated-test-resources</directory>
                  <targetPath>${project.build.outputDirectory}</targetPath>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>add-generated-test-classes</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-test-sources</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${maven.dependency.plugin.version}</version>
        <configuration>
          <artifactItems>
            <artifactItem>
              <groupId>org.openapitools</groupId>
              <artifactId>openapi-generator</artifactId>
              <version>${org.openapitools.version}</version>
              <includes>
                Java/*Annotation*.mustache,Java/*Model*.mustache,Java/model*.mustache,Java/pojo*.mustache,Java/additional_properties.mustache,Java/enum_outer_doc.mustache,Java/nullable_var_annotations.mustache
              </includes>
            </artifactItem>
          </artifactItems>
          <outputDirectory>
            ${openapi-java-folder}
          </outputDirectory>
        </configuration>
        <executions>
          <execution>
            <id>unpack-java-templates</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>${maven.resource.plugin.version}</version>
        <executions>
          <execution>
            <id>prepare-java-templates</id>
            <phase>process-resources</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/java-citrus</outputDirectory>
              <resources>
                <resource>
                  <directory>
                    ${openapi-java-folder}/Java
                  </directory>
                  <includes>
                    <include>
                      *.mustache
                    </include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${org.openapitools.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.citrusframework</groupId>
            <artifactId>citrus-openapi-codegen</artifactId>
            <version>${project.version}</version>
          </dependency>
        </dependencies>
        <configuration>
          <configOptions>
            <apiType>REST</apiType>
            <resourceFolder>generated-test-resources</resourceFolder>
            <sourceFolder>generated-test-sources</sourceFolder>
            <useTags>true</useTags>
          </configOptions>
          <generateSupportingFiles>true</generateSupportingFiles>
          <generatorName>java-citrus</generatorName>
          <output>${project.build.directory}</output>
        </configuration>
        <executions>
          <execution>
            <id>generate-openapi-petstore-files</id>
            <phase>compile</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/test/resources/apis/petstore-v3.yaml</inputSpec>
              <configOptions>
                <invokerPackage>org.citrusframework.openapi.generator.rest.petstore</invokerPackage>
                <apiPackage>org.citrusframework.openapi.generator.rest.petstore.request</apiPackage>
                <modelPackage>org.citrusframework.openapi.generator.rest.petstore.model</modelPackage>
                <prefix>petStore</prefix>
                <apiEndpoint>petstore.endpoint</apiEndpoint>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>generate-openapi-petstore-extended-files</id>
            <phase>compile</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/test/resources/apis/petstore-extended-v3.yaml</inputSpec>
              <configOptions>
                <invokerPackage>org.citrusframework.openapi.generator.rest.extpetstore</invokerPackage>
                <apiPackage>org.citrusframework.openapi.generator.rest.extpetstore.request</apiPackage>
                <modelPackage>
                  org.citrusframework.openapi.generator.rest.extpetstore.model
                </modelPackage>
                <prefix>ExtPetStore</prefix>
                <apiEndpoint>extpetstore.endpoint</apiEndpoint>
              </configOptions>
            </configuration>
          </execution>
          <execution>
            <id>generate-openapi-files-for-soap</id>
            <phase>compile</phase>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/test/resources/apis/BookService-generated.yaml</inputSpec>
              <configOptions>
                <apiType>SOAP</apiType>
                <invokerPackage>org.citrusframework.openapi.generator.soap.bookservice</invokerPackage>
                <apiPackage>org.citrusframework.openapi.generator.soap.bookservice.request</apiPackage>
                <modelPackage>
                  org.citrusframework.openapi.generator.soap.bookservice.model
                </modelPackage>
                <prefix>BookService</prefix>
                <apiEndpoint>bookstore.endpoint</apiEndpoint>
              </configOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
