Changeset 34703 in osm


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
Files:
3 added
3 edited

Legend:

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

    r34682 r34703  
    3333    <property name="plugin.dist.dir"        location="../../dist"/>
    3434    <property name="java.lang.version"      value="1.8" />
     35    <property name="manifest"               value="MANIFEST"/>
     36    <property name="manifest.unixoid"       value="MANIFEST-unixoid"/>
     37    <property name="manifest.windows"       value="MANIFEST-windows"/>
     38    <property name="manifest.osx"           value="MANIFEST-osx"/>
    3539    <property name="plugin.jar"             location="${plugin.dist.dir}/${ant.project.name}.jar"/>
     40    <property name="plugin.unixoid.jar"     location="${plugin.dist.dir}/${ant.project.name}-unixoid.jar"/>
     41    <property name="plugin.windows.jar"     location="${plugin.dist.dir}/${ant.project.name}-windows.jar"/>
     42    <property name="plugin.osx.jar"         location="${plugin.dist.dir}/${ant.project.name}-osx.jar"/>
    3643    <property name="plugin.sources.jar"     location="${plugin.dist.dir}/${ant.project.name}-sources.jar"/>
    3744    <property name="plugin.javadoc.jar"     location="${plugin.dist.dir}/${ant.project.name}-javadoc.jar"/>
     
    4148    <property name="ivy.version"            value="2.5.0-rc1"/>
    4249
    43     <!-- For Windows-specific stuff -->
    44     <condition property="isWindows">
    45         <os family="Windows"/>
    46     </condition>
     50    <!-- For platform-specific stuff -->
     51    <condition property="isWindows"><os family="Windows"/></condition>
     52    <condition property="isUnix"><os family="Unix"/></condition>
     53    <condition property="isMac"><os family="Mac"/></condition>
    4754    <!-- For Java specific stuff by version -->
    4855    <condition property="isJava9"><matches string="${ant.java.version}" pattern="(1.)?(9|1[0-9])" /></condition>
     
    7582            <exclude name="**/*-sources.jar"/>
    7683            <exclude name="**/*-javadoc.jar"/>
     84            <exclude name="**/*-unixoid.jar" unless="isUnix"/>
     85            <exclude name="**/*-windows.jar" unless="isWindows"/>
     86            <exclude name="**/*-osx.jar" unless="isMac"/>
    7787        </fileset>
    7888        <fileset refid="plugin.requires.jars"/>
     
    150160        <echo message="creating ${ant.project.name}.jar ... "/>
    151161        <antcall target="setup-dist" />
    152         <delete file="MANIFEST" failonerror="no"/>
    153         <manifest file="MANIFEST" mode="update">
     162        <delete failonerror="no">
     163            <fileset dir="." includes="${manifest}*" />
     164        </delete>
     165        <manifest file="${manifest}" mode="update">
    154166            <attribute name="Plugin-Mainversion" value="${plugin.main.version}"/>
    155167            <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
     
    198210        <jar destfile="${plugin.sources.jar}" basedir="${plugin.src.dir}" level="9"/>
    199211        <jar destfile="${plugin.javadoc.jar}" basedir="${plugin.doc.dir}" level="9"/>
    200         <delete file="MANIFEST" failonerror="no"/>
     212        <delete failonerror="no">
     213            <fileset dir="." includes="${manifest}*" />
     214        </delete>
    201215        <antcall target="post-dist" />
    202216    </target>
    203217    <target name="build-jar">
    204         <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="MANIFEST" manifestencoding="UTF-8" duplicate="preserve" level="9">
     218        <jar destfile="${plugin.jar}" basedir="${plugin.build.dir}" manifest="${manifest}" manifestencoding="UTF-8" duplicate="preserve" level="9">
    205219            <restrict>
    206220                <not><or>
     
    225239    </target>
    226240    <target name="add-manifest-attribute" depends="check-manifest-attribute" if="have-${property.name}">
    227         <manifest file="MANIFEST" mode="update">
     241        <manifest file="${manifest}" mode="update">
    228242            <attribute name="${manifest.attribute}" value="${property.value}" />
    229243        </manifest>
     
    549563                    <path refid="test.classpath"/>
    550564                </classpath>
    551                                 <compilerarg value="-Xlint:all"/>
    552                                 <compilerarg value="-Xlint:-serial"/>
     565                <compilerarg value="-Xlint:all"/>
     566                <compilerarg value="-Xlint:-serial"/>
    553567            </javac>
    554568        </sequential>
     
    611625                                                                         org/marvinproject/**/*.java,
    612626                                                                         org/netbeans/**/*.java,
    613                                                                                                                                                 org/openstreetmap/josm/plugins/dataimport/io/tcx/**/*.java,
    614                                                                                                                                                 org/openstreetmap/josm/plugins/ohe/parser/**/*.java,
    615                                                                                                                                                 org/openstreetmap/josm/plugins/pdfimport/pdfbox/operators/**/*.java
    616                                                                                                                                                 org/openstreetmap/josm/plugins/roadsigns/javacc/**/*.java,
     627                                                                        org/openstreetmap/josm/plugins/dataimport/io/tcx/**/*.java,
     628                                                                        org/openstreetmap/josm/plugins/ohe/parser/**/*.java,
     629                                                                        org/openstreetmap/josm/plugins/pdfimport/pdfbox/operators/**/*.java
     630                                                                        org/openstreetmap/josm/plugins/roadsigns/javacc/**/*.java,
    617631                                                                         org/osgeo/**/*.java,
    618                                                                                                                                                 "/>
     632                                                                        "/>
    619633            <fileset dir="${basedir}/test" includes="**/*.java" erroronmissingdir="false"/>
    620634            <formatter type="xml" toFile="checkstyle-josm-${ant.project.name}.xml"/>
     
    688702        <taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
    689703    </target>
    690         <target name="clean_ivy">
    691                 <delete failonerror="false">
    692                         <fileset dir="${plugin.lib.dir}">
    693                                 <include name="**/*.jar"/>
    694                                 <exclude name="**/*-custom.jar" />
    695                         </fileset>
    696                 </delete>
    697         </target>
    698         <target name="fetch_dependencies" depends="clean_ivy, init-ivy">
    699                 <echo>fetching dependencies with ivy</echo>
    700                 <ivy:settings file="ivy_settings.xml" />
    701                 <ivy:retrieve pattern="${plugin.lib.dir}/[artifact]-[revision](-[classifier]).[ext]" conf="default" />
    702         </target>
     704    <target name="clean_ivy">
     705        <delete failonerror="false">
     706            <fileset dir="${plugin.lib.dir}">
     707                <include name="**/*.jar"/>
     708                <exclude name="**/*-custom.jar" />
     709            </fileset>
     710        </delete>
     711    </target>
     712    <target name="fetch_dependencies" depends="clean_ivy, init-ivy">
     713        <echo>fetching dependencies with ivy</echo>
     714        <ivy:settings file="ivy_settings.xml" />
     715        <ivy:retrieve pattern="${plugin.lib.dir}/[artifact]-[revision](-[classifier]).[ext]" conf="default" />
     716    </target>
    703717</project>
  • 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.