JAVAFx构建失败,无法创建任务或键入javafx:com.sun.javafx.tools.ant:resources

时间:2019-03-29 19:58:32

标签: javafx build ant

我正在为我的一个项目尝试在antbuild文件下运行,但我的build.xmlfile代码没有成功

<?xml version="1.0" encoding="UTF-8"?>
<project name="PlayerApplication" 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"/>
            <file name="${basedir}"/>
        </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:\PlayerTestCode\lib">
            <filename name="gson-2.1.jar"/>
        </fileset>
    </copy>
    <copy todir="externalLibs">
        <fileset dir="D:\PlayerTestCode\lib">
            <filename name="sqlite-jdbc-3.5.9-universal.jar"/>
        </fileset>
    </copy>

    <mkdir dir="project" />
    <copy todir="project">
        <fileset dir="D:\PlayerTestCode">
            <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="gson-2.1.jar"/>
            <include name="sqlite-jdbc-3.5.9-universal.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.8" target="1.8" srcdir="build/src" destdir="build/classes" encoding="Cp1252">
        <classpath>
            <fileset dir="build/libs">
                <include name="*"/>
            </fileset>
        </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="PlayerApplication.jar"/>
        <fx:fileset dir="dist" includes="libs/*"/>
        <fx:fileset dir="dist" includes="resources/**"/>
    </fx:resources>

    <fx:application id="fxApplication"
        name="MovementLibraryPlayer"
        mainClass="Demo1"
        toolkit="fx"
        version="1.0" 

    />

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



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

        <manifest>
            <attribute name="Implementation-Vendor" value="MovementDynemics"/>
            <attribute name="Implementation-Title" value="MovementLibraryPlayer"/>
            <attribute name="Implementation-Version" value="1.0"/>
            <attribute name="JavaFX-Feature-Proxy" value="None"/>
        </manifest>
    </fx:jar>


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

        <fx:platform basedir="${java.home}"/>
        <fx:info title="PlayerApplication" vendor="MovementDynemics"/>

        <fx:application refId="fxApplication"/>
        <fx:resources refid="appRes"/>
    </fx:deploy>


</target>

当我在eclipse中运行以上文件作为蚂蚁构建时,我遇到了以下错误 有人对此错误有任何想法吗? 以下几行是什么意思?

 Buildfile: D:\PlayerTestCode\build\otherbuild\buildWin.xml
setup-staging-area:
   [delete] Deleting directory D:\PlayerTestCode\build\otherbuild\externalLibs
   [delete] Deleting directory D:\PlayerTestCode\build\otherbuild\project
   [delete] Deleting directory D:\PlayerTestCode\build\otherbuild\projectRefs
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\externalLibs
     [copy] Copying 1 file to D:\PlayerTestCode\build\otherbuild\externalLibs
     [copy] Copying 1 file to D:\PlayerTestCode\build\otherbuild\externalLibs
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\project
     [copy] Copying 63 files to D:\PlayerTestCode\build\otherbuild\project
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\projectRefs
do-compile:
   [delete] Deleting directory D:\PlayerTestCode\build\otherbuild\build
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\build\src
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\build\libs
    [mkdir] Created dir: D:\PlayerTestCode\build\otherbuild\build\classes
     [copy] Copying 2 files to D:\PlayerTestCode\build\otherbuild\build\libs
     [copy] Copying 63 files to D:\PlayerTestCode\build\otherbuild\build\src
    [javac] Compiling 26 source files to D:\PlayerTestCode\build\otherbuild\build\classes
    [javac] Note: D:\PlayerTestCode\build\otherbuild\build\src\FXMLDocumentController.java uses or overrides a deprecated API.
    [javac] Note: Recompile with -Xlint:deprecation for details.
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
     [copy] Copying 37 files to D:\PlayerTestCode\build\otherbuild\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 2 files to D:\PlayerTestCode\build\otherbuild\dist\libs

BUILD FAILED
D:\PlayerTestCode\build\otherbuild\buildWin.xml:97: Problem: failed to create task or type javafx:com.sun.javafx.tools.ant:resources

我不知道我在哪里错了,我必须去哪里找。 如果有人可以帮助我进行梳理,那将是很棒的事情。

谢谢

0 个答案:

没有答案