0

我为 javafx 开发安装了 eclipse-SDK-4.2.1-win32-efx-0.8.0。我进行了 soe 测试,我想部署我的应用程序。我首先将它导出到 ant 并在我的项目中获取了这个 ant 文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply create one in the same
              directory with the processing instruction <?eclipse.ant.import?>
              as the first entry and export the buildfile again. --><project basedir="." default="build" name="Newtest">
    <property environment="env"/>
    <property name="ECLIPSE_HOME" value="../../"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.7"/>
    <property name="source" value="1.7"/>
    <path id="JavaFX SDK.libraryclasspath">
        <pathelement location="C:/Program Files/Java/jre7/lib/jfxrt.jar"/>
    </path>
    <path id="Newtest.classpath">
        <pathelement location="bin"/>
        <path refid="JavaFX SDK.libraryclasspath"/>
        <pathelement location="lib/jfxtras-labs-2.2-r4.jar"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="Newtest.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="Test">
        <java classname="app.TEst" failonerror="true" fork="yes">
            <classpath refid="Newtest.classpath"/>
        </java>
    </target>
</project>

并单击“生成 ant build.xml 并运行”我在控制台上出现此错误:

Buildfile: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build.xml
setup-staging-area:
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\projectRefs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\externalLibs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
     [copy] Copying 2 files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\project
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\projectRefs
do-compile:
   [delete] Deleting directory D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\src
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\libs
    [mkdir] Created dir: D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\classes
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\libs
     [copy] Copying 2 files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\src
    [javac] Compiling 2 source files to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build\classes
init-fx-tasks:
  [taskdef] Could not load definitions from resource com/sun/javafx/tools/ant/antlib.xml. It could not be found.
do-deploy:
     [copy] Copying 1 file to D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\dist\libs

BUILD FAILED
D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\build\build.xml:93: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.
No types or tasks have been defined in this namespace yet


Total time: 14 seconds

我对蚂蚁一无所知,请问我的问题是什么?谢谢

4

2 回答 2

0

所以它告诉你它不能加载 JavaFX ant 扩展

无法从资源 com/sun/javafx/tools/ant/antlib.xml 加载定义。找不到。部署:

为什么不使用 build.fxbuild 文件来生成 ANT 文件?

于 2013-05-14T18:45:36.183 回答
0

这是我项目中的另一个 ant 文件:

<?xml version="1.0" encoding="UTF-8"?>
    <project name="Newtest" default="do-deploy" basedir="."  xmlns:fx="javafx:com.sun.javafx.tools.ant">
    <target name="init-fx-tasks">
        <path id="fxant">
            <filelist>
                <file name="${java.home}\..\lib\ant-javafx.jar"/>
                <file name="${java.home}\lib\jfxrt.jar"/>
            </filelist>
        </path>

        <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
            uri="javafx:com.sun.javafx.tools.ant"
            classpathref="fxant"/>
    </target>
    <target name="setup-staging-area">
        <delete dir="externalLibs" />
        <delete dir="project" />
        <delete dir="projectRefs" />

        <mkdir dir="externalLibs" />

        <copy todir="externalLibs">
            <fileset dir="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\lib">
                <filename name="jfxtras-labs-2.2-r4.jar"/>  
            </fileset>
        </copy>
        <copy todir="externalLibs">
            <fileset dir="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest\lib">
                <filename name="ant-javafx.jar"/>   
            </fileset>
        </copy>

        <mkdir dir="project" />
        <copy todir="project">
            <fileset dir="D:\eclipse-SDK-4.2.1-win32-efx-0.8.0\eclipse\MyWorkPlace\Newtest">
                <include name="src/**" />
            </fileset>
        </copy>

        <mkdir dir="projectRefs" />
    </target>
    <target name='do-compile'>
        <delete dir="build" />
        <mkdir dir="build/src" />
        <mkdir dir="build/libs" />
        <mkdir dir="build/classes" />

        <!-- Copy project-libs references -->
        <copy todir="build/libs">
            <fileset dir="externalLibs">
                <include name="ant-javafx.jar"/>
                <include name="jfxtras-labs-2.2-r4.jar"/>
            </fileset>
        </copy>

        <!-- Copy project references -->

        <!-- Copy project sources itself -->
        <copy todir="build/src">
            <fileset dir="project/src">
                <include name="**/*"/>
            </fileset>
        </copy>

        <javac includeantruntime="false" source="1.7" target="1.7" srcdir="build/src" destdir="build/classes" encoding="Cp1252">
            <classpath>
                <fileset dir="build/libs">
                    <include name="*"/>
                </fileset>
                <filelist>
                    <file name="C:\Program Files\Java\jre7\lib\jfxrt.jar"/>
                </filelist>
            </classpath>
        </javac>

        <!-- Copy over none Java-Files -->
        <copy todir="build/classes">
        <fileset dir="project/src">
            <exclude name="**/*.java"/>
        </fileset>
        </copy>


    </target>
    <target name="do-deploy" depends="setup-staging-area, do-compile, init-fx-tasks">
        <delete file="dist"/>
        <delete file="deploy" />

        <mkdir dir="dist" />
        <mkdir dir="dist/libs" />

        <copy todir="dist/libs">
            <fileset dir="externalLibs">
                <include name="*" />
            </fileset>
        </copy>


        <fx:resources id="appRes">
            <fx:fileset dir="dist" includes="Newtest.jar"/>
            <fx:fileset dir="dist" includes="libs/*"/>
        </fx:resources> 

        <fx:application id="fxApplication"
            name="Newtest"
            mainClass="app.TEst"
        />

        <mkdir dir="build/classes/META-INF" />



        <fx:jar destfile="dist/Newtest.jar">
            <fx:application refid="fxApplication"/>
            <fileset dir="build/classes">
            </fileset>
            <fx:resources refid="appRes"/>

            <manifest>
                <attribute name="Implementation-Vendor" value="Menguelenium"/>
                <attribute name="Implementation-Title" value=""/>
                <attribute name="Implementation-Version" value="0.0"/>
            </manifest>
        </fx:jar>


        <mkdir dir="deploy" />
        <!-- Need to use ${basedir} because somehow the ant task is calculating the directory differently -->
        <fx:deploy
            embedJNLP="false"
            extension="false"
            width="400" height="350" 
            includeDT="false"
            offlineAllowed="true"
            outdir="${basedir}/deploy"
            outfile="Newtest" 
            updatemode="background" >

            <fx:info title="Newtest" vendor="Menguelenium"/>
            <fx:application refId="fxApplication"/>
            <fx:resources refid="appRes"/>
        </fx:deploy>


    </target>
</project>

请我真的很熟悉蚂蚁。这是我第一次使用它。

于 2013-05-16T13:02:40.270 回答