Class RenderDependenciesMojo

  • 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 Detail

      • outputEncoding

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

        @Parameter(property="mdep.outputFile")
        private java.io.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 java.lang.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 java.lang.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 java.lang.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 Detail

      • 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 Detail

      • 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 java.lang.String render​(java.util.List<org.apache.maven.artifact.Artifact> artifacts)
        Do render the template.
        Parameters:
        artifacts - input.
        Returns:
        the template rendered.
      • getTemplatePath

        private java.nio.file.Path getTemplatePath()
      • orEmpty

        private java.util.Comparator<org.apache.maven.artifact.Artifact> orEmpty​(java.util.function.Function<org.apache.maven.artifact.Artifact,​java.lang.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​(java.lang.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​(java.lang.String content,
                           java.io.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​(java.lang.String extension)
      • setOutputEncoding

        public void setOutputEncoding​(java.lang.String outputEncoding)
      • setOutputFile

        public void setOutputFile​(java.io.File outputFile)
      • setClassifier

        public void setClassifier​(java.lang.String classifier)
      • setTemplate

        public void setTemplate​(java.lang.String template)