簡體   English   中英

JavaFX 11 部署失敗:無法創建任務或鍵入 javafx:com.sun.javafx.tools.ant:fileset

[英]JavaFX 11 Deployment Failure: failed to create task or type javafx:com.sun.javafx.tools.ant:fileset

我正在嘗試部署我的項目,但我不斷收到以下錯誤,我該怎么辦? 另外,我有 java 11,但我只能在 IntelliJ 中選擇最多 10 級的項目語言級別,但我可以使用“var”語法並運行它。 智能信息:

編輯:顯然 intellij IDEA 1.x 不支持 java 11 我已經下載了最新版本,目前正在嘗試重做整個過程

最終編輯:我通過在 intelliJ IDEA 3.x 上使用 java 8 解決了這個問題,並遵循了本指南 謝謝HCE

主意

信息:Java FX Packager: [C:/Program Files/Java/jdk-11.0.2\\bin\\java, -Dant.home=D:\\Programs\\IntelliJ IDEA 2018.1.5\\lib\\ant, -classpath, D: \\Programs\\IntelliJ IDEA 2018.1.5\\lib\\ant/lib/ant.jar;D:\\Programs\\IntelliJ IDEA 2018.1.5\\lib\\ant/lib/ant-launcher.jar;C:/Program Files/Java/ jdk-11.0.2/lib/ant-javafx.jar;C:/Program Files/Java/jdk-11.0.2/jre/lib/jfxrt.jar, org.apache.tools.ant.launch.Launcher, -f , C:\\Users\\HP.IntelliJIdea2018.1\\system\\compile-server\\luckypick-m_8a6db982_temp_\\build.xml] 信息:Java FX Packager: Buildfile: C:\\Users\\HP.IntelliJIdea2018.1\\system\\compile-server \\luckypick-m_8a6db982_temp_\\build.xml 信息:Java FX 打包程序:[taskdef] 無法從資源 com/sun/javafx/tools/ant/antlib.xml 加載定義。 無法找到。 信息:Java FX Packager:信息:Java FX Packager:構建工件:信息:27.01.2019 15:09 - 編譯完成,在 8 秒 226 毫秒內出現 2 個錯誤和 0 個警告錯誤:Java FX Packager:構建失敗 C:\\Users\\ HP.IntelliJIdea2018.1\\system\\compile-server\\luckypick-m_8a6db982_temp_\\build.xml:3:問題:無法創建任務或鍵入 javafx:com.sun.javafx.tools.ant:fileset 原因:名稱未定義。 行動:檢查拼寫。 行動:檢查是否已聲明任何自定義任務/類型。 行動:檢查任何/聲明已經發生。 尚未在此命名空間中定義任何類型或任務總時間:0 秒錯誤:Java FX Packager:fx:deploy 任務失敗。

這是我的項目目錄的外觀以及它包含哪些文件。

目錄

這是luckypick.properties

path.variable.kotl\u0131n_bundled=D\:\\Programs\\IntelliJ IDEA 2018.1.5\\plugins\\Kotlin\\kotlinc
path.variable.maven_repos\u0131tory=C\:\\Users\\HP\\.m2\\repository
jdk.home.11=C\:/Program Files/Java/jdk-11.0.2
idea.home=D\:/Programs/IntelliJ IDEA 2018.1.5
javafx.home=C\:/Users/HP/Documents/javafx-sdk-11.0.2
javac2.instrumentation.includeJavaRuntime=false

這是luckypick.xml

