public abstract class AbstractContainerMojo extends AbstractMojo
Modifier and Type | Class and Description |
---|---|
static interface |
AbstractContainerMojo.SourceEditor
Interface to manipulate source files.
|
Modifier and Type | Field and Description |
---|---|
protected static String[] |
DEFAULT_SOURCE_INCLUDES
Default source include patterns.
|
Constructor and Description |
---|
AbstractContainerMojo() |
Modifier and Type | Method and Description |
---|---|
protected static void |
disableThreadContextClassLoader()
Disables the use of the thread context classloader by setting system
property
org.jdtaus.core.container.ClassLoaderFactory.enableContextClassloader
to true . |
protected String |
edit(String str,
AbstractContainerMojo.SourceEditor editor)
Edits a string.
|
protected static void |
enableThreadContextClassLoader()
Enables the use of the thread context classloader by setting system
property
org.jdtaus.core.container.ClassLoaderFactory.enableContextClassloader
to true . |
protected String |
formatComment(String text)
Formats a given text to a javadoc comment.
|
protected Collection |
getAllSources()
Gets all source files from the project's compile source roots.
|
protected Set |
getClasspathElements()
Accessor to the project's classpath elements including runtime
dependencies.
|
protected String |
getEncoding()
Getter for property
encoding . |
protected Locale |
getLocale()
Getter for property
locale . |
protected MavenProject |
getMavenProject()
Accessor to the currently executed
MavenProject . |
protected ModelManager |
getModelManager()
Gets the
ModelManager instance. |
protected ClassLoader |
getRuntimeClassLoader(ClassLoader parent)
Provides access to the project's runtime classpath.
|
protected File |
getSource(List roots,
String className)
Accessor to a
*.java file for a given class name. |
protected ClassLoader |
getTestClassLoader(ClassLoader parent)
Provides access to the project's test classpath.
|
protected Set |
getTestClasspathElements()
Accessor to the test classpath elements.
|
protected Collection |
getTestSources()
Gets all source files from the project's test compile source roots.
|
protected VelocityEngine |
getVelocity()
Gets the
VelocityEngine used for generating source code. |
protected void |
indent(StringBuffer stringBuffer)
Adds the configured number of spaces to a string buffer.
|
protected boolean |
isClasspathElementDefaultExlude(String element)
Indicates whether a class path element is on the list of default class
path element excludes.
|
protected boolean |
isClasspathElementIncluded(String element)
Indicates wheter a class path element should be included in the
classpath.
|
protected boolean |
isTestClasspathElementIncluded(String element)
Indicates wheter a class path element should be included in the
classpath.
|
protected boolean |
isTestMode()
Getter for property
testMode . |
protected String |
load(File file)
Loads the contents of a file.
|
protected void |
save(File file,
String str)
Saves a string to a file.
|
getLog, getPluginContext, setLog, setPluginContext
protected static final String[] DEFAULT_SOURCE_INCLUDES
public AbstractContainerMojo()
protected static void disableThreadContextClassLoader()
org.jdtaus.core.container.ClassLoaderFactory.enableContextClassloader
to true
.protected final String edit(String str, AbstractContainerMojo.SourceEditor editor) throws MojoFailureException
str
- The string to edit.editor
- The editor to use for editing str
.str
edited by editor
.NullPointerException
- if either str
or editor
is
null
.MojoFailureException
- for unrecoverable errors.protected static void enableThreadContextClassLoader()
org.jdtaus.core.container.ClassLoaderFactory.enableContextClassloader
to true
.protected String formatComment(String text)
text
- The text to format.text
as a javadoc comment.NullPointerException
- if text
is null
.protected final Collection getAllSources()
Collection
holding File
instances for all
source files found in all compile source roots.protected final Set getClasspathElements() throws org.apache.maven.artifact.DependencyResolutionRequiredException
org.apache.maven.artifact.DependencyResolutionRequiredException
- for any unresolved
dependency scopes.protected final String getEncoding()
encoding
.null
to use the system's default encoding.protected final Locale getLocale()
locale
.protected final MavenProject getMavenProject()
MavenProject
.MavenProject
.protected ModelManager getModelManager()
ModelManager
instance.ModelManager
instance.protected final ClassLoader getRuntimeClassLoader(ClassLoader parent) throws MojoFailureException
parent
- the parent classloader to use for the runtime classloader.ClassLoader
initialized with the project's runtime
classpath.MojoFailureException
- for unrecoverable technical errors.protected final File getSource(List roots, String className)
*.java
file for a given class name.roots
- list of source roots to search.className
- The class name to return the corresponding
*.java
file for (needs to be in the project's compile source
roots). No inner classes are supported yet.className
or
null
if no corresponding source file can be found.NullPointerException
- if either roots
or className
is null
.protected final ClassLoader getTestClassLoader(ClassLoader parent) throws MojoFailureException
parent
- the parent classloader to use for the test classloader.ClassLoader
initialized with the project's test
classpath.MojoFailureException
- for unrecoverable technical errors.protected final Set getTestClasspathElements() throws org.apache.maven.artifact.DependencyResolutionRequiredException
org.apache.maven.artifact.DependencyResolutionRequiredException
- for any unresolved
dependency scopes.protected final Collection getTestSources()
Collection
holding File
instances for all
source files found in all test compile source roots.protected final VelocityEngine getVelocity() throws Exception
VelocityEngine
used for generating source code.VelocityEngine
used for generating source code.Exception
- if initializing a new velocity engine fails.protected final void indent(StringBuffer stringBuffer)
stringBuffer
- The StringBuffer
to add the number of spaces
to.NullPointerException
- if stringBuffer
is null
.protected boolean isClasspathElementDefaultExlude(String element)
element
- the element to check for default classpath exclusion.true
if element
should be excluded by default;
false
if not.NullPointerException
- if element
is null
.protected boolean isClasspathElementIncluded(String element)
element
- the element to check for classpath inclusion.true
if element
should be included in the
classpath; false
if not.NullPointerException
- if element
is null
.protected boolean isTestClasspathElementIncluded(String element)
element
- the element to check for classpath inclusion.true
if element
should be included in the
classpath; false
if not.NullPointerException
- if element
is null
.protected final boolean isTestMode()
testMode
.true
if no sources will be touched; false
if
sources will be changed.protected final String load(File file) throws MojoFailureException
file
- The file to load.file
.NullPointerException
- if file
is null
.MojoFailureException
- for unrecoverable errors.protected final void save(File file, String str) throws MojoFailureException
file
- The file to save str
to.str
- The string to save to file
.NullPointerException
- if either file
or str
is
null
.MojoFailureException
- for unrecoverable errors.Copyright © 2005–2014 jDTAUS. All rights reserved.