https://github.com/smarkwal/jarhc-gradle-plugin
JarHC Gradle Plugin
https://github.com/smarkwal/jarhc-gradle-plugin
Last synced: 5 months ago
JSON representation
JarHC Gradle Plugin
- Host: GitHub
- URL: https://github.com/smarkwal/jarhc-gradle-plugin
- Owner: smarkwal
- License: apache-2.0
- Created: 2022-12-19T09:43:31.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T08:35:34.000Z (about 1 year ago)
- Last Synced: 2025-04-28T09:56:51.491Z (about 1 year ago)
- Language: Java
- Size: 156 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JarHC Gradle Plugin
Gradle plugin to generate a [JarHC - JAR Health Check](https://github.com/smarkwal/jarhc) report for your project's dependencies.

[](https://www.apache.org/licenses/LICENSE-2.0)
[](https://github.com/smarkwal/jarhc-gradle-plugin/releases/latest)
[](https://github.com/smarkwal/jarhc-gradle-plugin/actions/workflows/build.yml)
[](https://sonarcloud.io/component_measures?metric=test_success_density&view=list&id=smarkwal_jarhc-gradle-plugin)
[](https://sonarcloud.io/component_measures?id=smarkwal_jarhc-gradle-plugin&metric=coverage&view=list)
[](https://sonarcloud.io/dashboard?id=smarkwal_jarhc-gradle-plugin)
[](https://github.com/smarkwal/jarhc-gradle-plugin/issues)
---
## Installation
Using the [plugins DSL](https://docs.gradle.org/current/userguide/plugins.html#sec:plugins_block) for Kotlin:
```kotlin
plugins {
id("org.jarhc") version "1.2.0"
}
```
## Configuration
The plugin adds a `jarhcReport` task to your project:
```shell
./gradlew jarhcReport
```
Without a specific configuration, the task will generate an HTML and a text report for all runtime dependencies of your project.
Both reports can be found in the `build` directory:
```
build/
└── reports/
└── jarhc/
├── jarhc-report.html
└── jarhc-report.txt
```
Example reports can be found here: [JarHC example reports](https://github.com/smarkwal/jarhc/wiki/Reports)
You can control many aspects of the JarHC task and take influence on the analysis and the report(s):
```kotlin
tasks {
jarhcReport {
// Classpath with JAR files (dependencies) to be analyzed by JarHC.
// Default: configurations.runtimeClasspath
classpath.setFrom(configurations.runtimeClasspath)
// There are also properties "provided" and "runtime" to set the classpath
// for JAR files used as provided libraries and Java runtime libraries.
// provided.setFrom(...)
// runtime.setFrom(...)
// Title of the JarHC report.
// Default: "JarHC Report for ${project.name} ${project.version}"
reportTitle.set("ASM 7.0")
// Path to generated report files (*.html or *.txt).
// Default: "${buildDir}/reports/jarhc/jarhc-report.html"
// and "${buildDir}/reports/jarhc/jarhc-report.txt"
reportFiles.setFrom(
file("${projectDir}/jarhc-report-asm-7.0.html"),
file("${projectDir}/jarhc-report-asm-7.0.txt")
)
// Sections to include in the report.
// See https://github.com/smarkwal/jarhc/wiki/Usage for more details.
// Default: empty list = include all sections
sections.addAll("jf", "d", "dc", "bc", "bl", "jm", "m", "ob" )
// Exclude sections without any issues from the report.
// Default: false
skipEmpty.set(true)
// Java release (8, 9, 10, ...) to use for analysis of multi-release JAR files.
// Default: version of Java used to run Gradle build
release.set(11)
// Classloader strategy. Used only if provided and/or runtime classpath is set.
// Default: "ParentLast"
strategy.set("ParentFirst")
// Ignore issues related to missing Java annotations.
// Default: false
ignoreMissingAnnotations.set(true)
// Ignore duplicate classes or resources if they are identical copies.
// Default: false
ignoreExactCopy.set(true)
// Path to the data directory used by JarHC to cache downloaded JAR and POM files.
// Default: "${rootDir}/.jarhc"
dataDir.set(file("${buildDir}/jarhc-data"))
}
}
```
Most configuration properties are 1-to-1 equivalents of the command line options explained in the [JarHC documentation](https://github.com/smarkwal/jarhc/wiki/Usage).
## Advanced examples
Add project artifact to classpath:
```kotlin
tasks {
jarhcReport {
dependsOn(jar)
classpath.setFrom(
jar.get().archiveFile,
configurations.runtimeClasspath
)
}
}
```
Add libraries to the "provided" classpath:
```kotlin
// create a custom configuration
val providedDependencies by configurations.creating
// add dependencies to the custom configuration
dependencies {
providedDependencies("javax.servlet:javax.servlet-api:3.1.0")
}
// use the custom configuration in the task
tasks {
jarhcReport {
provided.setFrom(providedDependencies)
}
}
```