<?xml version="1.0" encoding="UTF-8"?>
<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>dev.ikm.build</groupId>
        <artifactId>java-parent</artifactId>
        <version>1.47.0</version>
        <relativePath></relativePath>
    </parent>

    <groupId>dev.ikm.jpms</groupId>
    <artifactId>activej-bytebuf</artifactId>
    <packaging>jar</packaging>
    <name>Activej Bytebuf</name>
    <version>${activej.version}-${activej.release}</version>

    <licenses>
        <license>
            <name>The Apache Software License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <properties>
        <activej.version>4.3</activej.version>
        <!-- change release here-->
        <activej.release>r6</activej.release>
        <activej.common.version>4.3-r6</activej.common.version>
        <maven-assembly-plugin.version>3.3.0</maven-assembly-plugin.version>
        <maven.moditect.plugin>1.0.0.RC2</maven.moditect.plugin>
        <maven.antrun.plugin>3.1.0</maven.antrun.plugin>
    </properties>

    <dependencies>
        <!-- Include Transitive dependencies to project -->
        <dependency>
            <groupId>io.activej</groupId>
            <artifactId>activej-bytebuf</artifactId>
            <version>${activej.version}</version>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${basedir}/</directory>
                <includes>
                    <include>LICENSE.txt</include>
                </includes>
            </resource>
        </resources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.moditect</groupId>
                    <artifactId>moditect-maven-plugin</artifactId>
                    <version>${maven.moditect.plugin}</version>
                </plugin>

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

            </plugins>
        </pluginManagement>
        <plugins>
        <!-- Testing Javadoc plugin skip-->
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <skip>true</skip>
                    <failOnError>false</failOnError>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>sources</id>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>io.activej</groupId>
                                    <artifactId>activej-bytebuf</artifactId>
                                    <version>${activej.version}</version>
                                    <classifier>sources</classifier>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>io.activej</groupId>
                                    <artifactId>activej-bytebuf</artifactId>
                                    <version>${activej.version}</version>
                                    <classifier>javadoc</classifier>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                            <artifacts>
                                <artifact>
                                    <file>${project.build.directory}/dependency/${project.artifactId}-${activej.version}-sources.jar</file>
                                    <type>jar</type>
                                    <classifier>sources</classifier>
                                </artifact>
                                <artifact>
                                    <file>${project.build.directory}/dependency/${project.artifactId}-${activej.version}-javadoc.jar</file>
                                    <type>jar</type>
                                    <classifier>javadoc</classifier>
                                </artifact>
                            </artifacts>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.moditect</groupId>
                <artifactId>moditect-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-module-infos</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>add-module-info</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/moditect</outputDirectory>
                            <overwriteExistingFiles>true</overwriteExistingFiles>
                            <modules>
                                <module>
                                    <artifact>
                                        <groupId>io.activej</groupId>
                                        <artifactId>activej-bytebuf</artifactId>
                                        <version>${activej.version}</version>
                                     </artifact>
                                    <moduleInfoSource>
                                        open module io.activej.bytebuf {
                                            exports io.activej.bytebuf;

                                            requires io.activej.common;
                                        }
                                    </moduleInfoSource>
                                </module>
                            </modules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>rename-sources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="renaming sources file" />
                                <copy file="${project.build.directory}/dependency/${project.artifactId}-${activej.version}-sources.jar"
                                      tofile="${project.build.directory}/${project.artifactId}-${activej.version}-${activej.release}-sources.jar" />
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>rename-javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <echo message="renaming javadoc file" />
                                <copy file="${project.build.directory}/dependency/${project.artifactId}-${activej.version}-javadoc.jar"
                                      tofile="${project.build.directory}/${project.artifactId}-${activej.version}-${activej.release}-javadoc.jar" />
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>
                                <echo message="unzipping files" />
                                <unzip src="${project.build.directory}/moditect/${project.artifactId}-${activej.version}.jar"
                                       dest="${project.build.directory}/classes/" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
