0

我是 Ant 的新手(我来自 Maven),我有以下问题

我有一个名为GUI.jar的项目和一个将项目构建到 jar 文件中的 Ant 脚本

在我的项目中,我有以下包:com.myCompany.mySoftware.resources,这个包不包含 Java 类,但包含一些资源文件,例如.properties.png文件。(Eclipse 向我显示与此包相关的白色图标)

问题是当 Ant 脚本构建我的最终GUI.jar文件时,该文件中不包含文件夹/com/MyCompany/MySoftware/resources/,当我从命令行执行我的GUI.jar文件时我收到以下错误消息:

java.io.IOException: No localization could be found in '/com/MyCompany/MySoftware/resources/Strings_it_IT.properties'

这是我的build.xml Ant 脚本的代码:

<?xml version="1.0"?>
<project name="Peacock Engine" default="default">

    <tstamp />

    <condition property="unix">
        <os family="unix" />
    </condition>

    <condition property="mac">
        <os family="mac" />
    </condition>

    <!-- ============================================ -->
    <!-- Load build properties                        -->
    <!-- ============================================ -->

    <property name="project.buildfile" value="build.num" />

    <property file="${project.buildfile}" />

    <property file="info.properties" />

    <!-- ============================================ -->
    <!-- Specify the classpath                        -->
    <!-- ============================================ -->

    <path id="project.classpath">
        <fileset dir="../../SharedLib/">
            <include name="**/*.jar" />
        </fileset>

        <fileset dir="../../CrystalIceAdapter/Atmos/AtmosAdapter/Release/">
            <include name="atmosadapter.jar" />
        </fileset>

        <fileset dir="../../CrystalIceTasks/Release/">
            <include name="dataspace.jar" />
        </fileset>

        <fileset dir="../../CrystalIceTasksLib/Release/">
            <include name="taskslib.jar" />
        </fileset>

        <fileset dir="../../CrystalIceXMLHandler/Release/">
            <include name="XMLHandler.jar" />
        </fileset>

        <fileset dir="../../ShellExtBridge/Release/">
            <include name="shellExtBridge.jar" />
        </fileset>
    </path>

    <!-- ============================================ -->
    <!-- The default target                           -->
    <!-- ============================================ -->

    <target name="default" depends="jar" />

    <!-- Elimina le cartelle contenenti le classi compilate ed i jar -->
    <target name="clean">
        <echo message="Into CrystalGUI build.xml clean target" />
        <!-- <delete dir="../Release" /> -->
        <delete file="../Release/*.jar"/>
        <!-- Elimina directory del jar finale -->
        <delete dir="bin" />
        <!-- Elimina directory delle classi compilate -->
    </target>


    <!-- ============================================ -->
    <!-- Set the path if the operating system is      -->
    <!-- U                                            -->
    <!-- ============================================ -->
    <target name="initMacPath" if="mac" depends="clean">
            <echo message="initMacPath: SETTING MAC PATH" />
            <!--<property name="path">${basedir}/../../../Mac/CrystalIce/CrystalIce/CrystalIce/Build/Products/Debug/CrystalIce.app/Contents/Resources/java/</property>-->
            <property name="path">${basedir}/../../../CrossPlatform/CrystalIceGUI/Project/data/CrystalIce.app/Contents/Resources/java/</property>
        </target>

    <target name="initUnixPath" if="unix" depends="clean">
        <echo message="initUnixPath: SETTING UNIX PATH" />
        <property name="path">/usr/share/XCloud/appl/lib/</property>
    </target>


    <!-- ============================================ -->
    <!-- Compile the java sources to classes          -->
    <!-- ============================================ -->

    <target name="compile" description="Compile the Java sources to class files" depends="init">
        <echo message="Into CrystalGUI compile.xml jar target" />
        <mkdir dir="bin" />
        <javac srcdir="${basedir}/src" destdir="bin" classpathref="project.classpath" />
    </target>

    <!-- ============================================ -->
    <!-- Copy the JAR dependency and the driver in    -->
    <!-- the right location                           -->
    <!--                                              -->
    <!-- UNIX and MAC version                         -->
    <!-- ============================================ -->

    <target name="init" depends="initMacPath , initUnixPath">
        <echo message="Into CrystalGUI build.xml init target" />

        <ant antfile="build.xml" dir="${basedir}/../../CrystalIceXMLHandler/Project/" />
        <ant antfile="build.xml" dir="${basedir}/../../ShellExtBridge/Project/" />
        <ant antfile="build.xml" dir="${basedir}/../../CrystalIceAdapter/Atmos/AtmosAdapter/Project/AtmosAdapter/" />
        <ant antfile="build.xml" dir="${basedir}/../../CrystalIceTasksLib/Project/" />
        <ant antfile="build.xml" dir="${basedir}/../../CrystalIceTasks/Project/" />

        <!-- Copy SharedLib jar files: -->
        <!--<copy todir="${basedir}/../../../../../../../../usr/share/XCloud/appl/lib">-->
        <!--<copy todir="/usr/share/XCloud/appl/lib">-->
        <echo message="Copy to: ${path}" />

        <copy todir="${path}">
            <fileset dir="${basedir}/../../SharedLib" />
        </copy>

        <!-- Copy EMC Esu Rest API: -->
        <copy file="${basedir}/../../EsuAtmos/EsuApi 2.0.3.1/build/emcesu.jar" tofile="${path}emcesu.jar" />

        <echo message="emcesu.jar copyed" />
        <!--
        <copy file="${basedir}/../../EsuAtmos/EsuApi 2.0.3.1/build/emcesu.jar" tofile="/usr/share/XCloud/appl/lib/emcesu.jar" />
        -->


        <!-- Copy atmosadapter files: -->
        <copy file="${basedir}/../../CrystalIceAdapter/Atmos/AtmosAdapter/Release/atmosadapter.jar" tofile="${path}atmosadapter.jar" />
        <!--
        <copy file="${basedir}/../../CrystalIceAdapter/Atmos/AtmosAdapter/Release/atmosadapter.jar" tofile="/usr/share/XCloud/appl/lib/atmosadapter.jar" />
        -->

        <!-- Copy xmlhanlder files: -->
        <copy file="${basedir}/../../CrystalIceXMLHandler/Release/XMLHandler.jar" tofile="${path}XMLHandler.jar" />
        <!--
        <copy file="${basedir}/../../CrystalIceXMLHandler/Release/XMLHandler.jar" tofile="/usr/share/XCloud/appl/lib/XMLHandler.jar" />
        -->

        <!-- Copy taskslib files: -->
        <copy file="${basedir}/../../CrystalIceTasksLib/Release/taskslib.jar" tofile="${path}taskslib.jar" />
        <!--
        <copy file="${basedir}/../../CrystalIceTasksLib/Release/taskslib.jar" tofile="/usr/share/XCloud/appl/lib/taskslib.jar" />
        -->

        <!-- Copy dataspace files: -->
        <copy file="${basedir}/../../CrystalIceTasks/Release/dataspace.jar" tofile="${path}dataspace.jar" />
        <!--
        <copy file="${basedir}/../../CrystalIceTasks/Release/dataspace.jar" tofile="/usr/share/XCloud/appl/lib/dataspace.jar" />
        -->

        <!-- Copy shellextbridge files: -->
        <copy file="${basedir}/../../ShellExtBridge/Release/shellExtBridge.jar" tofile="${path}shellExtBridge.jar" />
        <!--
        <copy file="${basedir}/../../ShellExtBridge/Release/shellExtBridge.jar" tofile="/usr/share/XCloud/appl/lib/shellExtBridge.jar" />
        -->
    </target>




    <!-- Rutigliano path MAC
    /Users/xdrive/Documents/XDrive SVN/Implementazione/Mac/CrystalIce/CrystalIce/CrystalIce/Build/Products/Debug/CrystalIce.app/Contents/Resources/java/httpclient-cache-4.3.jar
    -->

    <!-- ============================================ -->
    <!-- Pack the java classes in a jar file          -->
    <!-- ============================================ -->
    <target name="jar" depends="compile">
        <echo message="Into CrystalGUI build.xml jar target" />

        <!-- Define the property jar.classpath 
             You may need to reference classes in other JAR files from within a JAR file.

             For example, in a typical situation an application is bundled in a JAR file whose manifest 
             references a different JAR file (or several different JAR files) that serves as utilities 
             for the purposes of that application.
        -->
        <pathconvert property="jar.classpath" pathsep=" ">
            <!-- classpath container: it contains a set of path element pointing to some jars or directories -->
            <path refid="project.classpath" />

            <chainedmapper>
                <!-- A chainedmapper is applied to the project.classpath -->
                <!-- STEP 1: Remove all directory information from the path element. Ex: dir1/dir2/lib1.jar is trasformed in lib1.jar -->
                <flattenmapper />
                <!-- STEP 2: Will prefix every path element resulting from step1 with lib/. EX: lib1.jar will became lib/lib1.jar -->
                <globmapper from="*" to="lib/*" />
            </chainedmapper>
        </pathconvert>

        <jar destfile="${basedir}/../Release/GUI.jar" index="false">
            <fileset dir="${basedir}/bin" excludes="${project.pluginptrn}/** **/tests/**" />
            <manifest>
                <attribute name="Specification-Title" value="Java Utility Classes" />
                <attribute name="Specification-Version" value="1.0.1-15" />
                <attribute name="Specification-Vendor" value="TechUb" />
                <attribute name="Created-By" value="${info.software.author}" />
                <attribute name="Class-Path" value="${jar.classpath}" />
                <attribute name="Main-Class" value="ConnectDataSpace" />
            </manifest>
        </jar>
        <!--
        <copy todir="${basedir}/../Release/lib">
            <fileset dir="${basedir}/lib">
                <include name="*" />
            </fileset>
        </copy>

        <copy todir="${basedir}/../Release">
            <fileset dir="${basedir}" includes="data/*/**" />
        </copy>

        <copy file="${basedir}/../Release/GUI.jar" tofile="/usr/share/XCloud/appl/GUI.jar" />
-->

        <copy file="${basedir}/../Release/GUI.jar" tofile="${path}GUI.jar" />
    </target>


</project>

我可以做些什么来解决这个问题并将我的包com.myCompany.mySoftware.resources的内容放在我最终 GUI.jar 文件的文件夹/com/MyCompany/MySoftware/resources/中?

肿瘤坏死因子

安德烈亚

4

0 回答 0