<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2006-2025 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 model.getCategory())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-runtime</artifactId>
    <version>1.79.0</version>
  </parent>

  <artifactId>component-starter-server</artifactId>

  <name>Component Runtime :: Starter Server</name>
  <description>Web application allowing to generate maven or gradle project skeleton to speed up component development.</description>

  <properties>
    <!--TODO: bump node/npm when issue TCOMP-2059 Update talend/ui to 6.x will be done-->
    <node.version>v20.12.0</node.version>
    <npm.version>10.5.0</npm.version>
    <talend.build.name>${talend.build.name.base}.starter</talend.build.name>
    <rat.numUnapprovedLicenses>10</rat.numUnapprovedLicenses>
  </properties>

  <dependencies>
    <dependency>
      <!-- override until we upgrade meecrowave -->
      <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>
    <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>commons-cli</groupId>
      <artifactId>commons-cli</artifactId>
      <version>${commons-cli.version}</version>
    </dependency>

    <dependency>
      <groupId>com.github.spullara.mustache.java</groupId>
      <artifactId>compiler</artifactId>
      <version>0.9.6</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jgit</groupId>
      <artifactId>org.eclipse.jgit</artifactId>
      <version>${jgit.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.slf4j</groupId>
          <artifactId>slf4j-jdk14</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.rrd4j</groupId>
      <artifactId>rrd4j</artifactId>
      <version>3.7</version>
    </dependency>

    <dependency>
      <groupId>org.apache.meecrowave</groupId>
      <artifactId>meecrowave-junit</artifactId>
      <version>${meecrowave.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo.specs</groupId>
      <artifactId>geronimo-activation_1.1_spec</artifactId>
      <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.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit5.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-api</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <filtering>true</filtering>
        <directory>src/main/resources</directory>
        <includes>
          <include>starter-versions.properties</include>
        </includes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <excludes>
          <exclude>starter-versions.properties</exclude>
        </excludes>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-clean-plugin</artifactId>
        <version>${clean-plugin.version}</version>
        <executions>
          <execution>
            <id>clean-frontend</id>
            <goals>
              <goal>clean</goal>
            </goals>
            <phase>clean</phase>
            <configuration>
              <directory>${project.basedir}/src/main/frontend/dist</directory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <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.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <systemPropertyVariables>
            <java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>

            <talend.component.starter.autorefresh.active>false</talend.component.starter.autorefresh.active>
            <talend.component.starter.rrd.steps>1</talend.component.starter.rrd.steps>
            <talend.component.starter.rrd.synchronization.period>3</talend.component.starter.rrd.synchronization.period>
            <talend.component.starter.rrd.location>${project.build.directory}/test-workdir/rrd/stats.rrd</talend.component.starter.rrd.location>
            <talend.component.starter.rrd.export>${project.build.directory}/test-workdir/rrd/stats.xml</talend.component.starter.rrd.export>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.meecrowave</groupId>
        <artifactId>meecrowave-maven-plugin</artifactId>
        <version>${meecrowave.version}</version>
        <configuration>
          <httpPort>8080</httpPort>
          <webapp>${project.basedir}/src/main/frontend/dist</webapp>
          <webResourceCached>false</webResourceCached>
          <cdiConversation>false</cdiConversation>
          <watcherBouncing>-1</watcherBouncing>
          <properties>
            <!--
            <talend.component.starter.security.csp>default-src * 'unsafe-eval' 'unsafe-inline' data:; img-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline'; frame-ancestors 'none'</talend.component.starter.security.csp>
            -->
            <!-- for dev with livereload
            <talend.component.starter.security.csp>default-src 'self' data: http://localhost:35729/livereload.js; frame-ancestors 'none'</talend.component.starter.security.csp>
            -->
            <!-- to test in "dev" mode rrd - otherwise you need to wait a full step (in s)
            <talend.component.starter.rrd.steps>1</talend.component.starter.rrd.steps>
            <talend.component.starter.rrd.synchronization.period>3</talend.component.starter.rrd.synchronization.period>
            <talend.component.starter.rrd.location>${java.io.tmpdir}/starter-workdir/rrd/stats.rrd</talend.component.starter.rrd.location>
            <talend.component.starter.rrd.export>${java.io.tmpdir}/starter-workdir/rrd/export/stats.xml</talend.component.starter.rrd.export>
            -->
          </properties>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.apache.johnzon</groupId>
            <artifactId>johnzon-jsonb</artifactId>
            <version>${johnzon.version}</version>
          </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>
        </dependencies>
        <executions>
          <execution>
            <id>bundle</id>
            <goals>
              <goal>bundle</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <attach>true</attach>
            </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>prepare-package</phase>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.outputDirectory}/starter-versions.properties</file>
                  <type>properties</type>
                  <classifier>versions</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <!-- frontend build (nodejs), generated at prepare-package to be there for tests -->
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>${frontend.version}</version>
        <configuration>
          <installDirectory>${project.basedir}/.node</installDirectory>
          <workingDirectory>${project.basedir}/src/main/frontend</workingDirectory>
        </configuration>
        <executions>
          <execution>
            <id>install-node-and-npm</id>
            <goals>
              <goal>install-node-and-npm</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <nodeVersion>${node.version}</nodeVersion>
              <npmVersion>${npm.version}</npmVersion>
            </configuration>
          </execution>
          <execution>
            <id>npm-install</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <arguments>install</arguments>
            </configuration>
          </execution>
          <execution>
            <id>npm-build</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <arguments>run build</arguments>
              <skip>${component.starter.front.build.skip}</skip>
              <environmentVariables>
                <NODE_ENV>production</NODE_ENV>
                <GENERATE_SOURCEMAP>false</GENERATE_SOURCEMAP>
                <USE_LIVERELOAD>false</USE_LIVERELOAD>
              </environmentVariables>
            </configuration>
          </execution>
          <execution>
            <!-- mvn frontend:npm@watch -->
            <id>watch</id>
            <goals>
              <goal>npm</goal>
            </goals>
            <phase/>
            <configuration>
              <arguments>start</arguments>
              <environmentVariables>
                <GENERATE_SOURCEMAP>true</GENERATE_SOURCEMAP>
                <USE_LIVERELOAD>true</USE_LIVERELOAD>
                <NODE_ENV>production</NODE_ENV>
              </environmentVariables>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-web-resources</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/META-INF/resources</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}/src/main/frontend/dist</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.googlecode.maven-download-plugin</groupId>
        <artifactId>download-maven-plugin</artifactId>
        <version>${download-plugin.version}</version>
        <executions>
          <execution>
            <id>download-gradle</id>
            <goals>
              <goal>wget</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <url>https://services.gradle.org/distributions/gradle-${gradle.version}-bin.zip</url>
              <outputFileName>gradle-${gradle.version}.zip</outputFileName>
              <outputDirectory>${project.build.directory}</outputDirectory>
              <unpack>true</unpack>
              <cacheDirectory>${project.basedir}/.cache</cacheDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>${gmavenplus.version}</version>
        <configuration>
          <allowSystemExits>true</allowSystemExits>
          <scripts>
            <script>${project.basedir}/src/build/GrabGradleWrapper.groovy</script>
            <script>${project.basedir}/src/build/GrabMavenWrapper.groovy</script>
          </scripts>
          <properties>
            <gradleHome>${project.build.directory}/gradle-${gradle.version}</gradleHome>
            <mvnVersion>${mvn.version}</mvnVersion>
          </properties>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.eclipse.jgit</groupId>
            <artifactId>org.eclipse.jgit</artifactId>
            <version>${jgit.version}</version>
            <exclusions>
              <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>grab-gradle-wrapper</id>
            <goals>
              <goal>execute</goal>
            </goals>
            <phase>process-resources</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
