mirror of
https://github.com/JFormDesigner/FlatLaf.git
synced 2026-02-13 07:17:13 -06:00
Native libraries: support Gradle cache when running in development environment (issue #800)
This commit is contained in:
@@ -178,21 +178,39 @@ class FlatNativeLibrary
|
|||||||
|
|
||||||
// build library file
|
// build library file
|
||||||
String libraryName = buildLibraryName( jarFile, classifier, ext );
|
String libraryName = buildLibraryName( jarFile, classifier, ext );
|
||||||
File parent = jarFile.getParentFile();
|
File jarDir = jarFile.getParentFile();
|
||||||
|
|
||||||
// check whether native library exists in same directory as jar
|
// check whether native library exists in same directory as jar
|
||||||
File libraryFile = new File( parent, libraryName );
|
File libraryFile = new File( jarDir, libraryName );
|
||||||
if( libraryFile.isFile() )
|
if( libraryFile.isFile() )
|
||||||
return libraryFile;
|
return libraryFile;
|
||||||
|
|
||||||
// if jar is in "lib" directory, then also check whether native library exists
|
// if jar is in "lib" directory, then also check whether native library exists
|
||||||
// in "../bin" directory
|
// in "../bin" directory
|
||||||
if( parent.getName().equalsIgnoreCase( "lib" ) ) {
|
if( jarDir.getName().equalsIgnoreCase( "lib" ) ) {
|
||||||
libraryFile = new File( parent.getParentFile(), "bin/" + libraryName );
|
libraryFile = new File( jarDir.getParentFile(), "bin/" + libraryName );
|
||||||
if( libraryFile.isFile() )
|
if( libraryFile.isFile() )
|
||||||
return libraryFile;
|
return libraryFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// special case: support Gradle cache when running in development environment
|
||||||
|
// <user-home>/.gradle/caches/modules-2/files-2.1/com.formdev/flatlaf/<version>/<hash-1>/flatlaf-<version>.jar
|
||||||
|
// <user-home>/.gradle/caches/modules-2/files-2.1/com.formdev/flatlaf/<version>/<hash-2>/flatlaf-<version>-windows-x86_64.dll
|
||||||
|
String path = jarDir.getAbsolutePath().replace( '\\', '/' );
|
||||||
|
if( path.contains( "/.gradle/caches/" ) ) {
|
||||||
|
File versionDir = jarDir.getParentFile();
|
||||||
|
if( libraryName.contains( versionDir.getName() ) ) {
|
||||||
|
File[] dirs = versionDir.listFiles();
|
||||||
|
if( dirs != null ) {
|
||||||
|
for( File dir : dirs ) {
|
||||||
|
libraryFile = new File( dir, libraryName );
|
||||||
|
if( libraryFile.isFile() )
|
||||||
|
return libraryFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// native library not found
|
// native library not found
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user