public class LibraryInstaller
extends java.lang.Object
Libraries that are no longer needed can be listed in the file
lib/OBSOLETE, so that they are removed along with older versions of the
current libraries (see removeOldJars() and removeOldNativeLibs()).
| Constructor and Description |
|---|
LibraryInstaller()
Creates a new LibraryInstaller.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addLibrary(java.lang.String libName) |
void |
addLibrary(java.lang.String libName,
java.lang.String linkName)
Adds a native library that is to be accessible through a link with
the name
linkName, such as libiomp5.so for libiomp5.so.2026.1. |
void |
clearJars() |
void |
clearNativeLibs() |
java.util.List<java.lang.String> |
getJarnames()
Returns the names of the jar files in the library list.
|
java.io.File |
getLibDir() |
java.lang.String |
getRemoteSource() |
boolean |
isConnectionException(java.lang.Exception e) |
static void |
main(java.lang.String[] args) |
void |
readLibs(java.io.File file)
Reads the library list from a file (in the format of lib/LIBRARIES),
or from standard input if
file is null. |
void |
readObsolete(java.io.File file)
Reads the obsolete list from a file (in the format of lib/OBSOLETE),
or from standard input if
file is null. |
int |
removeOldJars()
Removes older versions of the jar files in the library list.
|
int |
removeOldNativeLibs()
Removes older versions of the native libraries in the library list.
|
void |
setLibDir(java.lang.String dirPath) |
static void |
setRemoteSource(java.lang.String source) |
boolean |
updateEclipseClasspath(java.io.File cpfile)
Updates the jar file entries of an Eclipse .classpath file so that they
match the jar files in the library list that have no system specifier
(i.e., the jar files that form ArtiSynth's classpath; see
bin/makeClasspath).
|
int |
verifyJars(boolean updateLibs)
Verify that all jar files are present and, if requested, updated.
|
int |
verifyNativeLibs(boolean updateLibs)
Verify that all native libraries are present and, if requested, updated.
|
public LibraryInstaller()
inferLibDir()), and can be reset
using setLibDir(java.lang.String). The folder is not checked here, so that an
alternate folder can still be set if the inferred one does not exist.public java.lang.String getRemoteSource()
public static void setRemoteSource(java.lang.String source)
public void addLibrary(java.lang.String libName)
public void addLibrary(java.lang.String libName,
java.lang.String linkName)
linkName, such as libiomp5.so for libiomp5.so.2026.1. See NativeLibraryManager.verify(String,String).public java.util.List<java.lang.String> getJarnames()
readLibs(java.io.File), this includes only jar files required for the
current system.public void clearJars()
public void clearNativeLibs()
public void setLibDir(java.lang.String dirPath)
public java.io.File getLibDir()
public static void main(java.lang.String[] args)
public int verifyNativeLibs(boolean updateLibs)
throws java.lang.Exception
updateLibs - if true, verifies that each library
is the most recent, and downloads it if it isn't.java.lang.Exceptionpublic boolean isConnectionException(java.lang.Exception e)
public int verifyJars(boolean updateLibs)
throws java.lang.Exception
updateLibs - if true, verifies that each jar file
is the most recent, and downloads it if it isn't.java.lang.Exceptionpublic int removeOldJars()
getJarStem(java.lang.String)) as a jar file that is in the
list and is present in the folder. For example, if the list contains
jogl-all-2.6.0.jar, then jogl-all-2.5.0.jar would be
removed, but only if jogl-all-2.6.0.jar is present. This should
therefore be called after verifyJars(boolean), so that an older version
can still be used if a download fails.
Jar files whose stems match nothing in the list are left alone, as are files that cannot be deleted (which can happen on Windows if they are in use by another process, such as a running instance of ArtiSynth). A warning is printed for the latter.
Jar files listed in the obsolete list (see readObsolete(java.io.File))
are also removed, unless their stems match the stem of a jar file in
the library list (for any system), or they are special jar files.
public int removeOldNativeLibs()
NativeLibraryManager.removeOlderVersions(maspack.fileutil.NativeLibraryManager.LibDesc) for details. This
should be called after verifyNativeLibs(boolean).
Native libraries listed in the obsolete list (see readObsolete(java.io.File)) are also removed, unless they are libraries in the
library list or their links. An exactly named obsolete library is
removed even if another version of it is in the library list. See NativeLibraryManager.removeObsoleteLibraries(java.util.Collection<java.lang.String>, java.util.Collection<java.lang.String>, java.util.Collection<java.lang.String>) for details.
public boolean updateEclipseClasspath(java.io.File cpfile)
throws java.io.IOException
getJarStem(java.lang.String)). Each entry is also given the attribute
optional="true", so that Eclipse does not flag the project as
having build path errors when the jar file is missing (as it is in a
fresh checkout, before the libraries are installed). Other entries, and
the file's
formatting, are left unchanged, and the file is rewritten only if its
contents change, so that Eclipse is not triggered to rebuild
needlessly. Nothing is done if no library list has been read.cpfile - .classpath file to updatetrue if the file was changedjava.io.IOExceptionpublic void readLibs(java.io.File file)
throws java.io.IOException
file is null.java.io.IOExceptionpublic void readObsolete(java.io.File file)
throws java.io.IOException
file is null. Each line
contains the name of an obsolete jar file or native library, optionally
preceded by a system specifier, as in lib/LIBRARIES. Names may contain
'*' wildcards. If no obsolete list is read before removeOldJars() or removeOldNativeLibs() is called, then
OBSOLETE in the library folder is read if present.java.io.IOException