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
  • Field Details

  • Constructor Details

    • 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]).
    • JarCopier

      public JarCopier(@NonNull @NonNull JarCopier.OnJarConflict onJarConflict)
      Constructor with custom behavior for jar conflict resolution.
      Parameters:
      onJarConflict - conflict resolution options
      Since:
      3.0.0
    • JarCopier

      @Deprecated(since="3.0.0") public JarCopier(int strategy)
      Deprecated.
      Constructor.
      Parameters:
      strategy - the strategy to use when encountering duplicates/conflicts
  • Method Details

    • copyJarDirectory

      public void copyJarDirectory(@NonNull @NonNull String sourceDirectory, @NonNull @NonNull String targetDirectory) throws IOException
      Copies jars from a source directory to a target one taking into consideration potential jar duplicates.
      Parameters:
      sourceDirectory - directory to copy Jars from
      targetDirectory - directory to copy Jars to
      Throws:
      IOException - problem copying files
    • copyJarDirectory

      public void copyJarDirectory(@NonNull @NonNull File sourceDirectory, @NonNull @NonNull File targetDirectory) throws IOException
      Copies jars from a source directory to a target one taking into consideration potential jar duplicates.
      Parameters:
      sourceDirectory - directory to copy Jars from
      targetDirectory - directory to copy Jars to
      Throws:
      IOException - problem copying files
    • copyJarFile

      public void copyJarFile(@NonNull @NonNull String sourceJarFile, @NonNull @NonNull 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(@NonNull @NonNull File sourceJarFile, File targetDirectory) throws IOException
      Copies a single Jar to a target directory, taking into consideration Jar versions.
      Parameters:
      sourceJarFile - the Jar file to copy
      targetDirectory - directory to copy the jar into
      Throws:
      IOException - problem copying files
    • copyJarFile

      public void copyJarFile(@NonNull @NonNull JarFile sourceJarFile, @NonNull @NonNull File targetDirectory) throws IOException
      Copies a single Jar to a target directory, taking into consideration Jar versions.
      Parameters:
      sourceJarFile - the Jar file to copy
      targetDirectory - directory to copy the jar into
      Throws:
      IOException - problem copying files
      Since:
      3.0.0
    • main

      public static void main(String[] args) throws IOException
      Throws:
      IOException
    • getStrategy

      @Deprecated(since="3.0.0") public int getStrategy()
      Deprecated.
      Gets the strategy used when encountering duplicates or version conflicts.
      Returns:
      -1.