Skip to content

Commit

Permalink
Remove apache commons dependency and integrate static methods to chec…
Browse files Browse the repository at this point in the history
…k OS
  • Loading branch information
retiutut committed Sep 26, 2023
1 parent 91082ff commit c05ea75
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
52 changes: 51 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,54 @@ compiled/
java-package/openbci_gui_helpers/target/

# VS Code
.vscode/
.vscode/
ALL_BUILD.vcxproj
ALL_BUILD.vcxproj.filters
cmake_install.cmake
CMakeCache.txt
GanglionNativeScan.vcxproj
GanglionNativeScan.vcxproj.filters
GanglionScan.vcxproj
GanglionScan.vcxproj.filters
openbci-gui-helpers.sln
ZERO_CHECK.vcxproj
ZERO_CHECK.vcxproj.filters
3rdparty/SimpleBLE/simpleble/simpleble-c.vcxproj
3rdparty/SimpleBLE/simpleble/simpleble-c.vcxproj.filters
3rdparty/SimpleBLE/simpleble/SimpleBLE.sln
3rdparty/SimpleBLE/simpleble/simpleble.vcxproj
3rdparty/SimpleBLE/simpleble/simpleble.vcxproj.filters
3rdparty/SimpleBLE/simpleble/VERSION
3rdparty/SimpleBLE/simpleble/CMakeFiles/generate.stamp
3rdparty/SimpleBLE/simpleble/CMakeFiles/generate.stamp.depend
3rdparty/SimpleBLE/simpleble/export/simpleble/export.h
3rdparty/SimpleBLE/simpleble/libfmt/FMT.sln
3rdparty/SimpleBLE/simpleble/libfmt/fmt.vcxproj
3rdparty/SimpleBLE/simpleble/libfmt/fmt.vcxproj.filters
3rdparty/SimpleBLE/simpleble/libfmt/CMakeFiles/generate.stamp
3rdparty/SimpleBLE/simpleble/libfmt/CMakeFiles/generate.stamp.depend
CMakeFiles/cmake.check_cache
CMakeFiles/CMakeConfigureLog.yaml
CMakeFiles/generate.stamp
CMakeFiles/generate.stamp.depend
CMakeFiles/generate.stamp.list
CMakeFiles/TargetDirectories.txt
CMakeFiles/169bdb6ecb54b9cb29a827f249608a2d/generate.stamp.rule
CMakeFiles/3.27.4/CMakeCXXCompiler.cmake
CMakeFiles/3.27.4/CMakeDetermineCompilerABI_CXX.bin
CMakeFiles/3.27.4/CMakeRCCompiler.cmake
CMakeFiles/3.27.4/CMakeSystem.cmake
CMakeFiles/3.27.4/VCTargetsPath.txt
CMakeFiles/3.27.4/VCTargetsPath.vcxproj
CMakeFiles/3.27.4/CompilerIdCXX/CMakeCXXCompilerId.cpp
CMakeFiles/3.27.4/CompilerIdCXX/CompilerIdCXX.vcxproj
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.exe.recipe
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.command.1.tlog
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.read.1.tlog
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CL.write.1.tlog
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/CompilerIdCXX.lastbuildstate
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.command.1.tlog
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.read.1.tlog
CMakeFiles/3.27.4/CompilerIdCXX/Debug/CompilerIdCXX.tlog/link.write.1.tlog
CMakeFiles/3.27.4/x64/Debug/VCTargetsPath.recipe
CMakeFiles/3.27.4/x64/Debug/VCTargetsPath.tlog/VCTargetsPath.lastbuildstate
10 changes: 0 additions & 10 deletions java-package/openbci_gui_helpers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,6 @@
<version>5.10.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import java.nio.file.Files;
import java.util.ArrayList;

import org.apache.commons.lang3.SystemUtils;

import com.google.gson.Gson;
import com.sun.jna.Library;
import com.sun.jna.Native;
Expand All @@ -30,11 +28,11 @@ private interface DllNativeInterface extends Library {

String lib_name = "libGanglionScan.so";
String lib_native_name = "libGanglionNativeScan.so";
if (SystemUtils.IS_OS_WINDOWS) {
if (isWindows()) {
lib_name = "GanglionScan.dll";
lib_native_name = "GanglionNativeScan.dll";

} else if (SystemUtils.IS_OS_MAC) {
} else if (isMac()) {
lib_name = "libGanglionScan.dylib";
lib_native_name = "libGanglionNativeScan.dylib";
}
Expand All @@ -55,7 +53,7 @@ private static String unpack_from_jar(String lib_name) {
if (file.exists())
file.delete();
link = (GUIHelper.class.getResourceAsStream(lib_name));
if (SystemUtils.IS_OS_MAC) {
if (isMac()) {
String jarPath = GUIHelper.class.getProtectionDomain().getCodeSource().getLocation().getPath();
File jarFile = new File(jarPath);
String libPathString = jarFile.getParentFile().getAbsolutePath() + File.separator + lib_name;
Expand Down Expand Up @@ -120,4 +118,12 @@ public static GanglionDevice[] scan_for_ganglions(int timeout_sec) throws Gangli

return uniqueDevices.toArray(new GanglionDevice[uniqueDevices.size()]);
}

private static boolean isWindows() {
return System.getProperty("os.name").toLowerCase().contains("windows");
}

private static boolean isMac() {
return System.getProperty("os.name").toLowerCase().contains("mac");
}
}

0 comments on commit c05ea75

Please sign in to comment.