kordamp / jdeps-gradle-plugin

Run JDeps on a Gradle build
Apache License 2.0
35 stars 10 forks source link

= jdeps-gradle-plugin :linkattrs: :project-owner: kordamp :project-repo: maven :project-name: jdeps-gradle-plugin :project-group: org.kordamp.gradle :project-version: 0.20.0 :plugin-id: {project-group}.jdeps

image:https://img.shields.io/github/actions/workflow/status/{project-owner}/{project-name}/early-access.yml?branch=master&logo=github&label=Build["Build Status", link="https://github.com/{project-owner}/{project-name}/actions"] image:https://img.shields.io/gradle-plugin-portal/v/{plugin-id}?logo=gradle["Gradle Plugin Portal", link="https://plugins.gradle.org/plugin/{plugin-id}"]


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

== Usage

Option #1 [source,groovy] [subs="attributes"]

buildscript { repositories { jcenter() gradlePluginPortal() } dependencies { classpath '{project-group}:{project-name}:{project-version}' } } apply plugin: '{project-group}.jdeps'

Option #2 [source,groovy] [subs="attributes"]

plugins { id '{project-group}.jdeps' version '{project-version}' }

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

[options="header"] |=== | 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 | [] | packages | package | jdeps.package | List | [] | consoleOutput | console-output | jdeps.console.output | boolean | true | reportsDir | | | Directory | "${buildDir}/reports/jdeps" | configurations | configurations | jdeps.configurations | List | [] | classpaths | classpaths | jdeps.classpaths | List | [] | sourceSets | sourcesets | jdeps.sourcesets | List | ['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

[source]

$ 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

[source]

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 &lt;version&gt; an all dependencies. If you need to check different releases per dependency then use the MultiReleaseJars property instead, for example

[source]

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

[source]

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

=== JDeps Subcommands

You may use any of these subcommands with jdeps:

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.