<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2006-2018 Talend Inc. - www.talend.com
   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/xsd/maven-4.0.0.xsd">
  <parent>
    <artifactId>component-runtime</artifactId>
    <groupId>org.talend.sdk.component</groupId>
    <version>0.0.1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>talend-component-maven-plugin</artifactId>
  <name>Component Runtime :: Maven Plugin</name>
  <packaging>maven-plugin</packaging>
  <description>Provides Talend Component Kit Tools wrapped as Maven Mojos.</description>

  <properties>
    <components.version>0.19.7</components.version>

    <invoker.streamLogs>true</invoker.streamLogs>

    <talend.build.name>${talend.build.name.base}.maven</talend.build.name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-tools</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency> <!-- extends runtime manager with design time data -->
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-design-extension</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>3.5</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${mvn.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>${mvn.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-jsonb_1.0_spec</artifactId>
      <version>${jsonb-api.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-json_1.1_spec</artifactId>
      <version>${jsonp-api.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.johnzon</groupId>
      <artifactId>johnzon-jsonb</artifactId>
      <version>${johnzon.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.xmlgraphics</groupId>
      <artifactId>batik-codec</artifactId>
      <version>${batik.version}</version>
      <exclusions>
        <exclusion>
          <groupId>xml-apis</groupId>
          <artifactId>xml-apis</artifactId>
        </exclusion>
        <exclusion>
          <groupId>xalan</groupId>
          <artifactId>xalan</artifactId>
        </exclusion>
        <exclusion>
          <groupId>xerces</groupId>
          <artifactId>xercesImpl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-compress</artifactId>
      <version>1.14</version>
    </dependency>
    <dependency>
      <groupId>org.freemarker</groupId>
      <artifactId>freemarker</artifactId>
      <version>2.3.27-incubating</version>
    </dependency>

    <dependency>
      <groupId>org.apache.xbean</groupId>
      <artifactId>xbean-finder-shaded</artifactId>
      <version>${xbean.version}</version>
    </dependency>

    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-tools-webapp</artifactId>
      <version>${project.version}</version>
    </dependency>

    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-di</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>3.5</version>
        <executions>
          <execution>
            <id>mojo-descriptor</id>
            <goals>
              <goal>descriptor</goal>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <goalPrefix>talend-component</goalPrefix>
          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.plexus</groupId>
        <artifactId>plexus-component-metadata</artifactId>
        <version>1.7.1</version>
        <executions>
          <execution>
            <goals>
              <goal>generate-metadata</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${dependency-plugin.version}</version>
        <executions>
          <execution>
            <id>retrieve-component-xsd</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.talend.studio</groupId>
                  <artifactId>org.talend.model</artifactId>
                  <version>6.5.0-M1</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/unpacked</outputDirectory>
                  <includes>**/Component.xsd</includes>
                </artifactItem>
                <artifactItem>
                  <groupId>org.talend.ui</groupId>
                  <artifactId>talend-icon</artifactId>
                  <version>${talend-ui.version}</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <includes>icons/*.svg</includes>
                </artifactItem>
                <artifactItem>
                  <groupId>org.eclipse.emf</groupId>
                  <artifactId>org.eclipse.emf.ecore</artifactId>
                  <version>2.12.0</version>
                  <type>jar</type>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/unpacked</outputDirectory>
                  <includes>**/Ecore.xsd</includes> <!-- EcoreXMI.xsd, XMI.xsd, XMLNamespace.xsd, XMLType.xsd -->
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>${gmavenplus.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>${groovy.version}</version>
            <scope>runtime</scope>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>replace-emf-imports</id>
            <phase>process-resources</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <allowSystemExits>true</allowSystemExits>
              <scripts>
                <script>
                  <![CDATA[
def file = new java.io.File(project.build.directory, 'unpacked/model/Component.xsd')
file.write(file.text
  .replace('platform:/plugin/org.eclipse.emf.ecore/model/', '') // local resolution
  .replace('_._type', '')) // right naming in jaxb
]]>
                </script>
              </scripts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jaxb2-maven-plugin</artifactId>
        <version>2.2</version>
        <executions>
          <execution>
            <id>xjc</id>
            <phase>process-resources</phase>
            <goals>
              <goal>xjc</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <packageName>org.talend.sdk.component.maven.legacy.model</packageName>
          <sources>
            <source>${project.build.directory}/unpacked/model</source>
          </sources>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-invoker-plugin</artifactId>
        <version>2.0.0</version>
        <executions>
          <execution>
            <id>integration-test</id>
            <goals>
              <goal>install</goal>
              <goal>run</goal>
            </goals>
            <configuration>
              <showErrors>true</showErrors>
              <projectsDirectory>src/it</projectsDirectory>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <settingsFile>src/it/settings.xml</settingsFile>
              <pomIncludes>
                <pomInclude>*/pom.xml</pomInclude>
              </pomIncludes>
              <goals>
                <goal>clean</goal>
                <goal>verify</goal>
              </goals>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>3.5</version>
      </plugin>
    </plugins>
  </reporting>
</project>
