public class PluginHelper extends Object
| Modifier and Type | Field and Description |
|---|---|
protected static double[] |
memoryFactors |
protected static String[] |
memoryUnites |
static String |
SNAPSHOT_SUFFIX |
protected static double[] |
timeFactors |
protected static String[] |
timeUnites |
| Constructor and Description |
|---|
PluginHelper() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addResourceDir(File dir,
org.apache.maven.project.MavenProject project,
List<?> resources,
String... includes)
Add the directory as a resource in the given resource list.
|
static boolean |
addResourceDir(File dir,
org.apache.maven.project.MavenProject project,
String... includes)
Add the directory as a resource of the given project.
|
static boolean |
addTestResourceDir(File dir,
org.apache.maven.project.MavenProject project,
String... includes)
Add thedirectory as a test resource of the given project.
|
static void |
checkEncoding(PluginWithEncoding mojo)
Method to be invoked in init phase to check sanity of
PluginWithEncoding.getEncoding(). |
static String |
convert(long value,
double[] factors,
String[] unites) |
static String |
convertMemory(long value) |
static String |
convertTime(long value) |
static String |
convertTime(long value,
long value2) |
static void |
copy(File source,
File target)
Permet de copier le fichier source vers le fichier cible.
|
static void |
copyFiles(File src,
File dst,
String[] includes,
String[] excludes,
boolean overwrite) |
static void |
copyFiles(PluginIOContext p,
String[] includes,
String[] excludes,
boolean overwrite) |
static boolean |
createDirectoryIfNecessary(File dir)
Cretae the directory (and his parents) if necessary.
|
static void |
createNewFile(File file)
Create the given file.
|
static void |
deleteFile(File file)
Delete the given file.
|
static void |
expandFile(File src,
File dst,
String[] includes,
boolean overwrite) |
static void |
expandFiles(PluginIOContext p,
String[] includes,
String[] excludes,
String[] zipIncludes,
boolean overwrite) |
static SortedSet<String> |
getEmptyKeys(Map<?,?> map)
Obtenir les clefs de toutes les valeurs nulles ou vide a partir d'un
dictionnaire donne.
|
static File |
getFile(File base,
String... paths) |
static List<File> |
getIncludedFiles(File dir,
String[] includes,
String[] excludes) |
static String[] |
getLines(File src) |
static File[] |
getLinesAsFiles(File src) |
static URL[] |
getLinesAsURL(File src) |
static String |
getRelativePath(File base,
File file) |
static URL |
getUrl(URL baseUrl,
String suffix)
suffix a given
baseUrl with the given suffix |
static String |
prefixLines(String prefix,
String prefixForEmpty,
String content)
Prefix the lines of the given content with a given prefix.
|
static String |
readAsString(File file,
String encoding)
Permet de lire un fichier et de retourner sont contenu sous forme d'une
chaine de carateres
|
static String |
readAsString(Reader reader)
Permet de lire un fichier et de retourner sont contenu sous forme d'une
chaine de carateres
|
static String |
removeSnapshotSuffix(String versionId) |
static void |
renameFile(File file,
File destination)
Rename the given file to a new destination.
|
static void |
setLastModified(File file,
long lastModified) |
static String[] |
splitAndTrim(String txt,
String separator)
Split the given
text using the separator and trim each
part of result. |
static <O> List<O> |
toGenericList(List<?> list,
Class<O> type)
Permet de convertir une liste non typee, en une liste typee.
|
static void |
writeString(File file,
String content,
String encoding)
Sauvegarde un contenu dans un fichier.
|
public static final String SNAPSHOT_SUFFIX
protected static final double[] timeFactors
protected static final String[] timeUnites
protected static final double[] memoryFactors
protected static final String[] memoryUnites
public static <O> List<O> toGenericList(List<?> list, Class<O> type) throws IllegalArgumentException
O - le type des objets de la listelist - la liste a convertirtype - le type des elements de la listeIllegalArgumentException - si un element de la liste en entree
n'est pas en adequation avec le type
voulue.public static String convertMemory(long value)
public static String convertTime(long value)
public static String convertTime(long value, long value2)
public static String[] splitAndTrim(String txt, String separator)
text using the separator and trim each
part of result.txt - text to splitseparator - the split separatorpublic static String prefixLines(String prefix, String prefixForEmpty, String content) throws IOException
prefix - prefix to add on each line of textprefixForEmpty - prefix to add for empty linescontent - the text to treateIOException - if any reading problempublic static SortedSet<String> getEmptyKeys(Map<?,?> map)
map - le dictionner a parcourirpublic static boolean addResourceDir(File dir, org.apache.maven.project.MavenProject project, String... includes)
dir - the directory to addproject - the project to updateincludes - the includes of the resourcetrue if the resources was added (not already existing)public static boolean addTestResourceDir(File dir, org.apache.maven.project.MavenProject project, String... includes)
dir - the directory to addproject - the project to updateincludes - the includes of the resourcetrue if the resources was added (not already existing)public static boolean addResourceDir(File dir, org.apache.maven.project.MavenProject project, List<?> resources, String... includes)
dir - the directory to addproject - the project involvedresources - the list of existing resourcesincludes - includes of the new resourcestrue if the resource was added (not already existing)public static boolean createDirectoryIfNecessary(File dir) throws IOException
dir - the directory to create if not exisitingtrue if directory was created, false if was no
need to create itIOException - if could not create directorypublic static void createNewFile(File file) throws IOException
file - the file to createIOException - if could not create the filepublic static void deleteFile(File file) throws IOException
file - the file to deleteIOException - if could not delete the filepublic static void renameFile(File file, File destination) throws IOException
file - the file to renamedestination - the destination fileIOException - if could not rename the filepublic static void setLastModified(File file, long lastModified) throws IOException
IOExceptionpublic static void copy(File source, File target) throws IOException
source - le fichier sourcetarget - le fichier cibleIOException - Erreur de copiepublic static String readAsString(File file, String encoding) throws IOException
file - le fichier a lireencoding - encoding to read fileIOException - if IO pbpublic static String readAsString(Reader reader) throws IOException
reader - la source alireIOException - if IO pbpublic static void writeString(File file, String content, String encoding) throws IOException
file - le fichier a ecrirecontent - le contenu du fichierencoding - l'encoding d'ecritureIOException - if IO pbpublic static List<File> getIncludedFiles(File dir, String[] includes, String[] excludes)
public static void copyFiles(File src, File dst, String[] includes, String[] excludes, boolean overwrite) throws IOException
IOExceptionpublic static void copyFiles(PluginIOContext p, String[] includes, String[] excludes, boolean overwrite) throws IOException
IOExceptionpublic static void expandFiles(PluginIOContext p, String[] includes, String[] excludes, String[] zipIncludes, boolean overwrite) throws IOException
IOExceptionpublic static void expandFile(File src, File dst, String[] includes, boolean overwrite) throws IOException
IOExceptionpublic static String[] getLines(File src) throws IOException
src - the source file to readIOException - if any pb while reading filepublic static File[] getLinesAsFiles(File src) throws IOException
src - the source file to readIOException - if any pb while reading filepublic static URL[] getLinesAsURL(File src) throws IOException
src - the source file to readIOException - if any pb while reading filepublic static URL getUrl(URL baseUrl, String suffix) throws IllegalArgumentException
baseUrl with the given suffixbaseUrl - base url to usesuffix - suffix to addIllegalArgumentException - if malformed url.public static void checkEncoding(PluginWithEncoding mojo)
PluginWithEncoding.getEncoding().
If no encoding was filled, then use the default for system
(via file.encoding environement property).
Note: If mojo is not implementing PluginWithEncoding,
nothing is done.mojo - the mojo to check.Copyright © 2009–2013 CodeLutin. All rights reserved.