<?xml version="1.0" encoding="UTF-8"?>
<!--
   Copyright 2012, 2021 International Business Machines Corp. and others

   See the NOTICE file distributed with this work for additional information
   regarding copyright ownership. 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.

   SPDX-License-Identifier: Apache-2.0
 -->
<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>jakarta.batch</groupId>
        <artifactId>tck-parent</artifactId>
        <version>2.1.0</version>
    </parent>

    <artifactId>com.ibm.jbatch.tck</artifactId>
    <packaging>jar</packaging>
    <name>Jakarta Batch TCK Core Test Artifacts</name>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.batch</groupId>
            <artifactId>jakarta.batch-api</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.ibm.jbatch</groupId>
            <artifactId>com.ibm.jbatch.spi</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.batch</groupId>
            <artifactId>com.ibm.jbatch.tck.spi</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.batch</groupId>
            <artifactId>com.ibm.jbatch.tck.ann</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.batch</groupId>
            <artifactId>com.ibm.jbatch.tck.ann.proc</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.enterprise</groupId>
            <artifactId>jakarta.enterprise.cdi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>jakarta.batch.tck.util</artifactId>
        </dependency>
    </dependencies>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-antrun-plugin</artifactId>
                    <executions>
                        <!-- By failing when the newly-generated batch.xml changes, we force someone to review
                             the changes.   We purposely don't want to make it too easy to introduce a change here,
                             since this will ultimately affect the pass/failing of implementations' runs against the TCK.
                             This will add as a guard that the person who would make the update knows what they're doing. -->
                        <execution>
                            <id>generate-batch.xml</id>
                            <goals>
                                <goal>run</goal>
                            </goals>
                            <phase>none</phase>
                            <configuration>
                                <target>
                                    <property name="original.batch.xml" value="${project.basedir}${fs}src${fs}main${fs}resources${fs}META-INF${fs}batch.xml" />
                                    <property name="generate.batch.xml.dir" value="${project.basedir}${fs}target${fs}generate-tck" />
                                    <mkdir dir="${generate.batch.xml.dir}" />
                                    <echo message="building ${generate.batch.xml.dir}/batch.xml" />
                                    <java classname="com.ibm.jbatch.tck.utils.BatchXMLGenerator">
                                        <arg value="${project.build.outputDirectory}" />
                                        <arg value="com${fs}ibm${fs}jbatch${fs}tck${fs}artifacts" />
                                        <arg value="${generate.batch.xml.dir}" />
                                        <classpath refid="maven.compile.classpath" />
                                        <classpath>
                                            <dirset dir="${project.build.outputDirectory}/com/ibm/jbatch/tck">
                                                <include name="artifacts utils" />
                                            </dirset>
                                        </classpath>
                                    </java>
                                    <!-- See comment above <execution> -->
                                    <fail message="Newly-generated ${generate.batch.xml.dir}${fs}batch.xml does not exactly match previous batch.xml at location: ${original.batch.xml}. Review carefully and if this is correct, then overwrite the old ${original.batch.xml} file with the newly-generated copy of batch.xml">
                                        <condition>
                                            <not>
                                                <filesmatch file1="${original.batch.xml}" file2="${generate.batch.xml.dir}${fs}batch.xml" textfile="true" />
                                            </not>
                                        </condition>
                                    </fail>
                                </target>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                  <archive>
                    <manifestFile>META-INF/MANIFEST.MF</manifestFile>
                  </archive>
              </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <excludePackageNames>com.ibm.jbatch.tck.tests.*</excludePackageNames>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>batchXML</id>
            <activation>
                <activeByDefault>false</activeByDefault>
                <property>
                    <name>batchXML</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-batch.xml</id>
                                <phase>process-classes</phase>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
