|
||||||||||
| 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.InitState, Plugin.Packaging |
| Field Summary |
|---|
| Fields inherited from interface org.apache.maven.plugin.Mojo |
|---|
ROLE |
| Constructor Summary | |
|---|---|
AbstractPlugin()
|
|
| Method Summary | |
|---|---|
protected boolean |
acceptPackaging(Plugin.Packaging... packages)
Accept the project's packaging between some given. |
protected void |
addCompileSourceRoots(java.io.File srcDir)
Add a given directory in maven project's compile source roots (if not already present). |
protected void |
addDirectoryToUrlsList(java.io.File directory,
java.util.List<java.net.URL> urls,
java.util.Set<java.lang.String> done)
Add the given directory in urls if not already included. |
protected void |
addResourceDir(java.io.File dir,
java.lang.String... includes)
Add a new resource location to the maven project (in not already present). |
protected void |
addResourceDir(java.lang.String dir)
Deprecated. since 1.1.1, prefer use the method addResourceDir(java.io.File, String...) |
protected void |
addTestCompileSourceRoots(java.io.File srcDir)
Add a given directory in maven project's test compile source roots (if not already present). |
protected void |
addTestResourceDir(java.io.File dir,
java.lang.String... includes)
Add a new test resource location to the maven project (in not already present). |
protected void |
addTestResourceDir(java.lang.String dir)
Deprecated. since 1.1.1, prefer use the method addTestResourceDir(java.io.File, String...) |
protected void |
addUrlToUrlsList(java.net.URL url,
java.util.List<java.net.URL> urls,
java.util.Set<java.lang.String> done)
Add the given url in urls if not already included. |
protected void |
afterExecute()
A call back to execute after the execute() is done |
protected void |
backupFile(java.io.File f)
Backups the given file using the getBackupFile(java.io.File) as
destination file. |
protected boolean |
checkPackaging()
Check if the project packaging is acceptable for the mojo. |
protected void |
checkResource(java.io.File f)
Check that the given resource exists in a simple fs file or in the classPath. |
protected boolean |
checkRunOnceDone(boolean runOnce,
boolean onlyForRoot,
java.util.Date buildStartTime,
java.util.Date newStartTime)
Check if an execution was already done according to the given parameters. |
protected boolean |
checkSkip()
Checks if the mojo execution should be skipped. |
void |
copyFile(java.io.File srcFile,
java.io.File destFile)
Copy a file to a given locationand logging. |
protected void |
createDirectoryIfNecessary(java.io.File dir)
Create the directory if necessary. |
protected void |
createNewFile(java.io.File file)
Create a new file. |
protected void |
deleteFile(java.io.File file)
Delete the given file. |
protected abstract void |
doAction()
Do plugin action. |
void |
execute()
|
java.io.File |
getBackupFile(java.io.File file)
|
java.io.File |
getFileFromBasedir(java.lang.String... paths)
Recupere le fichier donnée à partir de son chemin relatif sur le basedir du projet maven. |
protected java.util.Map<java.lang.String,java.lang.String> |
getFilesToTreate(java.lang.String[] includes,
java.lang.String[] excludes,
java.io.File srcDir,
MirroredFileUpdater updater)
Collect to some files with a mirror. |
protected void |
getFilesToTreateForRoots(java.lang.String[] includes,
java.lang.String[] excludes,
java.util.List<java.lang.String> roots,
java.util.Map<java.io.File,java.lang.String[]> files,
MirroredFileUpdater updater)
Collects some file. |
protected java.net.URL |
getTemplate(java.io.File f)
Obtain the url of a file, if file does not exist, try in the classPath. |
protected abstract void |
init()
Method to initialize the mojo before doing any concrete actions. |
protected java.net.URLClassLoader |
initClassLoader(org.apache.maven.project.MavenProject project,
java.io.File src,
boolean addSourcesToClassPath,
boolean testPhase,
boolean addResourcesToClassPath,
boolean addCompileClassPath,
boolean addProjectClassPath)
Init mojo classLoader. |
protected boolean |
isExecutionRoot()
|
protected boolean |
isFileNewerThanPomFile(java.io.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(java.io.File srcDir)
Remove a given directory in maven project's compile source roots (if present). |
protected void |
removeTestCompileSourceRoots(java.io.File srcDir)
Remove a given directory in maven project's test compile source roots (if present). |
protected void |
renameFile(java.io.File file,
java.io.File destination)
Rename the given file to the destination one. |
void |
writeFile(java.io.File destFile,
java.lang.String content,
java.lang.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 |
| Constructor Detail |
|---|
public AbstractPlugin()
| Method Detail |
|---|
protected abstract void init()
throws java.lang.Exception
doAction() method.
// * @return true if mojo is well initialize and something has
// * to be done in the doAction() method, false
// * otherwise.
java.lang.Exception - if any
protected abstract void doAction()
throws java.lang.Exception
execute() invoke this method only and only if :
checkPackaging() returns true.init() returns true.
java.lang.Exception - if any
public final 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 void afterExecute()
execute() is done
protected 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 checkSkip()
false if the mojo should not be executed.protected boolean acceptPackaging(Plugin.Packaging... packages)
packages - the accepted packaging
true if the project's packaging 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,
java.util.Date buildStartTime,
java.util.Date newStartTime)
runOnce - the flagonlyForRoot - a flag tobuildStartTime - the build statrt time (if none means must do it)newStartTime - the current build start time
true if the goal was already invokedpublic java.io.File getFileFromBasedir(java.lang.String... paths)
paths - les paths pour atteindre le fichier ou le répertoire
public void copyFile(java.io.File srcFile,
java.io.File destFile)
throws java.io.IOException
srcFile - represents the file to copy.destFile - file name of destination file.
java.io.IOException - if could not copy file.
public void writeFile(java.io.File destFile,
java.lang.String content,
java.lang.String encoding)
throws java.io.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
java.io.IOException - if any pb while writing the content into the fileprotected boolean isFileNewerThanPomFile(java.io.File f)
f - the file to test
true if file exists and is newer than the pom file,
false otherwise.
protected void getFilesToTreateForRoots(java.lang.String[] includes,
java.lang.String[] excludes,
java.util.List<java.lang.String> roots,
java.util.Map<java.io.File,java.lang.String[]> files,
MirroredFileUpdater updater)
includes - includesexcludes - excludesroots - root directories to treatefiles - cache of file detected indexed by their root directoryupdater - the updater used to detect changes (if none, will get all
the files)
protected java.util.Map<java.lang.String,java.lang.String> getFilesToTreate(java.lang.String[] includes,
java.lang.String[] excludes,
java.io.File srcDir,
MirroredFileUpdater updater)
includes - includesexcludes - excludessrcDir - the directory to treateupdater - an updater (will give the mirrored files)
protected void addCompileSourceRoots(java.io.File srcDir)
srcDir - the location to include in compile source rootsprotected void removeCompileSourceRoots(java.io.File srcDir)
srcDir - the location to remove from compile source rootsprotected void addTestCompileSourceRoots(java.io.File srcDir)
srcDir - the location to include in test compile source rootsprotected void removeTestCompileSourceRoots(java.io.File srcDir)
srcDir - the location to remove from test compile source roots
protected void addResourceDir(java.io.File dir,
java.lang.String... includes)
dir - the new resource location to addincludes - files to include
protected void addTestResourceDir(java.io.File dir,
java.lang.String... includes)
dir - the new resource location to addincludes - files to include@Deprecated protected void addResourceDir(java.lang.String dir)
addResourceDir(java.io.File, String...)
dir - the new resource location to add@Deprecated protected void addTestResourceDir(java.lang.String dir)
addTestResourceDir(java.io.File, String...)
dir - the new resource location to add
protected void createDirectoryIfNecessary(java.io.File dir)
throws java.io.IOException
dir - the directory to create if not already existing
java.io.IOException - if could not create the directory
protected void createNewFile(java.io.File file)
throws java.io.IOException
file - the file to create
java.io.IOException - if could not create the file
protected void deleteFile(java.io.File file)
throws java.io.IOException
file - the file to delete
java.io.IOException - if could not delete the file
protected void renameFile(java.io.File file,
java.io.File destination)
throws java.io.IOException
file - the file to renamedestination - the destination of the file
java.io.IOException - if could not delete the filepublic java.io.File getBackupFile(java.io.File file)
file - the source file
protected void backupFile(java.io.File f)
throws java.io.IOException
getBackupFile(java.io.File) as
destination file.
f - the file to backup
java.io.IOException - if any pb while copying the file
protected java.net.URLClassLoader initClassLoader(org.apache.maven.project.MavenProject project,
java.io.File src,
boolean addSourcesToClassPath,
boolean testPhase,
boolean addResourcesToClassPath,
boolean addCompileClassPath,
boolean addProjectClassPath)
throws java.net.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
java.net.MalformedURLException - if an url was not correct
protected void addDirectoryToUrlsList(java.io.File directory,
java.util.List<java.net.URL> urls,
java.util.Set<java.lang.String> done)
throws java.net.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
java.net.MalformedURLException - if pb while converting file to url
protected void addUrlToUrlsList(java.net.URL url,
java.util.List<java.net.URL> urls,
java.util.Set<java.lang.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 java.net.URL getTemplate(java.io.File f)
throws java.io.IOException
f - the required resource file.
java.io.IOException - for any error while looking up for the url of the resources
protected void checkResource(java.io.File f)
throws java.io.IOException
f - the required resource file.
java.io.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 | |||||||||