<?xml version="1.0" encoding="UTF-8"?>
<project name="luckypick" default="all">


    <property file="luckypick.properties"/>
    <!-- Uncomment the following property if no tests compilation is needed -->
    <!--
    <property name="skip.tests" value="true"/>
     -->

    <!-- Compiler options -->

    <property name="compiler.debug" value="on"/>
    <property name="compiler.generate.no.warnings" value="off"/>
    <property name="compiler.args" value=""/>
    <property name="compiler.max.memory" value="700m"/>
    <patternset id="ignored.files">
        <exclude name="**/*.hprof/**"/>
        <exclude name="**/*.pyc/**"/>
        <exclude name="**/*.pyo/**"/>
        <exclude name="**/*.rbc/**"/>
        <exclude name="**/*.yarb/**"/>
        <exclude name="**/*~/**"/>
        <exclude name="**/.DS_Store/**"/>
        <exclude name="**/.git/**"/>
        <exclude name="**/.hg/**"/>
        <exclude name="**/.svn/**"/>
        <exclude name="**/CVS/**"/>
        <exclude name="**/__pycache__/**"/>
        <exclude name="**/_svn/**"/>
        <exclude name="**/vssver.scc/**"/>
        <exclude name="**/vssver2.scc/**"/>
    </patternset>
    <patternset id="library.patterns">
        <include name="*.egg"/>
        <include name="*.jar"/>
        <include name="*.ear"/>
        <include name="*.swc"/>
        <include name="*.war"/>
        <include name="*.zip"/>
        <include name="*.ane"/>
    </patternset>
    <patternset id="compiler.resources">
        <exclude name="**/?*.java"/>
        <exclude name="**/?*.form"/>
        <exclude name="**/?*.class"/>
        <exclude name="**/?*.groovy"/>
        <exclude name="**/?*.scala"/>
        <exclude name="**/?*.flex"/>
        <exclude name="**/?*.kt"/>
        <exclude name="**/?*.clj"/>
    </patternset>

    <!-- JDK definitions -->

    <property name="jdk.bin.11" value="${jdk.home.11}/bin"/>
    <path id="jdk.classpath.11">
        <fileset dir="${jdk.home.11}">
            <include name="/legal/java.base"/>
            <include name="/legal/java.compiler"/>
            <include name="/legal/java.datatransfer"/>
            <include name="/legal/java.desktop"/>
            <include name="/legal/java.instrument"/>
            <include name="/legal/java.logging"/>
            <include name="/legal/java.management"/>
            <include name="/legal/java.management.rmi"/>
            <include name="/legal/java.naming"/>
            <include name="/legal/java.net.http"/>
            <include name="/legal/java.prefs"/>
            <include name="/legal/java.rmi"/>
            <include name="/legal/java.scripting"/>
            <include name="/legal/java.se"/>
            <include name="/legal/java.security.jgss"/>
            <include name="/legal/java.security.sasl"/>
            <include name="/legal/java.smartcardio"/>
            <include name="/legal/java.sql"/>
            <include name="/legal/java.sql.rowset"/>
            <include name="/legal/java.transaction.xa"/>
            <include name="/legal/java.xml"/>
            <include name="/legal/java.xml.crypto"/>
            <include name="/legal/jdk.accessibility"/>
            <include name="/legal/jdk.aot"/>
            <include name="/legal/jdk.attach"/>
            <include name="/legal/jdk.charsets"/>
            <include name="/legal/jdk.compiler"/>
            <include name="/legal/jdk.crypto.cryptoki"/>
            <include name="/legal/jdk.crypto.ec"/>
            <include name="/legal/jdk.crypto.mscapi"/>
            <include name="/legal/jdk.dynalink"/>
            <include name="/legal/jdk.editpad"/>
            <include name="/legal/jdk.hotspot.agent"/>
            <include name="/legal/jdk.httpserver"/>
            <include name="/legal/jdk.internal.ed"/>
            <include name="/legal/jdk.internal.jvmstat"/>
            <include name="/legal/jdk.internal.le"/>
            <include name="/legal/jdk.internal.opt"/>
            <include name="/legal/jdk.internal.vm.ci"/>
            <include name="/legal/jdk.internal.vm.compiler"/>
            <include name="/legal/jdk.internal.vm.compiler.management"/>
            <include name="/legal/jdk.jartool"/>
            <include name="/legal/jdk.javadoc"/>
            <include name="/legal/jdk.jcmd"/>
            <include name="/legal/jdk.jconsole"/>
            <include name="/legal/jdk.jdeps"/>
            <include name="/legal/jdk.jdi"/>
            <include name="/legal/jdk.jdwp.agent"/>
            <include name="/legal/jdk.jfr"/>
            <include name="/legal/jdk.jlink"/>
            <include name="/legal/jdk.jshell"/>
            <include name="/legal/jdk.jsobject"/>
            <include name="/legal/jdk.jstatd"/>
            <include name="/legal/jdk.localedata"/>
            <include name="/legal/jdk.management"/>
            <include name="/legal/jdk.management.agent"/>
            <include name="/legal/jdk.management.jfr"/>
            <include name="/legal/jdk.naming.dns"/>
            <include name="/legal/jdk.naming.rmi"/>
            <include name="/legal/jdk.net"/>
            <include name="/legal/jdk.pack"/>
            <include name="/legal/jdk.rmic"/>
            <include name="/legal/jdk.scripting.nashorn"/>
            <include name="/legal/jdk.scripting.nashorn.shell"/>
            <include name="/legal/jdk.sctp"/>
            <include name="/legal/jdk.security.auth"/>
            <include name="/legal/jdk.security.jgss"/>
            <include name="/legal/jdk.unsupported"/>
            <include name="/legal/jdk.unsupported.desktop"/>
            <include name="/legal/jdk.xml.dom"/>
            <include name="/legal/jdk.zipfs"/>
        </fileset>
    </path>

    <property name="project.jdk.home" value="${jdk.home.11}"/>
    <property name="project.jdk.bin" value="${jdk.bin.11}"/>
    <property name="project.jdk.classpath" value="jdk.classpath.11"/>


    <!-- Project Libraries -->

    <path id="library.javafx-swt.classpath">
        <pathelement location="${javafx.home}/lib/javafx-swt.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.base.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.controls.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.fxml.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.graphics.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.media.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.swing.jar"/>
        <pathelement location="${javafx.home}/lib/javafx.web.jar"/>
    </path>


    <!-- Global Libraries -->
    <!-- Register Custom Compiler Taskdefs -->
    <property name="javac2.home" value="${idea.home}/lib"/>
    <path id="javac2.classpath">
        <fileset dir="${javac2.home}">
            <include name="javac2.jar"/>
            <include name="jdom.jar"/>
            <include name="asm-all*.jar"/>
            <include name="jgoodies-forms.jar"/>
        </fileset>
    </path>
    <target name="register.custom.compilers">
        <taskdef name="javac2" classname="com.intellij.ant.Javac2" classpathref="javac2.classpath"/>
        <taskdef name="instrumentIdeaExtensions" classname="com.intellij.ant.InstrumentIdeaExtensions"
                 classpathref="javac2.classpath"/>
    </target>

    <!-- Modules -->


    <!-- Module LuckyPick -->

    <dirname property="module.luckypick.basedir" file="${ant.file}"/>


    <property name="module.jdk.home.luckypick" value="${project.jdk.home}"/>
    <property name="module.jdk.bin.luckypick" value="${project.jdk.bin}"/>
    <property name="module.jdk.classpath.luckypick" value="${project.jdk.classpath}"/>

    <property name="compiler.args.luckypick" value="-encoding UTF-8 -source 10 -target 10 ${compiler.args}"/>

    <property name="luckypick.output.dir" value="${module.luckypick.basedir}/out/production/LuckyPick"/>
    <property name="luckypick.testoutput.dir" value="${module.luckypick.basedir}/out/test/LuckyPick"/>

    <path id="luckypick.module.bootclasspath">
        <!-- Paths to be included in compilation bootclasspath -->
    </path>

    <path id="luckypick.module.production.classpath">
        <path refid="${module.jdk.classpath.luckypick}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.runtime.production.module.classpath">
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.module.classpath">
        <path refid="${module.jdk.classpath.luckypick}"/>
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>

    <path id="luckypick.runtime.module.classpath">
        <pathelement location="${luckypick.testoutput.dir}"/>
        <pathelement location="${luckypick.output.dir}"/>
        <path refid="library.javafx-swt.classpath"/>
    </path>


    <patternset id="excluded.from.module.luckypick">
        <patternset refid="ignored.files"/>
    </patternset>

    <patternset id="excluded.from.compilation.luckypick">
        <patternset refid="excluded.from.module.luckypick"/>
    </patternset>

    <path id="luckypick.module.sourcepath">
        <dirset dir="${module.luckypick.basedir}">
            <include name="src"/>
            <include name="res"/>
        </dirset>
    </path>


    <target name="compile.module.luckypick" depends="compile.module.luckypick.production,compile.module.luckypick.tests"
            description="Compile module LuckyPick"/>

    <target name="compile.module.luckypick.production" depends="register.custom.compilers"
            description="Compile module LuckyPick; production classes">
        <mkdir dir="${luckypick.output.dir}"/>
        <javac2 destdir="${luckypick.output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}"
                memorymaximumsize="${compiler.max.memory}" fork="true" executable="${module.jdk.bin.luckypick}/javac">
            <compilerarg line="${compiler.args.luckypick}"/>
            <bootclasspath refid="luckypick.module.bootclasspath"/>
            <classpath refid="luckypick.module.production.classpath"/>
            <src refid="luckypick.module.sourcepath"/>
            <patternset refid="excluded.from.compilation.luckypick"/>
        </javac2>

        <copy todir="${luckypick.output.dir}">
            <fileset dir="${module.luckypick.basedir}/src">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
            <fileset dir="${module.luckypick.basedir}/res">
                <patternset refid="compiler.resources"/>
                <type type="file"/>
            </fileset>
        </copy>
    </target>

    <target name="compile.module.luckypick.tests"
            depends="register.custom.compilers,compile.module.luckypick.production"
            description="compile module LuckyPick; test classes" unless="skip.tests"/>

    <target name="clean.module.luckypick" description="cleanup module">
        <delete dir="${luckypick.output.dir}"/>
        <delete dir="${luckypick.testoutput.dir}"/>
    </target>

    <target name="init" description="Build initialization">
        <!-- Perform any build initialization in this target -->
    </target>

    <target name="clean" depends="clean.module.luckypick" description="cleanup all"/>

    <target name="build.modules" depends="init, clean, compile.module.luckypick" description="build all modules"/>

    <target name="all" depends="build.modules" description="build all"/>
</project>

螞蟻構建輸出:

螞蟻構建輸出

請。 嘗試以下操作:

<project name="luckypick" default="all" basedir="." xmlns:fx="javafx:com.sun.javafx.tools.ant">
...
<target name="all" depends="build.modules" description="build all">
   <taskdef resource="com/sun/javafx/tools/ant/antlib.xml"      
            uri="javafx:com.sun.javafx.tools.ant"
            classpath=".:path/to/sdk/lib/ant-javafx.jar"/>    
</target>

也嘗試使用 JDK 8。從 Oracle JDK 11 中刪除了 Packager。有關詳細信息,請參見此處

打包工具還可以幫助填補其他技術留下的空白,例如從 Oracle 的 JDK 11 中刪除的 Java Web Start 和在 JDK 11 中已棄用以在未來版本中刪除的 pack200。 開發人員可以使用 jlink 將 JDK 剝離為所需的最小模塊集,然后使用打包工具生成可部署到目標機器的壓縮、可安裝映像。

以前為了滿足這些要求,Oracle 的 JDK 8 隨附了一個名為 javapackager 的打包工具。但是,隨着 JavaFX 的刪除,它已從 Oracle 的 JDK 11 中刪除。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM