【问题标题】:Netbeans ant build error 'unsupported element customize'Netbeans ant 构建错误“不支持的元素自定义”
【发布时间】:2014-10-27 12:56:55
【问题描述】:

我从 7.0.1 更新到 Netbeans 8.0.1,如果禁用“Web Start”,我的 java 程序编译得很好。一旦启用“Web Start”,我就会收到以下错误:

C:\NetBeansProjects\SearchCriteriaEditor\nbproject\jnlp-impl.xml:480: 
unsupported element customize
  • 在 jnlp-impl.xml 文件的这一部分中:

    <target name="-do-jar-jnlp-application" depends="-init-filename,-test-jnlp-type,-init-macrodef-copylibs" if="is.application+mkdist.available"> <j2seproject3:copylibs manifest="${tmp.manifest.file}"> <customize> <attribute name="Main-Class" value="${main.class}"/> </customize> </j2seproject3:copylibs> <echo>To run this application from the command line without Ant, try:</echo> <property location="${jnlp.dest.dir}/${jnlp.file}" name="jnlp.file.resolved"/> <echo>javaws "${jnlp.file.resolved}"</echo> </target>

据我所知,修复是:'将以下内容添加到自定义的 junit 宏定义中:'

<attribute default="" name="testmethods"/>
   <element name="customize" optional="true"/>
<customize/>

问题是我不知道那在哪里,也没有以任何方式修改过我的 ant 文件...谁能给我更多信息?我假设修复程序位于 jnlp-impl.xml 文件中的某个位置;我只是不知道该放在哪里。

编辑更新:在 jnlp-impl.xml 文件中添加了所有引用“copylibs”的部分-

<target name="-test-jnlp-type" depends="-test-jnlp-enabled" if="is.jnlp.enabled">
    <condition property="is.applet">
        <equals arg1="${jnlp.descriptor}" arg2="applet" trim="true"/>
    </condition>
    <condition property="is.application">
        <equals arg1="${jnlp.descriptor}" arg2="application" trim="true"/>
    </condition>
    <condition property="is.component">
        <equals arg1="${jnlp.descriptor}" arg2="component" trim="true"/>
    </condition>
    <condition property="is.applet+mkdist.available">
        <and>
            <isset property="libs.CopyLibs.classpath"/>
            <istrue value="${is.applet}"/>
        </and>
    </condition>
    <condition property="is.application+mkdist.available">
        <and>
            <isset property="libs.CopyLibs.classpath"/>
            <istrue value="${is.application}"/>
        </and>
    </condition>
    <condition property="is.component+mkdist.available">
        <and>
            <isset property="libs.CopyLibs.classpath"/>
            <istrue value="${is.component}"/>
        </and>
    </condition>
</target>

......

<target name="-do-jar-jnlp-application" depends="-init-filename,-test-jnlp-type,-init-macrodef-copylibs" if="is.application+mkdist.available">
    <j2seproject3:copylibs manifest="${tmp.manifest.file}">
        <customize>
            <attribute name="Main-Class" value="${main.class}"/>
        </customize>
    </j2seproject3:copylibs>
    <echo>To run this application from the command line without Ant, try:</echo>
    <property location="${jnlp.dest.dir}/${jnlp.file}" name="jnlp.file.resolved"/>
    <echo>javaws "${jnlp.file.resolved}"</echo>
</target>
<target name="-do-jar-jnlp-component" depends="-test-jnlp-type,-init-macrodef-copylibs" if="is.component+mkdist.available">
    <j2seproject3:copylibs manifest="${tmp.manifest.file}"/>
</target>

提前致谢。

【问题讨论】:

    标签: java netbeans ant


    【解决方案1】:

    &lt;j2seproject3:copylibs 使用命名空间前缀 j2seproject3 调用宏定义 copylibs。在构建文件中应该有一个位置定义了 copylibs 宏,其方式类似于(但不一定准确):

    <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
    

    上述行逻辑上应该存在于-init-macrodef-copylibs 目标中,这也是customize 元素应该定义的地方。下面是基于我拥有的示例 NetBeans 项目的 sn-p。内容可能与您所拥有的内容不完全匹配,因此请对我的回答持保留态度:

    <macrodef name="copylibs" uri="http://www.netbeans.org/ns/j2se-project/3">
        ... <!-- some attributes may be defined here first -->
        <element name="customize" optional="true"/>  <!-- customize should be defined here -->
        <sequential>
            ...
            <!-- somewhere in the macrodef -->
            <copylibs compress="${jar.compress}" index="${jar.index}" jarfile="${dist.jar}" manifest="${manifest.file}" runtimeclasspath="${run.classpath.without.build.classes.dir}">
                <fileset dir="${build.classes.dir}"/>
                <manifest>
                    <attribute name="Class-Path" value="${jar.classpath}"/>
                    <customize/>    <!-- this is where customize is used -->  
                </manifest>
             </copylibs>
             ...
        </sequential>
    </macrodef>
    

    【讨论】:

    • 嗨 manouti,很抱歉让您感到痛苦.. copylibs 没有宏定义。我已将 nlp-impl.xml 中对 copylibs 的所有引用添加到原始问题中。我需要将其添加到文件中吗?
    • @Robbie62 肯定在某处存在copylibs 的定义。是否可以在 jnlp-impl.xml 导入的不同 Ant 构建文件中?
    • 嗨 manouti,是的,我完全忘记了另一个构建文件。我目前正在参加 Google Startup 挑战赛,所以我要过几天才能回到它。
    • 在这件事上工作了四年之后,我认为可能会出现倦怠。全局搜索和替换的经典案例,替换它不应该的东西。澳大利亚人将自定义拼写为“自定义”,所以当我重新启用 webstart 并且它使用了一个带有“自定义”的条目时,它找不到原始定义,因为全球搜索已经改变了它。谢谢你 manouti,至少你得到了我找对地方了……我非常感激。
    猜你喜欢
    • 1970-01-01
    • 2018-07-05
    • 1970-01-01
    • 2015-10-27
    • 1970-01-01
    • 2013-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多