From a701b8229950fd9420b58b0cb1cedd94ec09a566 Mon Sep 17 00:00:00 2001 From: Rik Veenboer Date: Wed, 26 Nov 2014 21:26:57 +0000 Subject: [PATCH] Migrate to jlibloader 0.2 --- build.gradle | 7 +- src/main/java/com/jacob/com/JacobObject.java | 22 ----- .../java/com/jacob/com/JacobReleaseInfo.java | 96 ------------------- .../java/com/jacob/com/LibraryLoaderTest.java | 84 ---------------- 4 files changed, 4 insertions(+), 205 deletions(-) delete mode 100644 src/main/java/com/jacob/com/JacobReleaseInfo.java delete mode 100644 src/test/java/com/jacob/com/LibraryLoaderTest.java diff --git a/build.gradle b/build.gradle index 2da254c..ddf93f0 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { } dependencies { - compile 'com.github.boukefalos:jlibloader:0.1' + compile 'com.github.boukefalos:jlibloader:0.2' testCompile 'junit:junit:3.8.1' } @@ -114,7 +114,8 @@ binaries.withType(SharedLibraryBinary) { binary -> jniPom.scopeMappings.mappings.clear() } def builderTask = binary.tasks.builder - nativeJar.into(project.group.replace('.', '/') + '/' + variantName) { from builderTask.outputFile } + def libraryDirectory = project.group.replace('.', '/') + "/${project.archivesBaseName}/${variantName}" + nativeJar.into(libraryDirectory) { from builderTask.outputFile } nativeJar.dependsOn builderTask } @@ -135,7 +136,7 @@ mainPom.withXml { provider -> def dep = deps.appendNode('dependency') dep.appendNode('groupId', 'com.github.boukefalos') dep.appendNode('artifactId', 'jlibloader') - dep.appendNode('version', '0.1') + dep.appendNode('version', '0.2') } jar { diff --git a/src/main/java/com/jacob/com/JacobObject.java b/src/main/java/com/jacob/com/JacobObject.java index d2e598c..2efa375 100644 --- a/src/main/java/com/jacob/com/JacobObject.java +++ b/src/main/java/com/jacob/com/JacobObject.java @@ -68,28 +68,6 @@ public class JacobObject { return DEBUG; } - /** - * Loads JacobVersion.Properties and returns the value of version in it - * - * @deprecated use JacobReleaseInfo.getBuildDate() instead. - * @return String value of version in JacobVersion.Properties or "" if none - */ - @Deprecated - public static String getBuildDate() { - return JacobReleaseInfo.getBuildDate(); - } - - /** - * Loads JacobVersion.Properties and returns the value of version in it - * - * @deprecated use JacobReleaseInfo.getBuildVersion() instead. - * @return String value of version in JacobVersion.Properties or "" if none - */ - @Deprecated - public static String getBuildVersion() { - return JacobReleaseInfo.getBuildVersion(); - } - /** * Very basic debugging function. * diff --git a/src/main/java/com/jacob/com/JacobReleaseInfo.java b/src/main/java/com/jacob/com/JacobReleaseInfo.java deleted file mode 100644 index a41b239..0000000 --- a/src/main/java/com/jacob/com/JacobReleaseInfo.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.jacob.com; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - -/** - * An interface to the version properties file. This code was removed from - * JacobObject because it doesn't belong there. - * - */ -public class JacobReleaseInfo { - - /** - * holds the build version as retrieved from the version properties file - * that exists in the JAR. This can be retrieved by calling the static - * method getBuildVersion() - * - * @see #getBuildVersion() - */ - private static String buildVersion = ""; - /** - * holds the build date as retrieved from the version properties file that - * exists in the JAR This can be retrieved by calling the static method - * getBuildDate() - * - * @see #getBuildDate() - */ - private static String buildDate = ""; - /** the name of the jacob version properties file */ - private static final String PROPERTY_FILE_NAME = "META-INF/JacobVersion.properties"; - - /** - * Loads version information from PROPERTY_FILE_NAME that was built as part - * of this release. - * - * @throws IllegalStateException - * when it can't find the version properties file - */ - private static void loadVersionProperties() { - Properties versionProps = new Properties(); - // can't use system class loader cause won't work in JavaWebStart - InputStream stream = JacobReleaseInfo.class.getClassLoader() - .getResourceAsStream(PROPERTY_FILE_NAME); - // This should never happen. This is an attempt to make something work - // for WebSphere. They may be using some kind of Servlet loader that - // needs an absolute path based search - if (stream == null) { - stream = JacobReleaseInfo.class.getClassLoader() - .getResourceAsStream("/" + PROPERTY_FILE_NAME); - } - // A report came in that WebSphere had trouble finding the file - // so lets trap it. Plus, it's a good idea anyway. - if (stream == null) { - throw new IllegalStateException( - "Can't find " - + PROPERTY_FILE_NAME - + " using JacobReleaseInfo.class.getClassLoader().getResourceAsStream()"); - } else { - try { - versionProps.load(stream); - stream.close(); - buildVersion = (String) versionProps.get("version"); - buildDate = (String) versionProps.get("build.date"); - } catch (IOException ioe) { - ioe.printStackTrace(); - System.err.println("Warning! Couldn't load props " + ioe); - } - } - } - - /** - * loads PROPERT_FILE_NAME and returns the value of version in it - * - * @return String value of version in PROPERT_FILE_NAME or "" if none - */ - public static String getBuildDate() { - if (buildDate.equals("")) { - loadVersionProperties(); - } - return buildDate; - } - - /** - * loads PROPERT_FILE_NAME and returns the value of version in it - * - * @return String value of version in PROPERT_FILE_NAME or "" if none - */ - public static String getBuildVersion() { - if (buildVersion.equals("")) { - loadVersionProperties(); - } - return buildVersion; - } - -} diff --git a/src/test/java/com/jacob/com/LibraryLoaderTest.java b/src/test/java/com/jacob/com/LibraryLoaderTest.java deleted file mode 100644 index 7705f27..0000000 --- a/src/test/java/com/jacob/com/LibraryLoaderTest.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.jacob.com; - -import junit.framework.TestCase; - -/** - * Tests Library loader architecture methods This test requires that jacob.jar - * be compiled and added to the classpath. You will need to refresh the release - * directory so that eclipse knows about jacob.jar. Otherwise you will get a - * "jar not found" dialog. - * - *

- * May need to run with some command line options (including from inside - * Eclipse). Look in the docs area at the Jacob usage document for command line - * options. - * - * @author clay_shooter - * - */ -public class LibraryLoaderTest extends TestCase { - - /** - * verify the architecture switches work - */ - public void testArchitectureVersions() { - System.out.println("running on 32Bit? VM" - + LibraryLoader.shouldLoad32Bit()); - // verify no null pointer is thrown - LibraryLoader.shouldLoad32Bit(); - } - - /** - * verify LibraryLoader.JACOB_DLL_NAME is read by LibraryLoader - */ - public void testJacobDllNameSystemProperty() { - // this test used to run in the reverse order but that caused - // ClassDefNotFound on DEBUG - - // no way to clear a system property once set so lets try setting to - // default - System.setProperty(LibraryLoader.JACOB_DLL_NAME, LibraryLoader - .getPreferredDLLName()); - try { - LibraryLoader.loadJacobLibrary(); - } catch (UnsatisfiedLinkError ule) { - fail("Should have been able to load dll after setting " - + LibraryLoader.JACOB_DLL_NAME + " to " - + LibraryLoader.getPreferredDLLName() + " " - + ule.getMessage()); - } - - // fill with bad dll name and try again - System.setProperty(LibraryLoader.JACOB_DLL_NAME, "xxx"); - try { - LibraryLoader.loadJacobLibrary(); - fail("Should have been unable to load dll with name xxx"); - } catch (UnsatisfiedLinkError ule) { - System.out.println("correctly caught UnsatisfiedLinkError"); - // yes, this is what we want to see when using a bad name - } - } - - /** - * Verifies that we get a preferred DLL name with X86 since we really only - * run the unit tests on 32 bit platforms. - */ - public void testDLLNameContainsProcessorAndVersion() { - System.out.println(LibraryLoader.getPreferredDLLName()); - if (LibraryLoader.shouldLoad32Bit()) { - // we build the package and run the unit tests on X86 - assertTrue(LibraryLoader.getPreferredDLLName() - + "should have contained " - + LibraryLoader.DLL_NAME_MODIFIER_32_BIT, LibraryLoader - .getPreferredDLLName().contains( - LibraryLoader.DLL_NAME_MODIFIER_32_BIT)); - } else { - // we build the package and run the unit tests on X86 - assertTrue(LibraryLoader.getPreferredDLLName() - + "should have contained " - + LibraryLoader.DLL_NAME_MODIFIER_64_BIT, LibraryLoader - .getPreferredDLLName().contains( - LibraryLoader.DLL_NAME_MODIFIER_64_BIT)); - } - } -}