Package com.norconex.commons.lang.jar
Class JarCopier
- java.lang.Object
-
- com.norconex.commons.lang.jar.JarCopier
-
public class JarCopier extends Object
Performs a version-sensitive copy a Jar file or directory containing Jar files over to another directory. When in interactive mode, the user will be prompted to decide how to handle duplicate Jars. Interactive mode requires this application to be run from a command prompt.- Since:
- 1.10.0
- Author:
- Pascal Essiembre
-
-
Field Summary
Fields Modifier and Type Field Description static intSTRATEGY_DELETE_COPYCopy source Jar only if greater or same version as target Jar after deleting target Jar.static intSTRATEGY_INTERACTIVEInteractive, let the user chose (requires execution on command prompt).static intSTRATEGY_NO_COPYDo not copy source Jar (leave target Jar as is).static intSTRATEGY_PLAIN_COPYCopy source Jar regardless of target Jar (may overwrite or cause mixed versions).static intSTRATEGY_RENAME_COPYCopy source Jar only if greater or same version as target Jar after renaming target Jar (.bak-[timestamp]).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcopyJarDirectory(File fromJarDirectory, File toJarDirectory)Copies Jars from a source directory to a target one taking into consideration Jar versions.voidcopyJarDirectory(String fromJarDirectory, String toJarDirectory)Copies Jars from a source directory to a target one taking into consideration Jar versions.voidcopyJarFile(File sourceJarFile, File toDirectory)Copies a single Jar to a target directory, taking into consideration Jar versions.voidcopyJarFile(String sourceJarFile, String toDirectory)Copies a single Jar to a target directory, taking into consideration Jar versions.intgetStrategy()Gets the strategy used when encountering duplicates or version conflicts.static voidmain(String[] args)
-
-
-
Field Detail
-
STRATEGY_RENAME_COPY
public static final int STRATEGY_RENAME_COPY
Copy source Jar only if greater or same version as target Jar after renaming target Jar (.bak-[timestamp]).- See Also:
- Constant Field Values
-
STRATEGY_DELETE_COPY
public static final int STRATEGY_DELETE_COPY
Copy source Jar only if greater or same version as target Jar after deleting target Jar.- See Also:
- Constant Field Values
-
STRATEGY_NO_COPY
public static final int STRATEGY_NO_COPY
Do not copy source Jar (leave target Jar as is).- See Also:
- Constant Field Values
-
STRATEGY_PLAIN_COPY
public static final int STRATEGY_PLAIN_COPY
Copy source Jar regardless of target Jar (may overwrite or cause mixed versions).- See Also:
- Constant Field Values
-
STRATEGY_INTERACTIVE
public static final int STRATEGY_INTERACTIVE
Interactive, let the user chose (requires execution on command prompt).- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JarCopier
public JarCopier()
Constructor. Only source Jars with greater or equal versions than their existing target will be copied over, and conflicting Jars will be renamed in the target directory (suffixed with .bak-[timestamp]). Same as invokingJarCopier(int)withSTRATEGY_RENAME_COPY.
-
JarCopier
public JarCopier(int strategy)
Constructor.- Parameters:
strategy- the strategy to use when encountering duplicates/conflicts
-
-
Method Detail
-
getStrategy
public int getStrategy()
Gets the strategy used when encountering duplicates or version conflicts.- Returns:
- strategy id
-
copyJarDirectory
public void copyJarDirectory(String fromJarDirectory, String toJarDirectory) throws IOException
Copies Jars from a source directory to a target one taking into consideration Jar versions.- Parameters:
fromJarDirectory- directory to copy Jars fromtoJarDirectory- directory to copy Jars to- Throws:
IOException- problem copying files
-
copyJarDirectory
public void copyJarDirectory(File fromJarDirectory, File toJarDirectory) throws IOException
Copies Jars from a source directory to a target one taking into consideration Jar versions.- Parameters:
fromJarDirectory- directory to copy Jars fromtoJarDirectory- directory to copy Jars to- Throws:
IOException- problem copying files
-
copyJarFile
public void copyJarFile(String sourceJarFile, String toDirectory) throws IOException
Copies a single Jar to a target directory, taking into consideration Jar versions.- Parameters:
sourceJarFile- the Jar file to copytoDirectory- directory to copy the jar into- Throws:
IOException- problem copying files
-
copyJarFile
public void copyJarFile(File sourceJarFile, File toDirectory) throws IOException
Copies a single Jar to a target directory, taking into consideration Jar versions.- Parameters:
sourceJarFile- the Jar file to copytoDirectory- directory to copy the jar into- Throws:
IOException- problem copying files
-
main
public static void main(String[] args) throws IOException
- Throws:
IOException
-
-