Java

Configuration - .deepsource.toml

This section covers configuration details specific to the Java analyzer. Please ensure that you have read the general configuration guide first.

The Java analyzer supports Gradle and Maven projects. There is no difference in configuration between them, and both types of projects can be initialized through the simple workflow of the DeepSource configuration generator.

name

  • Type: String
  • Presence: mandatory
  • Description: Shortcode of the analyzer.
  • Example:
name = "java"

enabled

  • Type: Boolean
  • Presence: mandatory
  • Description: Toggle whether this analyzer should be run.
  • Example:
enabled = true

meta

  • Type: Table
  • Presence: mandatory
  • Description: Additional data used to configure the analyzer.
  • Example:
[analyzers.meta]
  runtime_version = "8"

runtime_version

  • Type: String
  • Presence: mandatory
  • Description: The Java runtime version to use when running the analyzer. OpenJDK versions 8 to 15 are currently supported.
  • Aliases: java_version
  • Example:
[analyzers.meta]
  runtime_version = "13"

if runtime_version is not specified, or is the wrong Java version, analysis may fail. Specify the Java version you use locally or in CI for best results.

skip_doc_coverage

  • Type: Array

  • Presence: optional

  • Description: Specify which artifacts to skip when calculating documentation coverage.

  • Available Values: test, class, constructor and nonpublic

    • test - Ignore documentation coverage within tests
    • class - Ignore class documentation coverage
    • constructor - Ignore constructor documentation coverage
    • nonpublic - Ignore documentation coverage for any declaration not marked as public
  • Default Value: [ "test" ]

  • Example:

skip_doc_coverage = [ "nonpublic", "test" ]

If skip_doc_coverage is set, it will override any default configuration. That is, if this key is set, and you wish to ensure documentation coverage is skipped for elements that are skipped by default (like tests), you must specify those as well as the additional elements you wish to skip.

legacy

  • Type: Boolean
  • Presence: optional
  • Description: Use the Java analyzer in legacy mode. This will build your project before analysis and may detect more issues. This comes with a few caveats; analysis may take longer and might time out for large projects.
  • Example:
[analyzers.meta]
  legacy = true

Legacy mode is disabled by default and will be removed in a future release. Once legacy mode is removed, the legacy flag will be ignored if present in your config.

DeepSource will attempt to build and analyze your project's Java bytecode when using legacy mode. This may be more prone to failure and may result in analysis timeouts. We are continuing to improve the Java analyzer over time, and it is likely that you will have a better experience with legacy mode set to false.

Sample config

version = 1

[[analyzers]]
name = "java"
enabled = true

  [analyzers.meta]
  runtime_version = "8"