All Downloads are FREE. Search and download functionalities are using the official Maven repository.

forbiddenapis-3.8.src.test.antunit.TestCli.xml Maven / Gradle / Ivy

Go to download

Allows to parse Java byte code to find invocations of method/class/field signatures and fail build (Apache Ant, Apache Maven, Gradle, or CLI)

The newest version!
<?xml version="1.0" encoding="UTF-8"?>
<!--
 * (C) Copyright Uwe Schindler (Generics Policeman) and others.
 *
 * 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 xmlns:au="antlib:org.apache.ant.antunit">

  <pathconvert property="cp" refid="path.main-build"/>

  <target name="testBundledSignatures">
    <java jar="${jar-file}" failonerror="true" fork="true">
      <arg value="-c"/>
      <arg value="${cp}"/>
      <arg value="-d"/>
      <arg file="${antunit.main.classes}"/>
      <arg value="-b"/>
      <arg value="jdk-unsafe-${jdk.version},jdk-deprecated-${jdk.version},jdk-non-portable"/>
    </java>
    <au:assertLogContains text=" 0 error(s)."/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-${jdk.version}"/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-${jdk.version}"/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-non-portable"/> 
  </target>

  <target name="testIncludesExcludes">
    <java jar="${jar-file}" failonerror="true" fork="true">
      <arg value="-c"/>
      <arg value="${cp}"/>
      <arg value="-d"/>
      <arg file="."/>
      <arg value="-b"/>
      <arg value="jdk-unsafe-${jdk.version},jdk-deprecated-${jdk.version}"/>
      <arg value="--bundledsignatures"/>
      <arg value="jdk-system-out,jdk-non-portable"/>
      <arg value="--includes"/>
      <arg value="Java7*.class"/>
      <arg value="--excludes"/>
      <arg value="Java7ClassReferences.class"/>
    </java>
    <au:assertLogContains text=" 0 error(s)."/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-deprecated-${jdk.version}"/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-unsafe-${jdk.version}"/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-system-out"/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-non-portable"/> 
  </target>

  <target name="testSuppressAnnotations">
    <java jar="${jar-file}" failonerror="true" fork="true">
      <arg value="-c"/>
      <arg value="${cp}"/>
      <arg value="-d"/>
      <arg file="."/>
      <arg value="-b"/>
      <arg value="jdk-system-out"/>
      <arg value="--includes"/>
      <arg value="Java8Annotations.class"/>
      <arg value="--suppressannotation"/>
      <arg value="*$FooBar"/>
    </java>
    <au:assertLogContains text=" 0 error(s)."/> 
    <au:assertLogContains text="Reading bundled API signatures: jdk-system-out"/> 
  </target>

  <target name="testSignatureFile">
    <au:expectfailure expectedMessage="Java returned: 1">
      <java jar="${jar-file}" failonerror="true" fork="true">
        <arg value="-c"/>
        <arg value="${cp}"/>
        <arg value="-d"/>
        <arg file="${antunit.main.classes}"/>
        <arg value="-f"/>
        <arg file="signatures1.txt"/>
      </java>
    </au:expectfailure>
    <au:assertLogContains text="java.lang.String#substring(int,int) [You are crazy that you disallow substrings]"/> 
  </target>

</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy