Package org.codehaus.mojo.properties
Class ReadPropertiesMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.properties.ReadPropertiesMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="read-project-properties",
defaultPhase=NONE,
requiresProject=true,
threadSafe=true)
public class ReadPropertiesMojo
extends org.apache.maven.plugin.AbstractMojo
The read-project-properties goal reads property files and URLs and stores the properties as project properties. It
serves as an alternate to specifying properties in pom.xml. It is especially useful when making properties defined in
a runtime resource available at build time.
- Version:
- $Id$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classprivate static classprivate static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate File[]The properties files that will be used when reading properties.private org.apache.maven.project.MavenProjectprivate booleanIf the plugin should be quiet if any of the files was not foundprivate final PropertyResolverUsed for resolving property placeholders.private String[]The URLs that will be used when reading properties.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidvoidexecute()private StringgetPropertyValue(String k, Properties p, Properties environment) (package private) PropertiesOverride-able for test purposes.private voidload(ReadPropertiesMojo.Resource resource) private voidprivate voidloadProperties(ReadPropertiesMojo.Resource resource) private Propertiesprivate voidloadUrls()private voidmissing(ReadPropertiesMojo.Resource resource) private voidvoid(package private) voidsetProject(org.apache.maven.project.MavenProject project) Default scope for test access.(package private) voidsetQuiet(boolean quiet) Default scope for test access.voidDefault scope for test access.Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project -
files
The properties files that will be used when reading properties. -
urls
The URLs that will be used when reading properties. These may be non-standard URLs of the formclasspath:com/company/resource.properties. Note that the type is notURLfor this reason and therefore will be explicitly checked by this Mojo. -
quiet
@Parameter(defaultValue="false") private boolean quietIf the plugin should be quiet if any of the files was not found -
resolver
Used for resolving property placeholders.
-
-
Constructor Details
-
ReadPropertiesMojo
public ReadPropertiesMojo()
-
-
Method Details
-
setFiles
- Parameters:
files- The files to set for tests.
-
setUrls
Default scope for test access.- Parameters:
urls- The URLs to set for tests.
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
checkParameters
private void checkParameters() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
loadFiles
private void loadFiles() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
loadUrls
private void loadUrls() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
load
private void load(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
loadProperties
private void loadProperties(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
missing
private void missing(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
resolveProperties
private void resolveProperties() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
loadSystemEnvironmentPropertiesWhenDefined
private Properties loadSystemEnvironmentPropertiesWhenDefined() throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getPropertyValue
private String getPropertyValue(String k, Properties p, Properties environment) throws org.apache.maven.plugin.MojoFailureException - Throws:
org.apache.maven.plugin.MojoFailureException
-
getSystemEnvVars
Override-able for test purposes.- Returns:
- The shell environment variables, can be empty but never
null. - Throws:
IOException- If the environment variables could not be queried from the shell.
-
setQuiet
void setQuiet(boolean quiet) Default scope for test access.- Parameters:
quiet- Set totrueif missing files can be skipped.
-
setProject
void setProject(org.apache.maven.project.MavenProject project) Default scope for test access.- Parameters:
project- The test project.
-