<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2021 - Yupiik SAS - https://www.yupiik.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>bundlebee</artifactId>
    <groupId>io.yupiik</groupId>
    <version>1.0.12</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>bundlebee-maven-plugin</artifactId>
  <packaging>maven-plugin</packaging>
  <name>BundleBee :: Maven Plugin</name>

  <properties>
    <mvn.version>3.6.3</mvn.version>
    <mvn-plugin.version>3.6.0</mvn-plugin.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.apache.maven.plugin-tools</groupId>
      <artifactId>maven-plugin-annotations</artifactId>
      <version>${mvn-plugin.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-plugin-api</artifactId>
      <version>${mvn.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.maven</groupId>
      <artifactId>maven-core</artifactId>
      <version>${mvn.version}</version>
      <scope>provided</scope>
      <exclusions>
        <exclusion> <!-- indeed we need it but we don't want CVE reported so since it is provided... -->
          <groupId>com.google.inject</groupId>
          <artifactId>guice</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>bundlebee-core</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.2.0</version>
        <configuration>
          <excludes>
            <exclude>**/build/**</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-mojo</id>
            <phase>compile</phase>
            <goals>
              <goal>java</goal>
            </goals>
            <configuration>
              <includePluginDependencies>true</includePluginDependencies>
              <mainClass>io.yupiik.bundlebee.maven.build.MojoGenerator</mainClass>
              <arguments>
                <argument>${project.parent.basedir}/bundlebee-core/target/classes</argument>
                <argument>${project.build.directory}/generated-sources/mojo</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>org.apache.xbean</groupId>
            <artifactId>xbean-finder-shaded</artifactId>
            <version>${xbean.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>compile</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>${project.build.directory}/generated-sources/mojo</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-generated-classes</id>
            <phase>process-classes</phase>
            <goals>
              <goal>compile</goal>
            </goals>
            <configuration>
              <compileSourceRoots>
                <compileSourceRoot>${project.build.directory}/generated-sources/mojo</compileSourceRoot>
              </compileSourceRoots>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>${mvn-plugin.version}</version>
        <executions>
          <execution>
            <id>default-descriptor</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>descriptor</goal>
              <goal>helpmojo</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <encoding>UTF-8</encoding>
          <goalPrefix>bundlebee</goalPrefix>
          <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-plugin-plugin</artifactId>
        <version>${mvn-plugin.version}</version>
      </plugin>
    </plugins>
  </reporting>
</project>
