<?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-junkdetect</artifactId>
  <name>Apache Tika ML junk detector — runtime and training tools</name>
  <description>
    Language-agnostic text quality scorer that discriminates between clean UTF-8 text and
    mojibake, reversed text, wrong-codec decodings, and other corruption forms.
    Provides a standalone "languageyness" score suitable for re-OCR triggering and
    charset-decoding arbitration.

    Runtime classes (JunkDetector, ScriptDetector, feature extractors) and bundled model
    resources live here. Training and evaluation CLI tools live in the tools subpackage.
  </description>

  <dependencies>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-core</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-annotation-processor</artifactId>
      <version>4.0.0-alpha-1</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-ml-core</artifactId>
      <version>4.0.0-alpha-1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tika</groupId>
      <artifactId>tika-encoding-detector-mojibuster</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.junkdetect</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.rat</groupId>
        <artifactId>apache-rat-plugin</artifactId>
        <configuration>
          <inputExcludes>
            <inputExclude>**/*.bin</inputExclude>
            <inputExclude>**/*.txt</inputExclude>
          </inputExcludes>
        </configuration>
      </plugin>
      <!-- Tools package uses System.out/printf freely -->
      <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-junkdetect -am -Ptrain -DskipTests \
              -Dmaven.repo.local=.local_m2_repo
          java -jar tika-ml/tika-ml-junkdetect/target/tika-ml-junkdetect-*-tools.jar \
              [BuildJunkTrainingData|TrainJunkModel|EvalJunkDetector] \
              [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.junkdetect.tools.TrainJunkModel</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>
