Class 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 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 invoking JarCopier(int) with STRATEGY_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 from
        toJarDirectory - 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 from
        toJarDirectory - 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 copy
        toDirectory - 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 copy
        toDirectory - directory to copy the jar into
        Throws:
        IOException - problem copying files