Class ProjectAttribution

java.lang.Object
com.arc_e_tect.gradle.gherkin.indexing.ProjectAttribution

public final class ProjectAttribution extends Object
Decides which project in a Gradle build a given .feature file belongs to, by matching the file's path against every project's directory.

This is the single notion of "owning project" the plugin scopes work by. FeatureIndexer uses it to number each project's features as its own 1-based sequence, and the task uses it to tell whether the files one invocation collected actually span more than one project - which is the only situation in which that scoping changes anything.

A file that isn't under any of the configured project directories (which shouldn't normally happen, since callers supply every project directory in the build) is attributed to itself rather than being silently folded into an unrelated project.

  • Constructor Details

    • ProjectAttribution

      public ProjectAttribution(List<File> projectDirectories)
      Creates an attribution over projectDirectories.
      Parameters:
      projectDirectories - every project directory in the build; an empty list attributes every file to itself, since there are then no boundaries to match against
  • Method Details

    • owningProjectDirectory

      public File owningProjectDirectory(File featureFile)
      The most specific project directory that is an ancestor of featureFile, or featureFile itself when none is.
      Parameters:
      featureFile - the feature file to attribute
      Returns:
      the owning project's directory, never null
    • owningProjectDirectories

      public Set<File> owningProjectDirectories(List<File> featureFiles)
      Every distinct project featureFiles is spread across, in the order each owner was first encountered.
      Parameters:
      featureFiles - the feature files one run collected
      Returns:
      the distinct owning project directories; empty when featureFiles is empty