Ignore:
Timestamp:
2018-10-29T14:52:21+01:00 (6 years ago)
Author:
donvip
Message:

see #josm16682 - build 3 smaller native jar files instead of a giant one - speed up generation

Location:
applications/editors/josm/plugins/javafx
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/javafx/build.xml

    r34701 r34703  
    11<?xml version="1.0" encoding="utf-8"?>
    2 <project name="javafx" default="dist" basedir=".">
     2<project name="javafx" default="dist" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
    33    <!-- enter the SVN commit message -->
    44    <property name="commit.message" value="Commit message"/>
     
    66    <property name="plugin.main.version" value="14234"/>
    77
    8         <!-- Configure these properties (replace "..." accordingly).
     8    <!-- Configure these properties (replace "..." accordingly).
    99         See https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins
    1010    -->
    1111    <property name="plugin.author" value="Don-vip"/>
    12     <property name="plugin.class" value="org.openstreetmap.josm.plugins.javafx.JavaFxPlugin"/>
     12    <property name="plugin.class.windows" value="org.openstreetmap.josm.plugins.javafx.JavaFxPluginWindows"/>
     13    <property name="plugin.class.unixoid" value="org.openstreetmap.josm.plugins.javafx.JavaFxPluginUnixoid"/>
     14    <property name="plugin.class.osx" value="org.openstreetmap.josm.plugins.javafx.JavaFxPluginOsx"/>
    1315    <property name="plugin.description" value="Provides the OpenJFX (JavaFX) library for JOSM core and other JOSM plugins. Provides additional features such as MP3 audio playback."/>
    1416    <property name="plugin.minimum.java.version" value="11"/>
     
    2325    <import file="../build-common.xml"/>
    2426
    25         <target name="pre-compile" depends="fetch_dependencies">
    26                 <!-- include fetch_dependencies task -->
    27         </target>
     27    <target name="pre-compile" depends="fetch_dependencies">
     28        <!-- include fetch_dependencies task -->
     29    </target>
    2830
    29     <!-- Override build-jar target to speed up merging from 16 minutes to 7 minutes -->
     31    <macrodef name="build-native-manifest">
     32        <attribute name="class"/>
     33        <attribute name="manifest"/>
     34        <attribute name="platform"/>
     35        <sequential>
     36            <copy file="MANIFEST" tofile="@{manifest}" />
     37            <manifest file="@{manifest}" mode="update">
     38                <attribute name="Plugin-Class" value="${property.value}" />
     39                <attribute name="Plugin-Platform" value="@{platform}" />
     40            </manifest>
     41        </sequential>
     42    </macrodef>
     43
     44    <target name="additional-manifest">
     45        <build-native-manifest platform="Windows" class="${plugin.class.windows}" manifest="${manifest.windows}"/>
     46        <build-native-manifest platform="Unixoid" class="${plugin.class.unixoid}" manifest="${manifest.unixoid}" />
     47        <build-native-manifest platform="Osx" class="${plugin.class.osx}" manifest="${manifest.osx}" />
     48    </target>
     49
     50    <macrodef name="build-native-jar">
     51        <attribute name="jar"/>
     52        <attribute name="manifest"/>
     53        <attribute name="qualifier"/>
     54        <attribute name="copy"/>
     55        <sequential>
     56            <echo>Building @{qualifier} jar...</echo>
     57            <!-- Building the JAR file directly from javafx jar files is awfully slow,
     58                 see https://bz.apache.org/bugzilla/show_bug.cgi?id=43144 -->
     59            <mkdir dir="${plugin.lib.dir}/@{qualifier}"/>
     60            <unzip dest="${plugin.lib.dir}/@{qualifier}">
     61                <patternset>
     62                    <exclude name="META-INF/maven/*"/>
     63                    <exclude name="META-INF/DEPENDENCIES"/>
     64                    <exclude name="META-INF/LICENSE"/>
     65                    <exclude name="META-INF/NOTICE"/>
     66                    <exclude name="META-INF/*.RSA"/>
     67                    <exclude name="META-INF/*.SF"/>
     68                    <exclude name="module-info.class"/>
     69                </patternset>
     70                <fileset dir="${plugin.lib.dir}">
     71                    <include name="*-@{qualifier}.jar"/>
     72                    <include name="*-monocle*.jar"/>
     73                </fileset>
     74            </unzip>
     75            <jar destfile="@{jar}" manifest="@{manifest}" manifestencoding="UTF-8" level="9">
     76                <fileset dir="${plugin.build.dir}"/>
     77                <fileset dir="${plugin.lib.dir}/@{qualifier}"/>
     78            </jar>
     79            <delete dir="${plugin.lib.dir}/@{qualifier}" failonerror="false" />
     80            <copy file="@{jar}" tofile="${plugin.jar}" if:set="@{copy}" />
     81        </sequential>
     82    </macrodef>
     83
    3084    <target name="build-jar">
    31         <echo>Building commong jar...</echo>
    32         <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST" manifestencoding="UTF-8" duplicate="preserve" level="9">
    33             <restrict>
    34                 <not><or>
    35                     <name name="META-INF/maven/*"/>
    36                     <name name="META-INF/DEPENDENCIES"/>
    37                     <name name="META-INF/LICENSE"/>
    38                     <name name="META-INF/NOTICE"/>
    39                     <name name="META-INF/*.RSA"/>
    40                     <name name="META-INF/*.SF"/>
    41                     <name name="module-info.class"/>
    42                 </or></not>
    43                 <archives>
    44                     <zips>
    45                         <fileset dir="${plugin.lib.dir}" includes="*-linux.jar"/>
    46                     </zips>
    47                 </archives>
    48             </restrict>
    49         </jar>
    50         <echo>Adding macOS artifacts...</echo>
    51         <jar destfile="${plugin.jar}" update="true" duplicate="preserve" level="9">
    52             <restrict>
    53                 <or>
    54                     <name name="*.dylib"/>
    55                     <name name="com/sun/glass/events/mac/**"/>
    56                     <name name="com/sun/glass/ui/mac/**"/>
    57                     <name name="com/sun/media/jfxmediaimpl/platform/osx/**"/>
    58                     <name name="com/sun/prism/es2/**"/>
    59                 </or>
    60                 <archives>
    61                     <zips>
    62                         <fileset dir="${plugin.lib.dir}" includes="*-mac.jar"/>
    63                     </zips>
    64                 </archives>
    65             </restrict>
    66         </jar>
    67         <echo>Adding Windows artifacts...</echo>
    68         <jar destfile="${plugin.jar}" update="true" duplicate="preserve" level="9">
    69             <restrict>
    70                 <or>
    71                     <name name="*.dll"/>
    72                     <name name="com/sun/glass/ui/win/**"/>
    73                     <name name="com/sun/prism/d3d/**"/>
    74                     <name name="com/sun/scenario/effect/impl/hw/d3d/**"/>
    75                 </or>
    76                 <archives>
    77                     <zips>
    78                         <fileset dir="${plugin.lib.dir}" includes="*-win.jar"/>
    79                     </zips>
    80                 </archives>
    81             </restrict>
    82         </jar>
    83         <echo>Adding Monocle artifacts...</echo>
    84         <jar destfile="${plugin.jar}" update="true" duplicate="preserve" level="9">
    85             <restrict>
    86                 <archives>
    87                     <zips>
    88                         <fileset dir="${plugin.lib.dir}" includes="*-monocle*.jar"/>
    89                     </zips>
    90                 </archives>
    91             </restrict>
    92         </jar>
     85        <build-native-jar jar="${plugin.unixoid.jar}" manifest="${manifest.unixoid}" qualifier="linux" copy="isUnix" />
     86        <build-native-jar jar="${plugin.windows.jar}" manifest="${manifest.windows}" qualifier="win" copy="isWindows" />
     87        <build-native-jar jar="${plugin.osx.jar}" manifest="${manifest.osx}" qualifier="mac" copy="isMac" />
    9388    </target>
    9489</project>
  • applications/editors/josm/plugins/javafx/src/org/openstreetmap/josm/plugins/javafx/JavaFxPlugin.java

    r34701 r34703  
    2727import org.openstreetmap.josm.plugins.javafx.io.audio.JavaFxMediaPlayer;
    2828import org.openstreetmap.josm.tools.Logging;
    29 import org.openstreetmap.josm.tools.PlatformManager;
    3029
    3130/**
    3231 * OpenJFX plugin brings OpenJFX (JavaFX) to other plugins.
    3332 */
    34 public class JavaFxPlugin extends Plugin {
     33abstract class JavaFxPlugin extends Plugin {
    3534
    3635    /**
    3736     * Constructs a new {@code OpenJfxPlugin}.
    3837     * @param info plugin info
     38     * @param ext native libraries extension
    3939     */
    40     public JavaFxPlugin(PluginInformation info) {
     40    protected JavaFxPlugin(PluginInformation info, String ext) {
    4141        super(info);
    4242        AudioPlayer.setSoundPlayerClass(JavaFxMediaPlayer.class);
    43         String ext = null;
    44         if (PlatformManager.isPlatformWindows()) {
    45             ext = ".dll";
    46         } else if (PlatformManager.isPlatformUnixoid()) {
    47             ext = ".so";
    48         } else if (PlatformManager.isPlatformOsx()) {
    49             ext = ".dylib";
    50         }
    5143        extractNativeLibs(ext);
    5244        loadNativeLibs(ext);
Note: See TracChangeset for help on using the changeset viewer.