Class RenderDependenciesMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="render-dependencies", requiresDependencyResolution=TEST, defaultPhase=GENERATE_SOURCES, threadSafe=true) public class RenderDependenciesMojo extends AbstractDependencyFilterMojo
This goal renders dependencies based on a velocity template.
Since:
3.9.0
  • Field Details

    • outputEncoding

      @Parameter(property="outputEncoding", defaultValue="${project.reporting.outputEncoding}") private String outputEncoding
      Encoding to write the rendered template.
      Since:
      3.9.0
    • outputFile

      @Parameter(property="mdep.outputFile") private File outputFile
      The file to write the rendered template string. If undefined, it just prints the classpath as [INFO].
      Since:
      3.9.0
    • classifier

      @Parameter(property="mdep.classifier", defaultValue="template") private String classifier
      If not null or empty it will attach the artifact with this classifier.
      Since:
      3.9.0
    • extension

      @Parameter(property="mdep.extension", defaultValue="txt") private String extension
      Extension to use for the attached file if classifier is not null/empty.
      Since:
      3.9.0
    • template

      @Parameter(property="mdep.template", required=true) private String template
      Velocity template to use to render the output file. It can be inline or a file path.
      Since:
      3.9.0
    • projectHelper

      private final org.apache.maven.project.MavenProjectHelper projectHelper
  • Constructor Details

    • RenderDependenciesMojo

      @Inject protected RenderDependenciesMojo(org.apache.maven.execution.MavenSession session, org.sonatype.plexus.build.incremental.BuildContext buildContext, org.apache.maven.project.MavenProject project, ResolverUtil resolverUtil, org.apache.maven.project.ProjectBuilder projectBuilder, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager, org.apache.maven.project.MavenProjectHelper projectHelper)
  • Method Details

    • doExecute

      protected void doExecute() throws org.apache.maven.plugin.MojoExecutionException
      Main entry into mojo.
      Specified by:
      doExecute in class AbstractDependencyMojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - with a message if an error occurs
    • render

      private String render(List<org.apache.maven.artifact.Artifact> artifacts)
      Do render the template.
      Parameters:
      artifacts - input.
      Returns:
      the template rendered.
    • getTemplatePath

      private Path getTemplatePath()
    • orEmpty

      private Comparator<org.apache.maven.artifact.Artifact> orEmpty(Function<org.apache.maven.artifact.Artifact, String> getter)
      Trivial null protection impl for comparing callback.
      Parameters:
      getter - nominal getter.
      Returns:
      a comparer of getter defaulting on empty if getter value is null.
    • attachFile

      protected void attachFile(String content) throws org.apache.maven.plugin.MojoExecutionException
      Parameters:
      content - the rendered template
      Throws:
      org.apache.maven.plugin.MojoExecutionException - in case of an error
    • store

      private void store(String content, File out) throws org.apache.maven.plugin.MojoExecutionException
      Stores the specified string into that file.
      Parameters:
      content - the string to write into the file
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • getMarkedArtifactFilter

      protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter getMarkedArtifactFilter()
      Description copied from class: AbstractDependencyFilterMojo
      Return an ArtifactsFilter indicating which artifacts must be filtered out.
      Specified by:
      getMarkedArtifactFilter in class AbstractDependencyFilterMojo
      Returns:
      an ArtifactsFilter indicating which artifacts must be filtered out
    • setExtension

      public void setExtension(String extension)
    • setOutputEncoding

      public void setOutputEncoding(String outputEncoding)
    • setOutputFile

      public void setOutputFile(File outputFile)
    • setClassifier

      public void setClassifier(String classifier)
    • setTemplate

      public void setTemplate(String template)