Package com.norconex.commons.lang.jar
Class JarCopier
java.lang.Object
com.norconex.commons.lang.jar.JarCopier
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
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classEncapsulate target jar conflict resolution options. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDeprecated.static final intDeprecated.UseJarCopier(OnJarConflict)instead.static final intDeprecated.UseJarCopier(OnJarConflict)instead withJarCopier.OnJarConflict.SourceAction.NOOP.static final intDeprecated.UseJarCopier(OnJarConflict)instead withJarCopier.OnJarConflict.SourceAction.COPY.static final intDeprecated. -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.JarCopier(int strategy) Deprecated.UseJarCopier(OnJarConflict)instead.JarCopier(@NonNull JarCopier.OnJarConflict onJarConflict) Constructor with custom behavior for jar conflict resolution. -
Method Summary
Modifier and TypeMethodDescriptionvoidcopyJarDirectory(@NonNull File sourceDirectory, @NonNull File targetDirectory) Copies jars from a source directory to a target one taking into consideration potential jar duplicates.voidcopyJarDirectory(@NonNull String sourceDirectory, @NonNull String targetDirectory) Copies jars from a source directory to a target one taking into consideration potential jar duplicates.voidcopyJarFile(@NonNull JarFile sourceJarFile, @NonNull File targetDirectory) Copies a single Jar to a target directory, taking into consideration Jar versions.voidcopyJarFile(@NonNull File sourceJarFile, File targetDirectory) Copies a single Jar to a target directory, taking into consideration Jar versions.voidcopyJarFile(@NonNull String sourceJarFile, @NonNull String toDirectory) Copies a single Jar to a target directory, taking into consideration Jar versions.intDeprecated.static void
-
Field Details
-
STRATEGY_RENAME_COPY
Deprecated.Copy source Jar only if greater or same version as target Jar after renaming target Jar (.bak-[timestamp]).- See Also:
-
STRATEGY_DELETE_COPY
Deprecated.Copy source Jar only if greater or same version as target Jar after deleting target Jar.- See Also:
-
STRATEGY_NO_COPY
Deprecated.UseJarCopier(OnJarConflict)instead withJarCopier.OnJarConflict.SourceAction.NOOP.Do not copy source Jar (leave target Jar as is).- See Also:
-
STRATEGY_PLAIN_COPY
Deprecated.UseJarCopier(OnJarConflict)instead withJarCopier.OnJarConflict.SourceAction.COPY.Copy source Jar regardless of target Jar (may overwrite or cause mixed versions).- See Also:
-
STRATEGY_INTERACTIVE
Deprecated.UseJarCopier(OnJarConflict)instead.Interactive, let the user chose (requires execution on command prompt).- See Also:
-
-
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
Constructor with custom behavior for jar conflict resolution.- Parameters:
onJarConflict- conflict resolution options- Since:
- 3.0.0
-
JarCopier
Deprecated.UseJarCopier(OnJarConflict)instead.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 fromtargetDirectory- 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 fromtargetDirectory- 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 copytoDirectory- 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 copytargetDirectory- 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 copytargetDirectory- directory to copy the jar into- Throws:
IOException- problem copying files- Since:
- 3.0.0
-
main
- Throws:
IOException
-
getStrategy
Deprecated.Gets the strategy used when encountering duplicates or version conflicts.- Returns:
-1.
-
JarCopier(OnJarConflict)instead withJarCopier.OnJarConflict.SourceAction.COPY_IF_GREATER_OR_EQUIVALENTandJarCopier.OnJarConflict.TargetAction.DELETE.