Class RenderDependenciesMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.dependency.AbstractDependencyMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
-
- org.apache.maven.plugins.dependency.fromDependencies.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 AbstractDependencyFilterMojoThis goal renders dependencies based on a velocity template.- Since:
- 3.9.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringclassifierIf not null or empty it will attach the artifact with this classifier.private java.lang.StringextensionExtension to use for the attached file if classifier is not null/empty.private java.lang.StringoutputEncodingEncoding to write the rendered template.private java.io.FileoutputFileThe file to write the rendered template string.private org.apache.maven.project.MavenProjectHelperprojectHelperprivate java.lang.StringtemplateVelocity template to use to render the output file.-
Fields inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
excludeArtifactIds, excludeClassifiers, excludeGroupIds, excludeScope, excludeTransitive, excludeTypes, includeArtifactIds, includeClassifiers, includeGroupIds, includeScope, includeTypes, markersDirectory, overWriteIfNewer, overWriteReleases, overWriteSnapshots, prependGroupId, type
-
Fields inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
session
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedRenderDependenciesMojo(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 Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidattachFile(java.lang.String content)protected voiddoExecute()Main entry into mojo.protected org.apache.maven.shared.artifact.filter.collection.ArtifactsFiltergetMarkedArtifactFilter()Return anArtifactsFilterindicating which artifacts must be filtered out.private java.nio.file.PathgetTemplatePath()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.private java.lang.Stringrender(java.util.List<org.apache.maven.artifact.Artifact> artifacts)Do render the template.voidsetClassifier(java.lang.String classifier)voidsetExtension(java.lang.String extension)voidsetOutputEncoding(java.lang.String outputEncoding)voidsetOutputFile(java.io.File outputFile)voidsetTemplate(java.lang.String template)private voidstore(java.lang.String content, java.io.File out)Stores the specified string into that file.-
Methods inherited from class org.apache.maven.plugins.dependency.fromDependencies.AbstractDependencyFilterMojo
filterMarkedDependencies, getDependencySets, getDependencySets, getMarkersDirectory, getResolvedDependencies, getResolverUtil, isPrependGroupId, setMarkersDirectory, setPrependGroupId
-
Methods inherited from class org.apache.maven.plugins.dependency.AbstractDependencyMojo
execute, getProject, isSilent, isSkip, setSilent, setSkip
-
-
-
-
Field Detail
-
outputEncoding
@Parameter(property="outputEncoding", defaultValue="${project.reporting.outputEncoding}") private java.lang.String outputEncodingEncoding 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 classifierIf 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 extensionExtension 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 templateVelocity 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.MojoExecutionExceptionMain entry into mojo.- Specified by:
doExecutein classAbstractDependencyMojo- 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.MojoExecutionExceptionStores 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:AbstractDependencyFilterMojoReturn anArtifactsFilterindicating which artifacts must be filtered out.- Specified by:
getMarkedArtifactFilterin classAbstractDependencyFilterMojo- Returns:
- an
ArtifactsFilterindicating 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)
-
-