<commit_before><?xml version="1.0" encoding="UTF-8"?>
<!--
 * 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 name="Policeman's Forbidden API Checker" default="jar"
  xmlns:artifact="antlib:org.apache.maven.artifact.ant"
  xmlns:ivy="antlib:org.apache.ivy.ant"
  xmlns:au="antlib:org.apache.ant.antunit"
>
  <fail message="Minimum supported ANT version is 1.8.0. Yours: ${ant.version}">
    <condition>
      <not><antversion atleast="1.8.0" /></not>
    </condition>
  </fail>

  <condition property="tests.supported">
    <or>
      <equals arg1="${ant.java.version}" arg2="1.5"/>
      <equals arg1="${ant.java.version}" arg2="1.6"/>
      <equals arg1="${ant.java.version}" arg2="1.7"/>
      <!-- JDK 8 is currently not supported because ASM cannot load modified class file format -->
    </or>
  </condition>

  <property file="${user.home}/build.properties" />
  <property file="build.properties" />

  <property name="jdk.version" value="1.5"/>

  <property name="compile.debug" value="true"/>
  <property name="compile.deprecation" value="true"/>

  <property name="ivy.logging" value="download-only"/>
  <property name="maven.version" value="2.2.1"/>

  <property name="signatures.dir" location="src/main/resources/de/thetaphi/forbiddenapis/signatures"/>

  <!-- define Maven coordinates -->
  <property name="groupId" value="de.thetaphi" />
  <property name="artifactId" value="forbiddenapis" />
  <property name="version" value="1.0-SNAPSHOT"/>

  <!-- define artifacts' name, which follows the convention of Maven -->
  <property name="jar-file" location="dist/${artifactId}-${version}.jar" />
  <property name="sources-jar-file" location="dist/${artifactId}-${version}-sources.jar" />

  <!-- defined maven snapshots and staging repository id and url -->
  <property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
  <property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
  <property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
  <property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />

  <target name="-init">
    <ivy:cachepath pathid="path.build" conf="build" log="${ivy.logging}"/>
    <ivy:cachepath pathid="path.junit" conf="test" log="${ivy.logging}"/>
    <path id="path.run">
      <path refid="path.build"/>
      <pathelement path="build/main"/>
    </path>
    <path id="path.tools-run">
      <path refid="path.build"/>
      <pathelement path="build/tools"/>
    </path>
    <path id="path.test-build">
      <path refid="path.run"/>
      <path refid="path.junit"/>
    </path>
    <path id="path.test-run">
      <path refid="path.test-build"/>
      <pathelement path="build/test"/>
    </path>
  </target>

  <target name="-install-tasks" unless="installed.tasks">
    <ivy:cachepath pathid="path.tasks" conf="buildtools" log="${ivy.logging}"/>
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="path.tasks"/>
    <taskdef uri="antlib:org.apache.maven.artifact.ant" classpathref="path.tasks"/>
    <property name="installed.tasks" value="true"/>
  </target>

  <macrodef name="compile">
    <attribute name="module"/>
    <attribute name="classpathref"/>
    <sequential>
      <mkdir dir="build/@{module}"/>
      <copy todir="build/@{module}">
        <fileset dir="src/@{module}/resources" erroronmissingdir="false" />
      </copy>
      <javac includeantruntime="false" srcdir="src/@{module}/java" destdir="build/@{module}"
        source="${jdk.version}" target="${jdk.version}"
        debug="${compile.debug}" deprecation="${compile.deprecation}">
         <classpath refid="@{classpathref}"/>
         <compilerarg value="-Xlint"/>
      </javac>
    </sequential>
  </macrodef>

  <target name="compile" depends="-init" description="Compile">
    <compile module="main" classpathref="path.build"/>
  </target>

  <target name="compile-test" depends="compile" description="Compile tests">
    <compile module="test" classpathref="path.test-build"/>
  </target>

  <target name="compile-tools" depends="-init" description="Compile tools">
    <compile module="tools" classpathref="path.build"/>
  </target>

  <target name="clean" description="Clean">
    <delete dir="build"/>
    <delete dir="dist"/>
  </target>

  <target name="-maven-setup">
    <mkdir dir="build/maven"/>
    <copy todir="build/maven" encoding="UTF-8" outputencoding="UTF-8">
      <fileset dir="src/main/maven"/>
      <filterset>
        <filter token="NAME" value="${ant.project.name}"/>
        <filter token="VERSION" value="${version}"/>
        <filter token="GROUPID" value="${groupId}"/>
        <filter token="ARTIFACTID" value="${artifactId}"/>
      </filterset>
    </copy>
  </target>

  <target name="maven-descriptor" depends="-maven-setup,-install-tasks" description="Creates the Maven Plugin Descriptor">
    <!-- with fork=false this somehow takes endless to download the internet, so let's fork - and slow down -->
    <artifact:mvn pom="build/maven/pom.xml" mavenVersion="${maven.version}" failonerror="true" fork="true">
      <arg value="org.apache.maven.plugins:maven-plugin-plugin:2.9:descriptor"/>
      <sysproperty key="injected.src.dir" file="src/main/java"/>
      <sysproperty key="injected.target.dir" file="build/main"/>
    </artifact:mvn>
  </target>

  <target name="jar" depends="compile,-install-tasks,maven-descriptor" description="Create the binary JAR">
    <ivy:cachefileset setid="fileset.bundle" conf="bundle" log="${ivy.logging}"/>
    <mkdir dir="dist"/>
    <jarjar destfile="${jar-file}">
      <zipfileset dir="build/main"/>
      <zipfileset dir="build/maven" includes="pom.xml,pom.properties" prefix="META-INF/maven/${groupId}/${artifactId}"/>
      <restrict>
        <name name="**/*.class" handledirsep="true"/>
        <archives>
          <zips><fileset refid="fileset.bundle"/></zips>
        </archives>
      </restrict>
      <keep pattern="de.thetaphi.forbiddenapis.AntTask"/>
      <keep pattern="de.thetaphi.forbiddenapis.Mojo"/>
      <rule pattern="org.objectweb.asm.**" result="de.thetaphi.forbiddenapis.asm.@1"/>
      <manifest><commit_msg>Add uptodate task to not regenerate plugin.xml all the time<commit_after><?xml version="1.0" encoding="UTF-8"?>
