Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/402.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java JIBX-ant脚本问题_Java_Xml_Ant_Jibx - Fatal编程技术网

Java JIBX-ant脚本问题

Java JIBX-ant脚本问题,java,xml,ant,jibx,Java,Xml,Ant,Jibx,我对jibx和创建jar有问题。我使用NetbeansIDE 在build.xml中,我有: <import file="nbproject/jibx.xml"/> <import file="nbproject/build-impl.xml"/> <target name="-pre-compile" depends="jibx-bind"/> <target name="-post-compile" depends="jibx-postcompil

我对jibx和创建jar有问题。我使用NetbeansIDE

build.xml中,我有:

<import file="nbproject/jibx.xml"/>
<import file="nbproject/build-impl.xml"/>
<target name="-pre-compile" depends="jibx-bind"/>
<target name="-post-compile"  depends="jibx-postcompile">
    <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
        <fileset dir="${basedir}/${build.dir}/jibx/classes">
            <include name="**/*"/>
        </fileset>
    </copy>
</target>

<target name="-pre-jar"  depends="jibx-postcompile">
    <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
        <fileset dir="${basedir}/${build.dir}/jibx/classes">
            <include name="**/*"/>
        </fileset>
    </copy>
</target>
    <?xml version="1.0" encoding="UTF-8"?>
<project>
    <!-- generate using default settings -->
    <target name="jibx-codegen" >
        <echo message="Running code generation from schema"/>
        <java classname="org.jibx.schema.codegen.CodeGen" fork="yes" failonerror="true">
            <arg value="--generate-all=true"/>
            <arg value="-n"/>
            <arg value="jibxmodel"/>
            <arg value="-t"/>
            <arg value="${basedir}/${build.dir}/jibx/src"/>
            <arg value="src/xmlresource/XSD_final2.xsd"/>
            <classpath path="${javac.classpath}"/>
        </java>
        <move toDir="${src.dir}" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/src">
                <include name="**/*.java"/>
            </fileset>
        </move>
        <move toDir="${src.dir}/xmlresource/" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/src">
                <include name="**/*.xml"/>
                <include name="**/binding.xml"/>
            </fileset>
        </move>
    </target>

  <!-- bind as a separate step -->
    <target name="jibx-bind" depends="jibx-compile">
        <echo message="Running JiBX binding compiler : ${basedir}/${build.dir}/classes"/>
        <taskdef name="bind" classname="org.jibx.binding.ant.CompileTask">
            <classpath path="${javac.classpath}"/>
        </taskdef>
        <bind binding="${basedir}/src/xmlresource/binding.xml">
            <classpathset dir="${basedir}/${build.dir}/jibx/classes"/>
        </bind>
        <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/classes">
                <include name="**/*"/>
            </fileset>
        </copy>
    </target>

  <!-- compile the classes -->
    <!--target name="jibx-compile" depends="jibx-codegen"-->
    <target name="jibx-compile">   
        <echo message="Compiling JiBX Java source code"/>
        <mkdir dir="${basedir}/${build.dir}/jibx/classes"/>
        <javac srcdir="${basedir}/${src.dir}/jibxmodel" destdir="${basedir}/${build.dir}/jibx/classes" debug="on" source="1.5">
            <classpath path="${javac.classpath}/classes"/>
        </javac>
    </target>

    <target name="jibx-postcompile" depends="jibx-bind">
        <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/classes">
                <include name="**/*"/>
            </fileset>
        </copy>
    </target>
</project>

jibx.xml中,我有:

<import file="nbproject/jibx.xml"/>
<import file="nbproject/build-impl.xml"/>
<target name="-pre-compile" depends="jibx-bind"/>
<target name="-post-compile"  depends="jibx-postcompile">
    <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
        <fileset dir="${basedir}/${build.dir}/jibx/classes">
            <include name="**/*"/>
        </fileset>
    </copy>
</target>

<target name="-pre-jar"  depends="jibx-postcompile">
    <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
        <fileset dir="${basedir}/${build.dir}/jibx/classes">
            <include name="**/*"/>
        </fileset>
    </copy>
</target>
    <?xml version="1.0" encoding="UTF-8"?>
<project>
    <!-- generate using default settings -->
    <target name="jibx-codegen" >
        <echo message="Running code generation from schema"/>
        <java classname="org.jibx.schema.codegen.CodeGen" fork="yes" failonerror="true">
            <arg value="--generate-all=true"/>
            <arg value="-n"/>
            <arg value="jibxmodel"/>
            <arg value="-t"/>
            <arg value="${basedir}/${build.dir}/jibx/src"/>
            <arg value="src/xmlresource/XSD_final2.xsd"/>
            <classpath path="${javac.classpath}"/>
        </java>
        <move toDir="${src.dir}" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/src">
                <include name="**/*.java"/>
            </fileset>
        </move>
        <move toDir="${src.dir}/xmlresource/" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/src">
                <include name="**/*.xml"/>
                <include name="**/binding.xml"/>
            </fileset>
        </move>
    </target>

  <!-- bind as a separate step -->
    <target name="jibx-bind" depends="jibx-compile">
        <echo message="Running JiBX binding compiler : ${basedir}/${build.dir}/classes"/>
        <taskdef name="bind" classname="org.jibx.binding.ant.CompileTask">
            <classpath path="${javac.classpath}"/>
        </taskdef>
        <bind binding="${basedir}/src/xmlresource/binding.xml">
            <classpathset dir="${basedir}/${build.dir}/jibx/classes"/>
        </bind>
        <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/classes">
                <include name="**/*"/>
            </fileset>
        </copy>
    </target>

  <!-- compile the classes -->
    <!--target name="jibx-compile" depends="jibx-codegen"-->
    <target name="jibx-compile">   
        <echo message="Compiling JiBX Java source code"/>
        <mkdir dir="${basedir}/${build.dir}/jibx/classes"/>
        <javac srcdir="${basedir}/${src.dir}/jibxmodel" destdir="${basedir}/${build.dir}/jibx/classes" debug="on" source="1.5">
            <classpath path="${javac.classpath}/classes"/>
        </javac>
    </target>

    <target name="jibx-postcompile" depends="jibx-bind">
        <copy toDir="${basedir}/${build.dir}/classes" overwrite="true">
            <fileset dir="${basedir}/${build.dir}/jibx/classes">
                <include name="**/*"/>
            </fileset>
        </copy>
    </target>
</project>

Jibx编译的文件转到${build.dir}/Jibx/classes
打包后,jibx无法正常工作。我需要在ant脚本中更改什么?非常感谢您的帮助。

“打包后,jibx无法正常工作”-需要更多信息当我调用jar目标时,它会用新的类覆盖jibx增强的类。显示ant build.xml文件中的jar目标。更好:向我们展示ant和jibx xml文件的完整内容。“打包后,jibx无法正常工作”-需要更多信息当我调用jar目标时,它会用新的类覆盖jibx增强的类。向我们展示ant build.xml文件中的jar目标。更好:向我们展示ant和JiBXXML文件的完整内容。