<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
    <artifactId>tika-ml</artifactId>
    <groupId>org.apache.tika</groupId>
    <version>4.0.0-alpha-1</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>

  <artifactId>tika-ml-chardetect</artifactId>
  <name>Apache Tika ML charset detector — training and evaluation tools</name>
  <description>
    Training, evaluation, and diagnostic tools for the ML charset detector.
    Runtime detector classes live in tika-encoding-detector-mojibuster.
    This module contains no production code; it is a tools-only module for
    developer use (corpus preparation, model training, accuracy evaluation).
  </description>

  <dependencies>
    <!-- Runtime deps for the tool classes (in src/main/java) -->
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-encoding-detector-mojibuster</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-parser-text-module</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>
    <!-- Icu4jEncodingDetector and UniversalEncodingDetector for baseline comparison -->
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-encoding-detector-icu4j</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-encoding-detector-universal</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>

    <!-- Test dependencies -->
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>org.apache.tika.ml.chardetect.tools</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <inputExcludes>
            <inputExclude>**/manifest.json</inputExclude>
            <inputExclude>src/test/python/anneal_log.csv</inputExclude>
            <inputExclude>README.md</inputExclude>
          </inputExcludes>
        </configuration>
      </plugin>
      <!-- Tools use System.out/printf freely — suppress forbidden-apis for this module -->
      <plugin>
        <groupId>de.thetaphi</groupId>
        <artifactId>forbiddenapis</artifactId>
        <configuration>
          <skip>true</skip>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <!--
        Build a self-contained fat JAR for model training and evaluation.
        Usage:
          ./mvnw package -pl tika-ml/tika-ml-chardetect -am -Ptrain -DskipTests \
              -Dmaven.repo.local=.local_m2_repo
          java -jar tika-ml/tika-ml-chardetect/target/tika-ml-chardetect-*-tools.jar \
              [TrainNaiveBayesBigram|EvalCharsetDetectors|BenchmarkCharsetDetectors|TrainUtf16Specialist] \
              [args...]
      -->
      <id>train</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <executions>
              <execution>
                <phase>package</phase>
                <goals><goal>shade</goal></goals>
                <configuration>
                  <shadedArtifactAttached>true</shadedArtifactAttached>
                  <shadedClassifierName>tools</shadedClassifierName>
                  <transformers>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                      <mainClass>org.apache.tika.ml.chardetect.tools.TrainNaiveBayesBigram</mainClass>
                    </transformer>
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                    <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer" />
                  </transformers>
                  <filters>
                    <filter>
                      <artifact>*:*</artifact>
                      <excludes>
                        <exclude>META-INF/*.SF</exclude>
                        <exclude>META-INF/*.DSA</exclude>
                        <exclude>META-INF/*.RSA</exclude>
                      </excludes>
                    </filter>
                  </filters>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <scm>
    <tag>4.0.0-alpha-1-rc1</tag>
  </scm>
</project>
