@Mojo(name="read-project-properties",
defaultPhase=NONE,
requiresProject=true,
threadSafe=true)
public class ReadPropertiesMojo
extends org.apache.maven.plugin.AbstractMojo
Modifier and Type | Class and Description |
---|---|
private static class |
ReadPropertiesMojo.FileResource |
private static class |
ReadPropertiesMojo.Resource |
private static class |
ReadPropertiesMojo.UrlResource |
Modifier and Type | Field and Description |
---|---|
private java.io.File[] |
files
The properties files that will be used when reading properties.
|
private org.apache.maven.project.MavenProject |
project |
private boolean |
quiet
If the plugin should be quiet if any of the files was not found
|
private PropertyResolver |
resolver
Used for resolving property placeholders.
|
private java.lang.String[] |
urls
The URLs that will be used when reading properties.
|
Constructor and Description |
---|
ReadPropertiesMojo() |
Modifier and Type | Method and Description |
---|---|
private void |
checkParameters() |
void |
execute() |
private java.lang.String |
getPropertyValue(java.lang.String k,
java.util.Properties p,
java.util.Properties environment) |
(package private) java.util.Properties |
getSystemEnvVars()
Override-able for test purposes.
|
private void |
load(ReadPropertiesMojo.Resource resource) |
private void |
loadFiles() |
private void |
loadProperties(ReadPropertiesMojo.Resource resource) |
private java.util.Properties |
loadSystemEnvironmentPropertiesWhenDefined() |
private void |
loadUrls() |
private void |
missing(ReadPropertiesMojo.Resource resource) |
private void |
resolveProperties() |
void |
setFiles(java.io.File[] files) |
(package private) void |
setProject(org.apache.maven.project.MavenProject project)
Default scope for test access.
|
(package private) void |
setQuiet(boolean quiet)
Default scope for test access.
|
void |
setUrls(java.lang.String[] urls)
Default scope for test access.
|
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
@Parameter private java.io.File[] files
@Parameter private java.lang.String[] urls
classpath:com/company/resource.properties
. Note that the type is not URL
for this
reason and therefore will be explicitly checked by this Mojo.@Parameter(defaultValue="false") private boolean quiet
private final PropertyResolver resolver
public void setFiles(java.io.File[] files)
files
- The files to set for tests.public void setUrls(java.lang.String[] urls)
urls
- The URLs to set for tests.public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
private void checkParameters() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void loadFiles() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void loadUrls() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void load(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void loadProperties(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void missing(ReadPropertiesMojo.Resource resource) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void resolveProperties() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureException
private java.util.Properties loadSystemEnvironmentPropertiesWhenDefined() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private java.lang.String getPropertyValue(java.lang.String k, java.util.Properties p, java.util.Properties environment) throws org.apache.maven.plugin.MojoFailureException
org.apache.maven.plugin.MojoFailureException
java.util.Properties getSystemEnvVars() throws java.io.IOException
null
.java.io.IOException
- If the environment variables could not be queried from the shell.void setQuiet(boolean quiet)
quiet
- Set to true
if missing files can be skipped.void setProject(org.apache.maven.project.MavenProject project)
project
- The test project.