<?xml version="1.0"?>
<!--
* © 2016 and later: Unicode, Inc. and others.
* License & terms of use: http://www.unicode.org/copyright.html
*******************************************************************************
* Copyright (C) 2010-2016, International Business Machines Corporation and    *
* others. All Rights Reserved.                                                *
*******************************************************************************
-->
<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>
    <groupId>com.ibm.icu</groupId>
    <artifactId>icu4j-root</artifactId>
    <version>73.1-SNAPSHOT</version>
    <!-- default relativePath for parent -->
  </parent>
  
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.ibm.icu</groupId>
  <artifactId>icu4j-charset</artifactId>
  <version>73.1-SNAPSHOT</version>

  <packaging>jar</packaging>

  <name> ICU4J Charset Provider</name>
  <description>icu4j-charset is a supplemental library for icu4j, implementing Java Charset SPI.</description>

  <properties>
    <!-- Bundle-SymbolicName -->
    <jar.symbolic.name>org.ibm.icu.charset</jar.symbolic.name>
  </properties>

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>

          <!-- add directories with main executable code -->
          <execution>
            <id>add-source</id>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>../../main/classes/charset/src</source>
              </sources>
            </configuration>
          </execution>
          
          <!-- add directories with test code -->
          <execution>
            <id>add-test-source</id>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>../../main/tests/charset/src</source>
                <source>../../main/tests/framework/src</source>
              </sources>
            </configuration>
          </execution>

          <!-- add directories with main executable resources -->
          <execution>
            <id>add-resource</id>
            <goals>
              <goal>add-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>../../main/classes/charset/src</directory>
                  <excludes>
                    <exclude>**/*.java</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>

          <!-- add directories with test resources -->
          <execution>
            <id>add-test-resource</id>
            <goals>
              <goal>add-test-resource</goal>
            </goals>
            <configuration>
              <resources>
                <resource>
                  <directory>../../main/tests/charset/src</directory>
                  <excludes>
                    <exclude>**/*.java</exclude>
                  </excludes>
                </resource>
                <resource>
                  <directory>../../main/tests/framework/src</directory>
                  <excludes>
                    <exclude>**/*.java</exclude>
                  </excludes>
                </resource>
              </resources>
            </configuration>
          </execution>


        </executions>
      </plugin>

      <!--
        Extract the resource files from the icu4j-datafiles dependency so that it is available during `test`.
        Note: The extraction here will not result in these files being included in the packaged jar.
      -->
      <plugin>
        <artifactId>maven-remote-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>process-remote-resources</id>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <resourceBundles>
                <resourceBundle>com.ibm.icu:icu4j-datafiles:${icu4j.version}</resourceBundle>
                <resourceBundle>com.ibm.icu:icu4j-test-datafiles:${icu4j.version}</resourceBundle>
              </resourceBundles>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!--
        Extract and unpack the *.cnv files + cnvalias.icu from the *.jar files in the upstream depenendency 
        `com.ibm.icu:icu4j-datafiles`.
      -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-dependencies</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>com.ibm.icu</includeGroupIds>
              <!-- exclude test resource files which come through dependencies as `provided` scope -->
              <excludeScope>provided</excludeScope>
              <includes>**/*.cnv,**/cnvalias.icu</includes>
              <excludes>**/*.jar</excludes>
              <outputDirectory>${project.build.directory}/classes</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!--
        Enable configuration of the Manifest file, etc. during the process of packaging the .jar file.

        For future reference: https://stackoverflow.com/questions/38548271/difference-between-maven-plugins-assembly-plugins-jar-plugins-shaded-plugi
      -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>

              <X-Compile-Source-JDK>${maven.compiler.source}</X-Compile-Source-JDK>
              <X-Compile-Target-JDK>${maven.compiler.target}</X-Compile-Target-JDK>

              <Specification-Title>${jar.spec.title}</Specification-Title>
              <Specification-Version>${jar.spec.version}</Specification-Version>
              <Specification-Vendor>${jar.spec.vendor}</Specification-Vendor>

              <Implementation-Title>${jar.impl.title}</Implementation-Title>
              <Implementation-Version>${jar.impl.version}</Implementation-Version>
              <Implementation-Vendor>${jar.impl.vendor}</Implementation-Vendor>
              <Implementation-Vendor-Id>${jar.impl.vendor.id}</Implementation-Vendor-Id>

              <Bundle-ManifestVersion>${jar.manifest.version}</Bundle-ManifestVersion>
              <Bundle-Name>${jar.name}</Bundle-Name>
              <Bundle-Description>${jar.description}</Bundle-Description>
              <Bundle-SymbolicName>${jar.symbolic.name}</Bundle-SymbolicName>
              <Bundle-Version>${jar.version}</Bundle-Version>
              <Bundle-Vendor>${jar.vendor}</Bundle-Vendor>
              <Bundle-Copyright>${jar.copyright.info}</Bundle-Copyright>

              <!-- TODO: We should remove this, right??? -->
              <Main-Class>${jar.main.class}</Main-Class>

            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>

    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>icu4j</artifactId>
    </dependency>

    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>icu4j-test-datafiles</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>com.ibm.icu</groupId>
      <artifactId>icu4j</artifactId>
      <version>${project.version}</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>

    <!-- this is for parameterized JUnit tests -->
    <dependency>
        <groupId>pl.pragmatists</groupId>
        <artifactId>JUnitParams</artifactId>
        <scope>test</scope>
    </dependency>

</dependencies>

</project>
