Class AbstractProcessRemoteResourcesMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AggregateProcessRemoteResourcesMojo, ProcessRemoteResourcesMojo
Pull down resourceBundles containing remote resources and process the resources contained inside. When that is done, the resources are injected into the current (in-memory) Maven project, making them available to the process-resources phase.
Resources that end in ".vm" are treated as Velocity templates. For those, the ".vm" is stripped off for the final artifact name and it's fed through Velocity to have properties expanded, conditions processed, etc...
Resources that don't end in ".vm" are copied "as is".This is a support abstract class, with two non-aggregating and aggregating implementations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class(package private) static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate FileThe directory containing extra information appended to the generated resources.private final org.apache.maven.artifact.handler.manager.ArtifactHandlerManagerprivate booleanAttaches the resources to the main build of the project as a resource directory.private booleanAttaches the resources to the test build of the project as a resource directory.protected StringThe character encoding scheme to be applied when filtering resources.protected StringComma separated list of Artifact names to exclude.protected StringComma separated list of GroupId Names to exclude.protected StringScope to exclude.protected booleanIf we should exclude transitive dependenciesprivate final org.apache.maven.shared.filtering.MavenFileFilterFiltering support, for local resources that override those in the remote bundle.In cases where a local resource overrides one from a remote resource bundle, that resource should be filtered if the resource set specifies it.protected StringComma separated list of Artifact names to include.protected StringComma separated list of GroupIds to include.protected booleanDeprecated.protected StringScope to include.private final ModelInheritanceAssemblerMerges supplemental data model with artifact metadata.private static final Stringprivate static final Stringprivate final org.codehaus.plexus.resource.ResourceManagerprotected org.apache.maven.execution.MavenSessionThe Maven session.private FileThe directory where processed resources will be placed for packaging.private StringTimestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).protected org.apache.maven.project.MavenProjectThe current project.private final org.apache.maven.project.ProjectBuilderAdditional properties to be passed to Velocity.protected final org.eclipse.aether.RepositorySystemprotected String[]When resolving project dependencies, specify the scopes to include.The resource bundles that will be retrieved and processed, expressed withgroupId:artifactId:version[:type[:classifier]]format.private booleanSkip remote-resource processingList of artifacts that are added to the search path when looking for supplementalModels, expressed withgroupId:artifactId:version[:type[:classifier]]format.private String[]Supplemental model data.Map of artifacts to supplemental project object models.private static final Stringprotected booleanprivate booleanIndicate if project workspace files with the same name should be used instead of the ones from the bundle.private org.apache.velocity.app.VelocityEngineprotected intDeprecated.not used anymoreFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractProcessRemoteResourcesMojo(org.eclipse.aether.RepositorySystem repoSystem, org.apache.maven.shared.filtering.MavenFileFilter fileFilter, org.codehaus.plexus.resource.ResourceManager locator, org.apache.maven.project.ProjectBuilder projectBuilder, org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.apache.velocity.VelocityContextprivate voidprivate booleancopyProjectRootIfExists(File outputFile, String bundleResourceName) protected booleancopyResourceIfExists(File outputFile, String bundleResourceName, org.apache.velocity.VelocityContext context, String encoding) downloadBundles(List<String> bundles) voidexecute()private static StringgenerateSupplementMapKey(String groupId, String artifactId) protected abstract Set<org.apache.maven.artifact.Artifact> Returns all the transitive hull of all the involved maven projects.protected abstract Set<org.apache.maven.artifact.Artifact> Returns all the direct dependencies of all the involved maven projects.private StringgetLocationTemp(String name) Convenience method to get the location of the specified file name.protected List<org.apache.maven.project.MavenProject> getProjectsSortedByOrganization(List<org.apache.maven.project.MavenProject> projects) private Readerprotected org.apache.maven.model.ModelgetSupplement(org.codehaus.plexus.util.xml.Xpp3Dom supplementModelXml) private WritergetWriter(String writerEncoding, OutputStream outputStream) private ClassLoaderinitalizeClassloader(List<File> artifacts) loadSupplements(String[] models) protected org.apache.maven.model.ModelmergeModels(org.apache.maven.model.Model parent, org.apache.maven.model.Model child) protected voidprocessResourceBundles(ClassLoader classLoader, org.apache.velocity.VelocityContext context) private org.apache.maven.shared.filtering.MavenFileFilterRequestsetupRequest(org.apache.maven.model.Resource resource, File source, File file) protected voidvalidate()private voidverifyRequiredProperties(RemoteResourcesBundle bundle, URL url) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
TEMPLATE_SUFFIX
- See Also:
-
filterDelimiters
In cases where a local resource overrides one from a remote resource bundle, that resource should be filtered if the resource set specifies it. In those cases, this parameter defines the list of delimiters for filterable expressions. These delimiters are specified in the form 'beginToken*endToken'. If no '*' is given, the delimiter is assumed to be the same for start and end.
So, the default filtering delimiters might be specified as:
<delimiters> <delimiter>${*}</delimiter> <delimiter>@</delimiter> </delimiters>Since the '@' delimiter is the same on both ends, we don't need to specify '@*@' (though we can).- Since:
- 1.1
-
useDefaultFilterDelimiters
@Parameter(defaultValue="true") protected boolean useDefaultFilterDelimiters- Since:
- 1.1
-
encoding
@Parameter(property="encoding", defaultValue="${project.build.sourceEncoding}") protected String encodingThe character encoding scheme to be applied when filtering resources. -
outputDirectory
@Parameter(property="outputDirectory", defaultValue="${project.build.directory}/maven-shared-archive-resources") private File outputDirectoryThe directory where processed resources will be placed for packaging. -
appendedResourcesDirectory
@Parameter(defaultValue="${basedir}/src/main/appended-resources") private File appendedResourcesDirectoryThe directory containing extra information appended to the generated resources. -
supplementalModels
Supplemental model data. Useful when processing artifacts with incomplete POM metadata. By default, this Mojo looks for supplemental model data in the file "${appendedResourcesDirectory}/supplemental-models.xml".- Since:
- 1.0-alpha-5
-
supplementalModelArtifacts
-
resourceBundles
-
skip
@Parameter(property="remoteresources.skip", defaultValue="false") private boolean skipSkip remote-resource processing- Since:
- 1.0-alpha-5
-
attachToMain
@Parameter(defaultValue="true", property="attachToMain") private boolean attachToMainAttaches the resources to the main build of the project as a resource directory.- Since:
- 1.5
-
attachToTest
@Parameter(defaultValue="true", property="attachToTest") private boolean attachToTestAttaches the resources to the test build of the project as a resource directory.- Since:
- 1.5
-
properties
Additional properties to be passed to Velocity. Several properties are automatically added:project- the current MavenProjectprojects- the list of dependency projectsprojectsSortedByOrganization- the list of dependency projects sorted by organizationprojectTimespan- the timespan of the current project (requires inceptionYear in pom)locator- the ResourceManager that can be used to retrieve additional resources
-
includeProjectProperties
Deprecated.as Maven Project is available in Velocity context we can simply use$project.properties.propertyNameWhether to include properties defined in the project when filtering resources.- Since:
- 1.2
-
velocityFilterInMemoryThreshold
Deprecated.not used anymoreWhen the result of velocity transformation fits in memory, it is compared with the actual contents on disk to eliminate unnecessary destination file overwrite. This improves build times since further build steps typically rely on the modification date.- Since:
- 1.6
-
mavenSession
@Parameter(defaultValue="${session}", readonly=true, required=true) protected org.apache.maven.execution.MavenSession mavenSessionThe Maven session. -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) protected org.apache.maven.project.MavenProject projectThe current project. -
includeScope
Scope to include. An Empty string indicates all scopes (default is "runtime").- Since:
- 1.0
-
excludeScope
Scope to exclude. An Empty string indicates no scopes (default).- Since:
- 1.0
-
resolveScopes
When resolving project dependencies, specify the scopes to include. The default is the same as "includeScope" if there are no exclude scopes set. Otherwise, it defaults to "test" to grab all the dependencies so the exclude filters can filter out what is not needed.- Since:
- 1.5
-
excludeArtifactIds
Comma separated list of Artifact names to exclude.- Since:
- 1.0
-
includeArtifactIds
Comma separated list of Artifact names to include.- Since:
- 1.0
-
excludeGroupIds
Comma separated list of GroupId Names to exclude.- Since:
- 1.0
-
includeGroupIds
Comma separated list of GroupIds to include.- Since:
- 1.0
-
excludeTransitive
@Parameter(property="excludeTransitive", defaultValue="false") protected boolean excludeTransitiveIf we should exclude transitive dependencies- Since:
- 1.0
-
outputTimestamp
Timestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH). -
useProjectFiles
@Parameter(defaultValue="false") private boolean useProjectFilesIndicate if project workspace files with the same name should be used instead of the ones from the bundle.- Since:
- 3.3.0
-
supplementModels
-
inheritanceAssembler
Merges supplemental data model with artifact metadata. Useful when processing artifacts with incomplete POM metadata. -
velocity
private org.apache.velocity.app.VelocityEngine velocity -
repoSystem
protected final org.eclipse.aether.RepositorySystem repoSystem -
fileFilter
private final org.apache.maven.shared.filtering.MavenFileFilter fileFilterFiltering support, for local resources that override those in the remote bundle. -
locator
private final org.codehaus.plexus.resource.ResourceManager locator -
projectBuilder
private final org.apache.maven.project.ProjectBuilder projectBuilder -
artifactHandlerManager
private final org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager -
KEY_PROJECTS
- See Also:
-
KEY_PROJECTS_ORGS
- See Also:
-
-
Constructor Details
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
configureLocator
private void configureLocator() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getProjects
-
getAllDependencies
Returns all the transitive hull of all the involved maven projects. -
getDirectDependencies
Returns all the direct dependencies of all the involved maven projects. -
getProjectsSortedByOrganization
-
copyResourceIfExists
protected boolean copyResourceIfExists(File outputFile, String bundleResourceName, org.apache.velocity.VelocityContext context, String encoding) throws IOException, org.apache.maven.plugin.MojoExecutionException - Throws:
IOExceptionorg.apache.maven.plugin.MojoExecutionException
-
copyProjectRootIfExists
private boolean copyProjectRootIfExists(File outputFile, String bundleResourceName) throws IOException - Throws:
IOException
-
getReader
- Throws:
IOException
-
getWriter
- Throws:
IOException
-
setupRequest
-
validate
protected void validate() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
buildVelocityContext
protected org.apache.velocity.VelocityContext buildVelocityContext() -
downloadBundles
-
initalizeClassloader
private ClassLoader initalizeClassloader(List<File> artifacts) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
processResourceBundles
protected void processResourceBundles(ClassLoader classLoader, org.apache.velocity.VelocityContext context) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
verifyRequiredProperties
private void verifyRequiredProperties(RemoteResourcesBundle bundle, URL url) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
getSupplement
protected org.apache.maven.model.Model getSupplement(org.codehaus.plexus.util.xml.Xpp3Dom supplementModelXml) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
mergeModels
protected org.apache.maven.model.Model mergeModels(org.apache.maven.model.Model parent, org.apache.maven.model.Model child) -
generateSupplementMapKey
-
loadSupplements
-
getLocationTemp
-
$project.properties.propertyName