<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (C) 2015 Red Hat, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<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">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>io.fabric8</groupId>
    <artifactId>kubernetes-model-generator</artifactId>
    <version>4.13.2</version>
  </parent>

  <artifactId>kubernetes-model-coordination</artifactId>
  <packaging>bundle</packaging>
  <name>Fabric8 :: Kubernetes Model :: Coordination</name>

  <properties>
    <clone-kube>true</clone-kube>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-model-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-model-common</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.jsonschema2pojo</groupId>
        <artifactId>jsonschema2pojo-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <configuration>
              <target>
                <echo>removing the duplicate generated class</echo>
                <delete file="${project.build.directory}/generated-sources/io/fabric8/kubernetes/api/model/coordination/v1/LeaseSpec.java" verbose="true" />
                <delete verbose="true">
                  <fileset dir="${project.build.directory}/generated-sources">
                    <include name="*.java" />
                  </fileset>
                </delete>
              </target>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${maven.bundle.plugin.version}</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
            <Import-Package>*</Import-Package>
            <Export-Package>
              io.fabric8.kubernetes.api.model.coordination**
            </Export-Package>
            <Include-Resource>
              {maven-resources},
              /META-INF/jandex.idx=target/classes/META-INF/jandex.idx,
              /coordination.properties=target/classes/coordination.properties,
            </Include-Resource>
          </instructions>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${maven.buildhelper.plugin.version}</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.outputDirectory}/schema/kube-schema.json</file>
                  <type>json</type>
                  <classifier>schema</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>java9-plus</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <dependencies>
        <dependency>
          <groupId>javax.annotation</groupId>
          <artifactId>javax.annotation-api</artifactId>
          <version>1.3.2</version>
        </dependency>
        <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>2.3.0</version>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jsonschema2pojo</groupId>
            <artifactId>jsonschema2pojo-maven-plugin</artifactId>
            <version>${jsonschema2pojo.version}</version>
            <configuration>
              <sourcePaths>
                <sourcePath>${project.basedir}/src/main/resources/schema/kube-schema.json</sourcePath>
              </sourcePaths>
              <targetPackage>io.fabric8.kubernetes.api.model</targetPackage>
              <includeConstructors>true</includeConstructors>
              <includeJsr303Annotations>false</includeJsr303Annotations>
              <includeToString>false</includeToString>
              <includeHashcodeAndEquals>false</includeHashcodeAndEquals>
              <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
              <customAnnotator>io.fabric8.kubernetes.annotator.KubernetesTypeAnnotator</customAnnotator>
              <annotationStyle>none</annotationStyle>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
            <dependencies>
              <dependency>
                <groupId>io.fabric8</groupId>
                <artifactId>kubernetes-model-annotator</artifactId>
                <version>${project.version}</version>
              </dependency>
              <dependency>
                <groupId>javax.annotation</groupId>
                <artifactId>javax.annotation-api</artifactId>
                <version>1.3.2</version>
              </dependency>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
