<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2006-2021 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">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.talend.sdk.component</groupId>
    <artifactId>component-server-parent</artifactId>
    <version>1.40.0</version>
  </parent>

  <artifactId>component-server</artifactId>

  <name>Component Runtime :: Server Parent :: Server</name>
  <description>The Web server of the framework. Mainly provides UI interaction hooks.</description>

  <properties>
    <talend.component.server.enableDumps>false</talend.component.server.enableDumps>
    <org.apache.tomcat.Logger>org.apache.meecrowave.logging.tomcat.Log4j2Log</org.apache.tomcat.Logger>
    <talend.build.name>${talend.build.name.base}.server</talend.build.name>
    <sample.beam.groupId>org.talend.sdk.components</sample.beam.groupId>
    <sample.beam.artifactId>sample-beam</sample.beam.artifactId>
    <sample.beam.location>${project.build.directory}${file.separator}lib</sample.beam.location>
    <talend.component.server.tomcat.valve.error.debug>false</talend.component.server.tomcat.valve.error.debug>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-manager</artifactId>
      <version>${project.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-annotation_1.3_spec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-json_1.1_spec</artifactId>
        </exclusion>
        <exclusion>
          <groupId>org.apache.geronimo.specs</groupId>
          <artifactId>geronimo-jsonb_1.0_spec</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- extends runtime manager with design time data -->
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-design-extension</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-server-api</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>vault-client</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>${commons-cli.version}</version>
    </dependency>
    <!-- override until we upgrade meecrowave -->
    <dependency>
      <groupId>org.apache.johnzon</groupId>
      <artifactId>johnzon-jsonb</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.meecrowave</groupId>
      <artifactId>meecrowave-core</artifactId>
      <version>${meecrowave.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.microprofile.config</groupId>
      <artifactId>microprofile-config-api</artifactId>
    </dependency>
    <!-- just to generate the openapi.json -->
    <dependency>
      <groupId>org.eclipse.microprofile.openapi</groupId>
      <artifactId>microprofile-openapi-api</artifactId>
      <version>${microprofile-openapi-api.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.config</groupId>
      <artifactId>geronimo-config-impl</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
      <version>${log4j2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-web</artifactId>
      <version>${log4j2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <version>${log4j2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <version>${log4j2.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-jul</artifactId>
      <version>${log4j2.version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-websocket</artifactId>
      <version>${tomcat.version}</version>
    </dependency>

    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-server-extension-api</artifactId>
      <version>${project.version}</version>
      <!-- all the stack must be provided -->
      <exclusions>
        <exclusion>
          <groupId>*</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.apache.meecrowave</groupId>
      <artifactId>meecrowave-junit</artifactId>
      <version>${meecrowave.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.tomee</groupId>
      <artifactId>ziplock</artifactId>
      <version>${ziplock.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-junit-base</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-features-logging</artifactId>
      <version>${cxf.version}</version>
      <scope>test</scope>
    </dependency>

    <!-- just here to ensure the reactor is well structured, but shouldnt be in the classpath! -->
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>sample-beam</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-beam</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>pl.project13.maven</groupId>
        <artifactId>git-commit-id-plugin</artifactId>
        <version>${git-commit-id-plugin.version}</version>
        <configuration>
          <generateGitPropertiesFile>true</generateGitPropertiesFile>
          <generateGitPropertiesFilename>${project.build.outputDirectory}/TALEND-INF/git.properties</generateGitPropertiesFilename>
        </configuration>
        <executions>
          <execution>
            <id>generate-the-git-infos</id>
            <goals>
              <goal>revision</goal>
            </goals>
            <phase>generate-resources</phase>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.geronimo</groupId>
        <artifactId>geronimo-openapi-maven-plugin</artifactId>
        <version>${geronimo-openapi.version}</version>
        <executions>
          <execution>
            <id>generate-openapi.json</id>
            <goals>
              <goal>openapi.json</goal>
            </goals>
            <configuration>
              <output>${project.build.outputDirectory}/META-INF/resources/documentation/openapi.json</output>
              <application>org.talend.sdk.component.server.front.TalendComponentApplication</application>
              <endpointClasses>
                <endpointClass>org.talend.sdk.component.server.front.ActionResourceImpl</endpointClass>
                <endpointClass>org.talend.sdk.component.server.front.BulkReadResourceImpl</endpointClass>
                <endpointClass>org.talend.sdk.component.server.front.ComponentResourceImpl</endpointClass>
                <endpointClass>org.talend.sdk.component.server.front.ConfigurationTypeResourceImpl</endpointClass>
                <endpointClass>org.talend.sdk.component.server.front.DocumentationResourceImpl</endpointClass>
                <endpointClass>org.talend.sdk.component.server.front.EnvironmentResourceImpl</endpointClass>
              </endpointClasses>
              <info>
                <version>1</version>
                <title>Talend Component Server</title>
                <description>UI related component server to provide metadata about component and callback for the forms.</description>
              </info>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${build-helper-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.outputDirectory}/META-INF/resources/documentation/openapi.json</file>
                  <type>json</type>
                  <classifier>openapi</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>${dependency-plugin.version}</version>
        <executions>
          <execution>
            <id>create-TALEND-INF/dependencies.txt</id>
            <goals>
              <goal>list</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <outputFile>${project.build.outputDirectory}/TALEND-INF/server/dependencies.txt</outputFile>
            </configuration>
          </execution>
          <execution>
            <id>import-redoc</id>
            <goals>
              <!-- otherwise .map are too fat for what we do of it -->
              <goal>unpack</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.webjars.npm</groupId>
                  <artifactId>redoc</artifactId>
                  <version>2.0.0-alpha.38</version>
                  <type>jar</type>
                  <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                  <includes>**/redoc.standalone.js</includes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>copy-beam-sample</id>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>generate-test-resources</phase>
            <configuration>
              <stripVersion>true</stripVersion>
              <artifactItems>
                <artifact>
                  <groupId>org.talend.sdk.component</groupId>
                  <artifactId>sample-beam</artifactId>
                  <version>${project.version}</version>
                  <type>jar</type>
                  <outputDirectory>${sample.beam.location}</outputDirectory>
                </artifact>
                <artifact>
                  <groupId>org.talend.sdk.component</groupId>
                  <artifactId>component-runtime-beam</artifactId>
                  <version>${project.version}</version>
                  <type>jar</type>
                  <outputDirectory>${sample.beam.location}/deps</outputDirectory>
                </artifact>
                <artifact>
                  <groupId>org.apache.beam</groupId>
                  <artifactId>beam-sdks-java-core</artifactId>
                  <version>${beam.version}</version>
                  <type>jar</type>
                  <outputDirectory>${sample.beam.location}/deps</outputDirectory>
                </artifact>
                <artifact>
                  <groupId>org.apache.avro</groupId>
                  <artifactId>avro</artifactId>
                  <version>${avro.version}</version>
                  <type>jar</type>
                  <outputDirectory>${sample.beam.location}/deps</outputDirectory>
                </artifact>
                <artifact>
                  <groupId>org.codehaus.jackson</groupId>
                  <artifactId>jackson-core-asl</artifactId>
                  <version>${avro-jackson.version}</version>
                  <type>jar</type>
                  <outputDirectory>${sample.beam.location}/deps</outputDirectory>
                </artifact>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>cleanup-TALEND-INF/dependencies.txt</id>
            <!-- cleanup asap -->
            <goals>
              <goal>run</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <target>
                <!-- TCOMP-1983 -->
                <replaceregexp byline="true" file="${project.build.outputDirectory}/TALEND-INF/server/dependencies.txt" match="(\u001B\[36m)?\s+--\s+module\s+.*$" replace=""/>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.meecrowave</groupId>
        <artifactId>meecrowave-maven-plugin</artifactId>
        <version>${meecrowave.version}</version>
        <configuration>
          <cdiConversation>false</cdiConversation>
          <watcherBouncing>-1</watcherBouncing>
          <scanningExcludes>apiguardian,brave,kafka,lz4,talend-icon,zipkin,container-core,component-runtime,beam,paranamer,joda-time,avro,objenesis,xz,snappy,component-spi,component-api,tomcat-websocket</scanningExcludes>
          <!--<webapp>${project.basedir}/src/dev/webapp</webapp>-->
          <!--
          <systemProperties>
            <talend.component.server.documentation.active>true</talend.component.server.documentation.active>
            <talend.component.server.tomcat.valve.error.debug>${talend.component.server.tomcat.valve.error.debug}</talend.component.server.tomcat.valve.error.debug>
            <talend.component.server.component.coordinates>${talend.component.server.component.coordinates.samples}</talend.component.server.component.coordinates>
          </systemProperties>
          -->
        </configuration>
        <executions>
          <execution>
            <id>bundle</id>
            <goals>
              <goal>bundle</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <attach>true</attach>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <executions>
          <execution>
            <id>default-test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <excludes>
                <exclude>**/beam/*Test.java</exclude>
              </excludes>
              <systemPropertyVariables>
                <org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>false</org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>
                <talend.component.server.enableDumps>${talend.component.server.enableDumps}</talend.component.server.enableDumps>
                <org.apache.tomcat.Logger>${org.apache.tomcat.Logger}</org.apache.tomcat.Logger>
              </systemPropertyVariables>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.talend.sdk.component:sample-beam</classpathDependencyExclude>
                <classpathDependencyExclude>org.talend.sdk.component:component-runtime-beam</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>beam-sample-test</id>
            <goals>
              <goal>test</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <includes>
                <include>**/beam/*Test.java</include>
              </includes>
              <systemPropertyVariables>
                <org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>false</org.apache.geronimo.config.configsource.SystemPropertyConfigSource.copy>
                <components.server.beam.active>true</components.server.beam.active>
                <components.sample.beam.groupId>${sample.beam.groupId}</components.sample.beam.groupId>
                <components.sample.beam.artifactId>${sample.beam.artifactId}</components.sample.beam.artifactId>
                <components.sample.beam.version>${project.version}</components.sample.beam.version>
                <components.sample.beam.location>${sample.beam.location}</components.sample.beam.location>
                <talend.component.server.enableDumps>${talend.component.server.enableDumps}</talend.component.server.enableDumps>
                <org.apache.tomcat.Logger>${org.apache.tomcat.Logger}</org.apache.tomcat.Logger>
              </systemPropertyVariables>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.talend.sdk.component:sample-beam</classpathDependencyExclude>
              </classpathDependencyExcludes>
              <additionalClasspathElements>
                <additionalClasspathElement>${sample.beam.location}${file.separator}deps${file.separator}beam-sdks-java-core.jar,
                  ${sample.beam.location}${file.separator}deps${file.separator}component-runtime-beam.jar,
                  ${sample.beam.location}${file.separator}deps${file.separator}jackson-core-asl.jar,
                  ${sample.beam.location}${file.separator}deps${file.separator}avro.jar</additionalClasspathElement>
              </additionalClasspathElements>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>travis</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemPropertyVariables>
                <component.server.test.logging.skip>true</component.server.test.logging.skip>
                <talend.component.server.enableDumps>${talend.component.server.enableDumps}</talend.component.server.enableDumps>
                <org.apache.tomcat.Logger>${org.apache.tomcat.Logger}</org.apache.tomcat.Logger>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
