<?xml version="1.0" encoding="UTF-8"?>
<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you 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>org.apache.torque</groupId>
        <artifactId>torque</artifactId>
        <version>8.0-SNAPSHOT</version>
        <relativePath>..</relativePath>
    </parent>

    <artifactId>torque-build</artifactId>
    <packaging>pom</packaging>
    <name>Torque Build Example</name>
    <description>
        Reference Ant build module for Torque ORM code generation. Provides
        build-torque.xml and build.properties as a ready-to-use starting point
        for new Torque projects.
    </description>

    <dependencies>
        <!-- Runtime scope: copied to libs/ by maven-dependency-plugin -->
        <dependency>
            <groupId>org.apache.torque</groupId>
            <artifactId>torque-ant-tasks</artifactId>
            <version>${project.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.torque</groupId>
            <artifactId>torque-templates</artifactId>
            <version>${project.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.torque</groupId>
            <artifactId>torque-runtime</artifactId>
            <version>${project.version}</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Step 1: Copy all runtime dependencies into libs/ so build-torque.xml can use them -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.8.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeScope>runtime</includeScope>
                            <outputDirectory>${project.basedir}/libs</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Step 2: Run Ant generate + compile via the main target -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>clean-generated-sources</id>
                        <phase>clean</phase>
                        <configuration>
                            <target>
                                <!--  remove old generated sources -->
                                <echo message="Deleting directory src/main/generated-java" />
                                <delete dir="src/main/generated-java" />
                                <!--  remove old generated sources -->
                                <echo message="Deleting directory libs" />
                                <delete dir="libs" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>torque-generate</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <ant antfile="${basedir}/build-torque.xml" target="main"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!--resources>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
       </resources-->
    </build>

</project>
