GradleUsage

Uwe Schindler edited this page Oct 15, 2018 · 13 revisions

Gradle Usage Instructions

(since version 2.0) The plugin registers a separate task for each defined sourceSet using the default task naming convention. For default Java projects, two tasks are created: forbiddenApisMain and forbiddenApisTest. Additional source sets will produce a task with similar names ('forbiddenApis' + nameOfSourceSet). All tasks are added as dependencies to the check default Gradle task. For convenience, the plugin also defines an additional task forbiddenApis that runs checks on all source sets.

Installation can be done from your build.gradle file using the Gradle plugin DSL:

plugins {
  id 'de.thetaphi.forbiddenapis' version '2.6'
}

Alternatively, you can use the following script snippet if dynamic configuration is required (e.g., for own tasks):

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'de.thetaphi:forbiddenapis:2.6'
  }
}

apply plugin: 'de.thetaphi.forbiddenapis'

After that you can add the following task configuration closures:

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

(using the += notation, you can add additional bundled signatures to the defaults). To define those defaults, which are used by all source sets, you can use the extension / convention mapping provided by the corresponding extension:

forbiddenApis {
  bundledSignatures = [ 'jdk-unsafe', 'jdk-deprecated', 'jdk-non-portable', 'jdk-reflection' ]
  signaturesFiles = files('path/to/my/signatures.txt')
  ignoreFailures = false
}

The possible bundledSignatures can be found on a separate page. You can also give your own signatures in separate files from your project directory.

The detailed documentation (based on nightly snapshots) can be found here: https://jenkins.thetaphi.de/job/Forbidden-APIs/javadoc/

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.