Skip to content

ABI allow inclusions #1588

@ArtyomGabeev

Description

@ArtyomGabeev

Is your feature request related to a problem? Please describe.
Currently ABI configuration supports only excludeClasses, excludeAnnotations.
When working with existing codebase, which does not follow package convention, it's hard to differentiate between public/internal api, bcz everything are essentially public, leading to dependency exposure if I follow plugin advices.

Describe the solution you'd like
Add to the abi { exclusions {} } possibility to configure:

  • includeClasses('some.package')
  • includeAnnotations('PublicApi')

In order to allow graceful migration and enforcements.

Describe alternatives you've considered

  1. Major refactoring to use packages to differentiate api/internal package, will cause backward compatibility issues on the client and mess with git history. However, package separation is a common practice and used by java modules or ArchUnit.
  2. As a workaround I came up with exclude everything except:
dependencyAnalysis {
    abi {
        exclusions {
            def includes = [
                'some.package.'
            ]
            def includesQuoted = includes.collect { Pattern.quote(it) }
            def excludeRegex = '^' + includesQuoted.collect { "(?!${it})" }.join('') + '.*$'

            ignoreGeneratedCode()
            excludeAnnotations('org.springframework.boot.autoconfigure.AutoConfiguration')
            excludeClasses(excludeRegex)
        }
    }
}

Additional context
If it makes sense I can contribute the change.
What I am not sure, how existing exclusion work with transitive class dependencies.
E.g. if we introduce inclusion configuration and include single class, I assume it will be challenging and non-explicit to add all dependent classes from class ABI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions