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

forbiddenapis-3.8.src.test.gradle.build.gradle 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!
/*
 * (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.
 */

// The following properties need to be defined in gradle.properties next to this file:
//  - forbiddenRootDir
//  - forbiddenClasspath
//  - forbiddenTestClasspath
//  - forbiddenSourceCompatibility

buildscript {
  dependencies {
    classpath fileTree(dir: new File(forbiddenRootDir, 'dist'), include: '*.jar')
  }
}

apply plugin: 'java'
apply plugin: 'de.thetaphi.forbiddenapis'

if (project.extensions.findByName('java')) {

  java {
    sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility)
  }
  
} else {
  // TODO: Remove this after Gradle 4.10
  sourceCompatibility = JavaVersion.toVersion(forbiddenSourceCompatibility)
}

sourceSets {
  main {
    compileClasspath = files(forbiddenClasspath.tokenize(File.pathSeparator))
    java {
      srcDirs = [new File(forbiddenRootDir, 'src/main/java')]
    }
  }
  main2 {
    compileClasspath = files(forbiddenClasspath.tokenize(File.pathSeparator))
    java {
      srcDirs = [new File(forbiddenRootDir, 'src/main/java')]
    }
  }
  test {
    compileClasspath = files(forbiddenTestClasspath.tokenize(File.pathSeparator))
    java {
      srcDirs = [new File(forbiddenRootDir, 'src/test/java')]
    }
  }
}

forbiddenApis {
  bundledSignatures = [ 'jdk-unsafe', 'jdk-deprecated', 'jdk-non-portable', 'jdk-reflection' ]
  signaturesFiles += files(new File(forbiddenRootDir, 'src/tools/signatures/mysignatures.txt'))
  failOnUnsupportedJava = false
}

forbiddenApisMain {
  bundledSignatures.add('jdk-internal')
}

forbiddenApisMain2 {
  bundledSignatures += 'jdk-system-out'
}

forbiddenApisTest {
  // keep defaults from "forbiddenApis" above
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy