Skip to content

kordamp/jdeps-gradle-plugin

Repository files navigation

jdeps-gradle-plugin

Build Status Gradle Plugin Portal


Runs the jdeps command on the project’s output and all of its dependencies.

Usage

Option #1

buildscript {
    repositories {
        jcenter()
        gradlePluginPortal()
    }
    dependencies {
        classpath 'org.kordamp.gradle:jdeps-gradle-plugin:0.20.0'
    }
}
apply plugin: 'org.kordamp.gradle.jdeps'

Option #2

plugins {
    id 'org.kordamp.gradle.jdeps' version '0.20.0'
}

This will add a jdepsReport task to your build, which will analyze the main sourceSet. Should you need to analyze dependencies then define a value for either classpaths or configurations.

Configuration

Plugin configuration

The following properties can be specified in the jdeps task configuration

Name Option Property Type Default Value

listDeps

list-deps

jdeps.list.deps

boolean

false

listReducedDeps

list-reduced-deps

jdeps.list.reduced.deps

boolean

false

printModuleDeps

print-module-deps

jdeps.print.module.deps

boolean

false

verbose

verbose

jdeps.verbose

boolean

false

modular

modular

jdeps.modular

boolean

false

summary

summary

jdeps.summary

boolean

false

profile

profile

jdeps.profile

boolean

false

recursive

recursive

jdeps.recursive

boolean

false

jdkinternals

jdkinternals

jdeps.jdkinternals

boolean

false

apionly

apionly

jdeps.apionly

boolean

false

failOnWarning

fail-on-warning

jdeps.fail.on.warning

boolean

false

ignoreMissingDeps

ignore-missing-deps

jdeps.ignore.missing.deps

boolean

false

missingDeps

missing-deps

jdeps.missing.deps

boolean

false

include

include

jdeps.include

String

regex

regex

jdeps.regex

String

filter

filter

jdeps.filter

String

requires

require

jdeps.require

List<String>

[]

packages

package

jdeps.package

List<String>

[]

consoleOutput

console-output

jdeps.console.output

boolean

true

reportsDir

Directory

"${buildDir}/reports/jdeps"

configurations

configurations

jdeps.configurations

List<String>

[]

classpaths

classpaths

jdeps.classpaths

List<String>

[]

sourceSets

sourcesets

jdeps.sourcesets

List<String>

['main']

multiRelease

multi-release

jdeps.multi.release

String

multiReleaseJars

jdeps.multi.release.jars

Map<String, String>

[:]

dotOutput

dot-output

jdeps.dot.output

File

Task properties may be defined on the command line using their option name, or their property name, such as

$ gradle jdeps --verbose
$ gradle jdeps -Pjdeps.verbose=true
$ gradle jdeps -Djdeps.verbose=true
$ set JDEPS_VERBOSE=true
$ gradle jdeps

You may configure multiple sourceSets and configurations, which will be evaluated in a single report. The following snippet shows how this plugin can be configured to run jdeps on production and test sources

jdepsReport {
    sourceSets = ['main', 'test']
    configurations = ['testRuntimeClasspath']
}

MultiRelease JAR support

You may configure a version for the multiRelease property in which case this setting will be applied --multi-release <version> an all dependencies. If you need to check different releases per dependency then use the MultiReleaseJars property instead, for example

jdepsReport {
    multiReleaseJars = [
        'foo-1.0.0': '11',  // matches full name
        'bar.*':     '12'   // matches all files with 'bar' as prefix
    ]
}

MonkeyPatching the module

There are times when explicit modular settings may be needed to generate a jdeps report. You have the option to specify these settings using a moduleOptions extension on the `jdepsReport task, for example

jdepsReport {
    moduleOptions {
        addModules = ['com.acme.foo']
    }
}

JDeps Subcommands

You may use any of these subcommands with jdeps:

  • --list-deps

  • --list-reduced-deps

  • --print-module-deps

The output of these commands will be written to a file matching <subcommand>-<[sourceset|configuration].name>.txt, for example invoking --print-module-deps with default configuration will run jdeps on the main sourceSet, resulting in a file named build/reports/jdeps/print-module-deps-main.txt.

About

Run JDeps on a Gradle build

Resources

License