Class ProjectArtifactContentReader

java.lang.Object
org.bonitasoft.plugin.analyze.content.ProjectArtifactContentReader
All Implemented Interfaces:
ArtifactContentReader

public class ProjectArtifactContentReader extends Object implements ArtifactContentReader
Reads the content of a maven project folder.

Java classes are loaded from build directory.

  • Constructor Details

    • ProjectArtifactContentReader

      public ProjectArtifactContentReader(org.apache.maven.shared.filtering.MavenResourcesFiltering mavenResourcesFiltering, List<org.apache.maven.project.MavenProject> reactorProjects)
  • Method Details

    • getArtifactFileType

      public ArtifactContentReader.ArtifactFileType getArtifactFileType()
      Description copied from interface: ArtifactContentReader
      Get the concerned artifact file type.
      Specified by:
      getArtifactFileType in interface ArtifactContentReader
      Returns:
      the artifact file type
    • hasEntryWithPath

      public boolean hasEntryWithPath(org.apache.maven.artifact.Artifact artifact, Path entryPath)
      Description copied from interface: ArtifactContentReader
      Test whether the artifact has a content entry at the given relative path.
      Specified by:
      hasEntryWithPath in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to test (with adequate file type)
      entryPath - the relative path of the entry to test
      Returns:
      true when there is a valid entry
    • readEntry

      public void readEntry(org.apache.maven.artifact.Artifact artifact, Path entryPath, Consumer<InputStream> reader) throws IllegalArgumentException, IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the artifact entry at the given relative path.

      The input stream is closed automatically, so you do not have to worry about it.

      Specified by:
      readEntry in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      entryPath - the relative path of the entry to read
      reader - the reading job which will consume the entry content
      Throws:
      IllegalArgumentException - when entry not found
      IOException - exception reading artifact content
    • readFirstEntry

      public <T> Optional<T> readFirstEntry(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Function<ArtifactContentReader.Entry,T> reader) throws IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the first artifact entry which satisfy the path predicate.

      You must close the requested input stream in the reader.

      Specified by:
      readFirstEntry in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      predicateOnPath - the predicate to test on the entry path
      reader - the reading job which will eventually consume the valid entry content and transform it
      Returns:
      the result of the reading job, empty when no valid entry was found
      Throws:
      IOException - exception reading artifact content
    • readEntries

      public <R, A> R readEntries(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Collector<ArtifactContentReader.Entry,A,R> reader) throws IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the artifact entries which satisfy the path predicate.

      You must close the requested input stream in the reader.

      Specified by:
      readEntries in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      predicateOnPath - the predicate to test on the entry path
      reader - the reading job which will eventually consume each valid entry content and collect the result
      Returns:
      the result collected by the reader
      Throws:
      IOException - exception reading artifact content
    • detectImplementationHierarchy

      public Set<String> detectImplementationHierarchy(String className, org.apache.maven.artifact.Artifact artifact, Consumer<ClassNotFoundException> exceptionHandler) throws UnsupportedOperationException
      Description copied from interface: ArtifactContentReader
      Detect the implementation hierarchy of a java class in the artifact.

      Some implementations may not support this method for their artifact file type.

      Specified by:
      detectImplementationHierarchy in interface ArtifactContentReader
      Parameters:
      className - the name of the class to analyze
      artifact - the artifact to read (with adequate file type)
      exceptionHandler - handles any ClassNotFoundException while loading classes
      Returns:
      set of class names in the implementation's parent hierarchy
      Throws:
      UnsupportedOperationException - when the implementation does not support this method