|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
public abstract class AbstractPlugin
Base mojo with usefull methods and implementing Plugin contract.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin |
|---|
Plugin.Packaging |
| Field Summary | |
|---|---|
protected String |
skipAfterInitMessage
the message to display when will skip the goal |
| Fields inherited from interface org.apache.maven.plugin.Mojo |
|---|
ROLE |
| Constructor Summary | |
|---|---|
protected |
AbstractPlugin()
|
protected |
AbstractPlugin(String skipAfterInitMessage)
|
| Method Summary | |
|---|---|
protected boolean |
acceptPackaging(Plugin.Packaging... packages)
Accept the project's packaging between some given. |
protected void |
addCompileSourceRoots(File srcDir)
Add a given directory in maven project's compile source roots (if not already present). |
protected void |
addDirectoryToUrlsList(File directory,
List<URL> urls,
Set<String> done)
Add the given directory in urls if not already included. |
protected void |
addResourceDir(String dir)
Add a new resource location to the maven project (in not already present). |
protected void |
addTestCompileSourceRoots(File srcDir)
Add a given directory in maven project's test compile source roots (if not already present). |
protected void |
addTestResourceDir(String dir)
Add a new test resource location to the maven project (in not already present). |
protected void |
addUrlToUrlsList(URL url,
List<URL> urls,
Set<String> done)
Add the given url in urls if not already included. |
protected boolean |
checkPackaging()
Check if the project packaging is acceptable for the mojo. |
protected void |
checkResource(File f)
Check that the given resource exists in a simple fs file or in the classPath. |
protected boolean |
checkRunOnceDone(boolean runOnce,
boolean onlyForRoot,
Date buildStartTime,
Date newStartTime)
|
void |
copyFile(File srcFile,
File destFile)
Copy a file to a given locationand logging. |
protected abstract void |
doAction()
Do plugin action. |
void |
execute()
|
File |
getFileFromBasedir(String... paths)
Recupere le fichier donnée à partir de son chemin relatif sur le basedir du projet maven. |
protected Map<String,String> |
getFilesToTreate(String[] includes,
String[] excludes,
File srcDir,
MirroredFileUpdater updater)
Collect to some files with a mirror. |
protected void |
getFilesToTreateForRoots(String[] includes,
String[] excludes,
List<String> roots,
Map<File,String[]> files,
MirroredFileUpdater updater)
Collects some file. |
protected URL |
getTemplate(File f)
Obtain the url of a file, if file does not exist, try in the classPath. |
protected abstract boolean |
init()
Method to initialize the mojo before doing any concrete actions. |
protected URLClassLoader |
initClassLoader(org.apache.maven.project.MavenProject project,
File src,
boolean addSourcesToClassPath,
boolean testPhase,
boolean addResourcesToClassPath,
boolean addCompileClassPath,
boolean addProjectClassPath)
Init mojo classLoader. |
protected boolean |
isExecutionRoot()
|
protected boolean |
isFileNewerThanPomFile(File f)
Test if a file exists and is newer than the pom file. |
protected boolean |
rejectPackaging(Plugin.Packaging... packages)
Accept the project's packaging if not in given one. |
protected void |
removeCompileSourceRoots(File srcDir)
Remove a given directory in maven project's compile source roots (if present). |
protected void |
removeTestCompileSourceRoots(File srcDir)
Remove a given directory in maven project's test compile source roots (if present). |
void |
writeFile(File destFile,
String content,
String encoding)
Write a content into the given destination file for the given
encoding. |
| Methods inherited from class org.apache.maven.plugin.AbstractMojo |
|---|
getLog, getPluginContext, setLog, setPluginContext |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.nuiton.plugin.Plugin |
|---|
getProject, isVerbose, setProject, setVerbose |
| Methods inherited from interface org.apache.maven.plugin.Mojo |
|---|
getLog, setLog |
| Field Detail |
|---|
protected String skipAfterInitMessage
| Constructor Detail |
|---|
protected AbstractPlugin()
protected AbstractPlugin(String skipAfterInitMessage)
| Method Detail |
|---|
protected abstract boolean init()
throws Exception
doAction() method.
true if mojo is well initialize and something has
to be done in the doAction() method, false
otherwise.
Exception - if any
protected abstract void doAction()
throws Exception
execute() invoke this method only and only if :
checkPackaging() returns true.init() returns true.
Exception - if any
public void execute()
throws org.apache.maven.plugin.MojoExecutionException,
org.apache.maven.plugin.MojoFailureException
execute in interface org.apache.maven.plugin.Mojoorg.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoFailureExceptionprotected boolean checkPackaging()
execute().
Tip: There is two method to simplify the packaging check :
acceptPackaging(org.nuiton.plugin.Plugin.Packaging[])
and
rejectPackaging(org.nuiton.plugin.Plugin.Packaging[])
true if can execute the goal for the packaging of the
project, false otherwise.protected boolean acceptPackaging(Plugin.Packaging... packages)
packages - the accepted packaging
true if the project's packagin is one of the given ones.protected boolean rejectPackaging(Plugin.Packaging... packages)
packages - the rejecting packagings
true if the project's packaging is not in the given ones.protected boolean isExecutionRoot()
true if project is the root execution project
protected boolean checkRunOnceDone(boolean runOnce,
boolean onlyForRoot,
Date buildStartTime,
Date newStartTime)
runOnce - onlyForRoot - buildStartTime - newStartTime -
true if the goal was already invokedpublic File getFileFromBasedir(String... paths)
paths - les paths pour atteindre le fichier ou le répertoire
public void copyFile(File srcFile,
File destFile)
throws org.apache.maven.plugin.MojoExecutionException
srcFile - represents the file to copy.destFile - file name of destination file.
org.apache.maven.plugin.MojoExecutionException - with a message if an
error occurs.
public void writeFile(File destFile,
String content,
String encoding)
throws IOException
content into the given destination file for the given
encoding.
destFile - location where to write the contentcontent - content ot write in the fileencoding - the enconding of the file
IOException - if any pb while writing the content into the fileprotected boolean isFileNewerThanPomFile(File f)
f - the file to test
true if file exists and is newer than the pom file,
false otherwise.
protected void getFilesToTreateForRoots(String[] includes,
String[] excludes,
List<String> roots,
Map<File,String[]> files,
MirroredFileUpdater updater)
includes - includesexcludes - excludesroots - root directories to treatefiles - cache of file detected indexed by their root directoryupdater -
protected Map<String,String> getFilesToTreate(String[] includes,
String[] excludes,
File srcDir,
MirroredFileUpdater updater)
includes - includesexcludes - excludessrcDir - the directory to treateupdater - an updater (will give the mirrored files)
protected void addCompileSourceRoots(File srcDir)
srcDir - the location to include in compile source rootsprotected void removeCompileSourceRoots(File srcDir)
srcDir - the location to remove from compile source rootsprotected void addTestCompileSourceRoots(File srcDir)
srcDir - the location to include in test compile source rootsprotected void removeTestCompileSourceRoots(File srcDir)
srcDir - the location to remove from test compile source rootsprotected void addResourceDir(String dir)
dir - the new resource location to addprotected void addTestResourceDir(String dir)
dir - the new resource location to add
protected URLClassLoader initClassLoader(org.apache.maven.project.MavenProject project,
File src,
boolean addSourcesToClassPath,
boolean testPhase,
boolean addResourcesToClassPath,
boolean addCompileClassPath,
boolean addProjectClassPath)
throws MalformedURLException
project - the maven projectsrc - the source directoryaddSourcesToClassPath - a flag to a maven sources to classLoadertestPhase - a flag to specify if we are in a test phase (changes the classLoader)addResourcesToClassPath - flag to add maven's resources to classLoaderaddCompileClassPath - flag to add maven's project compile classPath to classLoaderaddProjectClassPath - flag to add maven'es project dependecies to classLoader
MalformedURLException
protected void addDirectoryToUrlsList(File directory,
List<URL> urls,
Set<String> done)
throws MalformedURLException
directory in urls if not already included.
Note: We use a extra list to store file string representation, since
we do NOT want any url resolution and the URL.equals(java.lang.Object) is
doing some...
directory - the directory to insert in urlsurls - list of urlsdone - list of string representation of urls
MalformedURLException - if pb while converting file to url
protected void addUrlToUrlsList(URL url,
List<URL> urls,
Set<String> done)
url in urls if not already included.
Note: We use a extra list to store file string representation, since
we do NOT want any url resolution and the URL.equals(java.lang.Object) is
doing some..
url - the url to insert in urlsurls - list of urlsdone - list of string representation of urls
protected URL getTemplate(File f)
throws IOException
f - the required resource file.
IOException - for any error while looking up for the url of the resources
protected void checkResource(File f)
throws IOException
f - the required resource file.
IOException - for any error while looking up for the resources content.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||