<!--
 * 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 name="Policeman's Forbidden API Checker" default="jar"
  xmlns:artifact="antlib:org.apache.maven.artifact.ant"
  xmlns:ivy="antlib:org.apache.ivy.ant"
  xmlns:au="antlib:org.apache.ant.antunit"
>
  <fail message="Minimum supported ANT version is 1.8.0. Yours: ${ant.version}">
    <condition>
      <not><antversion atleast="1.8.0" /></not>
    </condition>
  </fail>

  <condition property="tests.supported">
    <or>
      <equals arg1="${ant.java.version}" arg2="1.5"/>
      <equals arg1="${ant.java.version}" arg2="1.6"/>
      <equals arg1="${ant.java.version}" arg2="1.7"/>
      <!-- JDK 8 is currently not supported because ASM cannot load modified class file format -->
    </or>
  </condition>

  <property file="${user.home}/build.properties" />
  <property file="build.properties" />

  <property name="jdk.version" value="1.5"/>

  <property name="compile.debug" value="true"/>
  <property name="compile.deprecation" value="true"/>

  <property name="ivy.logging" value="download-only"/>
  <property name="maven.version" value="2.2.1"/>

  <property name="signatures.dir" location="src/main/resources/de/thetaphi/forbiddenapis/signatures"/>

  <!-- define Maven coordinates -->
  <property name="groupId" value="de.thetaphi" />
  <property name="artifactId" value="forbiddenapis" />
  <property name="version" value="1.0-SNAPSHOT"/>

  <!-- define artifacts' name, which follows the convention of Maven -->
  <property name="jar-file" location="dist/${artifactId}-${version}.jar" />
  <property name="sources-jar-file" location="dist/${artifactId}-${version}-sources.jar" />

  <!-- defined maven snapshots and staging repository id and url -->
  <property name="maven-snapshots-repository-id" value="sonatype-nexus-snapshots" />
  <property name="maven-snapshots-repository-url" value="https://oss.sonatype.org/content/repositories/snapshots/" />
  <property name="maven-staging-repository-id" value="sonatype-nexus-staging" />
  <property name="maven-staging-repository-url" value="https://oss.sonatype.org/service/local/staging/deploy/maven2/" />

  <target name="-init">
    <ivy:cachepath pathid="path.build" conf="build" log="${ivy.logging}"/>
    <ivy:cachepath pathid="path.junit" conf="test" log="${ivy.logging}"/>
    <path id="path.run">
      <path refid="path.build"/>
      <pathelement path="build/main"/>
    </path>
    <path id="path.tools-run">
      <path refid="path.build"/>
      <pathelement path="build/tools"/>
    </path>
    <path id="path.test-build">
      <path refid="path.run"/>
      <path refid="path.junit"/>
    </path>
    <path id="path.test-run">
      <path refid="path.test-build"/>
      <pathelement path="build/test"/>
    </path>
  </target>

  <target name="-install-tasks" unless="installed.tasks">
    <ivy:cachepath pathid="path.tasks" conf="buildtools" log="${ivy.logging}"/>
    <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="path.tasks"/>
    <taskdef uri="antlib:org.apache.maven.artifact.ant" classpathref="path.tasks"/>
    <property name="installed.tasks" value="true"/>
  </target>

  <target name="-uptodate"> 
    <uptodate property="maven-descriptor.uptodate" targetfile="build/main/META-INF/maven/plugin.xml">
      <srcfiles dir="src/main/java"/>
    </uptodate>
  </target>

  <macrodef name="compile">
    <attribute name="module"/>
    <attribute name="classpathref"/>
    <sequential>
      <mkdir dir="build/@{module}"/>
      <copy todir="build/@{module}">
        <fileset dir="src/@{module}/resources" erroronmissingdir="false" />
      </copy>
      <javac includeantruntime="false" srcdir="src/@{module}/java" destdir="build/@{module}"
        source="${jdk.version}" target="${jdk.version}"
        debug="${compile.debug}" deprecation="${compile.deprecation}">
         <classpath refid="@{classpathref}"/>
         <compilerarg value="-Xlint"/>
      </javac>
    </sequential>
  </macrodef>

  <target name="compile" depends="-init" description="Compile">
    <compile module="main" classpathref="path.build"/>
  </target>

  <target name="compile-test" depends="compile" description="Compile tests">
    <compile module="test" classpathref="path.test-build"/>
  </target>

  <target name="compile-tools" depends="-init" description="Compile tools">
    <compile module="tools" classpathref="path.build"/>
  </target>

  <target name="clean" description="Clean">
    <delete dir="build"/>
    <delete dir="dist"/>
  </target>

  <target name="-maven-setup">
    <mkdir dir="build/maven"/>
    <copy todir="build/maven" encoding="UTF-8" outputencoding="UTF-8">
      <fileset dir="src/main/maven"/>
      <filterset>
        <filter token="NAME" value="${ant.project.name}"/>
        <filter token="VERSION" value="${version}"/>
        <filter token="GROUPID" value="${groupId}"/>
        <filter token="ARTIFACTID" value="${artifactId}"/>
      </filterset>
    </copy>
  </target>
  
  <target name="maven-descriptor" depends="-maven-setup,-install-tasks,-uptodate" unless="maven-descriptor.uptodate" description="Creates the Maven Plugin Descriptor">
    <!-- with fork=false this somehow takes endless to download the internet, so let's fork - and slow down -->
    <artifact:mvn pom="build/maven/pom.xml" mavenVersion="${maven.version}" failonerror="true" fork="true">
      <arg value="org.apache.maven.plugins:maven-plugin-plugin:2.9:descriptor"/>
      <sysproperty key="injected.src.dir" file="src/main/java"/>
      <sysproperty key="injected.target.dir" file="build/main"/>
    </artifact:mvn>
  </target>

  <target name="jar" depends="compile,-install-tasks,maven-descriptor" description="Create the binary JAR">
    <ivy:cachefileset setid="fileset.bundle" conf="bundle" log="${ivy.logging}"/>
    <mkdir dir="dist"/>
    <jarjar destfile="${jar-file}">
      <zipfileset dir="build/main"/>
      <zipfileset dir="build/maven" includes="pom.xml,pom.properties" prefix="META-INF/maven/${groupId}/${artifactId}"/>
      <restrict>
        <name name="**/*.class" handledirsep="true"/>
        <archives>
          <zips><fileset refid="fileset.bundle"/></zips>
        </archives>
      </restrict>
      <keep pattern="de.thetaphi.forbiddenapis.AntTask"/>
      <keep pattern="de.thetaphi.forbiddenapis.Mojo"/>
      <rule pattern="org.objectweb.asm.**" result="de.thetaphi.forbiddenapis.asm.@1"/>
      <manifest>
{'fraction_non_alphanumeric': 0.18286046005369713, 'fraction_numerical': 0.005659966620709673, 'mean_word_length': 3.92566118656183, 'pattern_counts': {'":': 0, '<': 266, '<?xml version=': 2, '>': 266, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 14}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7333334', 'n_tokens_mistral': 4447, 'n_tokens_neox': 4274, 'n_words': 874}