Changeset 34713 in osm
- Timestamp:
- 2018-11-01T15:24:19+01:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/javafx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/javafx/build.xml
r34705 r34713 22 22 <property name="plugin.stage" value="5"/> 23 23 24 <!-- ** include targets that all plugins have in common ** --> 24 <condition property="isWindows"><os family="Windows"/></condition> 25 <condition property="isUnix"><os family="Unix"/></condition> 26 <condition property="isMac"><os family="Mac"/></condition> 27 <property name="plugin.dist.dir" location="../../dist"/> 28 <property name="plugin.jar" location="${plugin.dist.dir}/${ant.project.name}-windows.jar" if:set="isWindows"/> 29 <property name="plugin.jar" location="${plugin.dist.dir}/${ant.project.name}-osx.jar" if:set="isMac"/> 30 <property name="plugin.jar" location="${plugin.dist.dir}/${ant.project.name}-unixoid.jar" if:set="isUnix"/> 31 32 <!-- ** include targets that all plugins have in common ** --> 25 33 <import file="../build-common.xml"/> 26 34 … … 78 86 </jar> 79 87 <delete dir="${plugin.lib.dir}/@{qualifier}" failonerror="false" /> 80 <copy file="@{jar}" tofile="${plugin.jar}" if:set="@{copy}" />81 88 </sequential> 82 89 </macrodef> -
applications/editors/josm/plugins/javafx/src/org/openstreetmap/josm/plugins/javafx/JavaFxPlugin.java
r34703 r34713 16 16 import java.security.CodeSource; 17 17 import java.util.Enumeration; 18 import java.util.List; 18 19 import java.util.Objects; 19 20 import java.util.zip.ZipEntry; … … 37 38 * @param info plugin info 38 39 * @param ext native libraries extension 40 * @param orderedNativeLibraries native librarires that must be loaded in this order 39 41 */ 40 protected JavaFxPlugin(PluginInformation info, String ext ) {42 protected JavaFxPlugin(PluginInformation info, String ext, List<String> orderedNativeLibraries) { 41 43 super(info); 42 44 AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class); 43 45 extractNativeLibs(ext); 44 loadNativeLibs(ext );46 loadNativeLibs(ext, orderedNativeLibraries); 45 47 } 46 48 … … 80 82 private final ClassLoader ccl = Thread.currentThread().getContextClassLoader(); 81 83 private final String ext; 84 private final List<String> orderedNativeLibraries; 82 85 83 public LibVisitor(String ext ) {86 public LibVisitor(String ext, List<String> orderedNativeLibraries) { 84 87 this.ext = Objects.requireNonNull(ext); 88 this.orderedNativeLibraries = Objects.requireNonNull(orderedNativeLibraries); 85 89 } 86 90 … … 88 92 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { 89 93 if (ccl instanceof DynamicURLClassLoader) { 90 if (file.endsWith(ext)) {91 Logging.debug("Loading " + file);92 System.load(file.toAbsolutePath().toString());93 } else if ( file.endsWith(".jar")) {94 Logging.debug("Loading " + file);94 String path = file.toAbsolutePath().toString(); 95 if (path.endsWith(ext) && !orderedNativeLibraries.contains(file.getFileName().toString())) { 96 loadNativeLib(path); 97 } else if (path.endsWith(".jar")) { 98 Logging.debug("Loading {0}", path); 95 99 ((DynamicURLClassLoader) ccl).addURL(file.toUri().toURL()); 96 100 } … … 103 107 } 104 108 105 private void loadNativeLibs(String ext) {109 private static void loadNativeLib(String absolutePath) { 106 110 try { 107 Files.walkFileTree(getNativeDir(), new LibVisitor(ext)); 111 Logging.debug("Loading {0}", absolutePath); 112 System.load(absolutePath); 113 } catch (LinkageError e) { 114 Logging.error(e); 115 } 116 } 117 118 private static void loadNativeLibs(String ext, List<String> orderedNativeLibraries) { 119 try { 120 Path nativeDir = getNativeDir(); 121 Files.walkFileTree(nativeDir, new LibVisitor(ext, orderedNativeLibraries)); 122 for (String lib : orderedNativeLibraries) { 123 loadNativeLib(nativeDir.resolve(lib).toAbsolutePath().toString()); 124 } 108 125 } catch (IOException e) { 109 126 Logging.error(e); -
applications/editors/josm/plugins/javafx/src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginOsx.java
r34703 r34713 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.javafx; 3 4 import java.util.Arrays; 3 5 4 6 import org.openstreetmap.josm.plugins.PluginInformation; … … 10 12 11 13 /** 12 * Constructs a new {@code OpenJfxPlugin}.14 * Constructs a new {@code JavaFxPluginOsx}. 13 15 * @param info plugin info 14 16 */ 15 17 public JavaFxPluginOsx(PluginInformation info) { 16 super(info, ".dylib" );18 super(info, ".dylib", Arrays.asList()); 17 19 } 18 20 } -
applications/editors/josm/plugins/javafx/src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginUnixoid.java
r34703 r34713 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.javafx; 3 4 import java.util.Arrays; 3 5 4 6 import org.openstreetmap.josm.plugins.PluginInformation; … … 10 12 11 13 /** 12 * Constructs a new {@code OpenJfxPlugin}.14 * Constructs a new {@code JavaFxPluginUnixoid}. 13 15 * @param info plugin info 14 16 */ 15 17 public JavaFxPluginUnixoid(PluginInformation info) { 16 super(info, ".so" );18 super(info, ".so", Arrays.asList()); 17 19 } 18 20 } -
applications/editors/josm/plugins/javafx/src/org/openstreetmap/josm/plugins/javafx/JavaFxPluginWindows.java
r34703 r34713 1 1 // License: GPL. For details, see LICENSE file. 2 2 package org.openstreetmap.josm.plugins.javafx; 3 4 import java.util.Arrays; 3 5 4 6 import org.openstreetmap.josm.plugins.PluginInformation; … … 10 12 11 13 /** 12 * Constructs a new {@code OpenJfxPlugin}.14 * Constructs a new {@code JavaFxPluginWindows}. 13 15 * @param info plugin info 14 16 */ 15 17 public JavaFxPluginWindows(PluginInformation info) { 16 super(info, ".dll" );18 super(info, ".dll", Arrays.asList("fxplugins.dll")); 17 19 } 18 20 }
Note:
See TracChangeset
for help on using the changeset viewer.