ANT 为项目 src & 构建路径优先级gwt 罐子
我在 ant 构建文件中的构建路径有问题。由于 gwt 中的错误。我在我的项目中创建了 1 个 gwt 包(com.google.gwt.user.client.ui)复制了MenuBar类,我修改了Menubar类代码来解决我们的问题。它的工作很棒。即使我也可以从 eclipse 编译它。
但问题是当我运行 ant 构建文件时。菜单栏类取自 gwt jar &抛出“未解决的方法”的异常。我想 ant 构建从我的项目包中获取 MenuBar 类而不是 gwt jar。
请帮我解决这个问题。
下面是build.xml文件内容
--> --> -->
<property name="main-class" value="com.my.project.main.Main" />
<!-- defbizserver libraries
<path id="libraries">
<fileset dir="./libs">
<include name="*.jar"/>
</fileset>
</path>-->
<!-- accounter server libraries-->
<!--<path id="acclibraries">
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
<fileset dir="${acc.dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${acc.dir}/src"/>
</path>-->
<!-- gwt libraries-->
<path id="gwtlibraries">
<fileset dir="${bizantragui.dir}">
<include name="**/**.jar" />
</fileset>
<fileset dir="./libs">
<include name="*.jar" />
</fileset>
<fileset dir="${acc.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${src.dir}" />
<pathelement location="${acc.dir}/src" />
<pathelement location="${gwt.sdk}/gwt-user.jar" />
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
<pathelement location="${bizantragui.dir}/src" />
<!--<pathelement location="${comet.dir}/src" />-->
<!--<pathelement location="${network.dir}/src" />-->
</path>
<fileset file="webapp" id="webapp">
<exclude name=".svn" />
</fileset>
<target name="clean">
<delete dir="${build.dir}" />
<delete defaultExcludes="false">
<fileset dir="./webapp/myprouject" />
</delete>
</target>
<!--Compiling-->
<target name="compile" depends="check-gwtpath" if="gwt.present">
<mkdir dir="${classes.dir}" />
<mkdir dir="${libs.dir}" />
<copy todir="${classes.dir}">
<fileset dir="${acc.dir}/war/WEB-INF/classes">
<include name="**/**" />
</fileset>
</copy>
<!--<javac srcdir="${comet.dir}/src" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />
<!--<javac srcdir="${network.dir}" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
<!--<javac srcdir="${acc.dir}/src" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
</target>
<target name="gwtcompile" description="GWT COMPILATION">
<mkdir dir="./webapp" />
<java classpathref="gwtlibraries" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="${bizantragui.dir}/src" />
<pathelement location="${acc.dir}/src" />
</classpath>
<jvmarg value="-Xmx1024m" />
<arg line="-war ./webapp/" />
<arg line="-style OBF" />
<arg line="com.bizantra.Bizantra">
</arg>
<arg line="-localWorkers 2" />
</java>
</target>
<target name="makewebapp">
<foreach target="compress_file" param="file">
<path>
<fileset dir="./webapp/bizantra" id="outputhtml">
<include name="*.cache.js" />
<include name="**/*.js" />
</fileset>
</path>
</foreach>
</target>
<target name="compress_file" description="Compress file and make gz file">
<gzip src="${file}" zipfile="${file}.gz" />
</target>
<target name="setup" depends="compile,gwtcompile,makewebapp">
<mkdir dir="${classes.dir}" />
<!-- <copy todir="${classes.dir}">
<fileset dir="./">
<exclude name="*xml" />
<exclude name="build.xml" />
</fileset>
<fileset dir="${acc.dir}/src">
<exclude name="*xml" />
</fileset>
</copy>-->
<!--<copy todir="${classes.dir}/webapp/images">
<fileset dir="${bizantragui.dir}/war/images">
<include name="**/*.*" />
</fileset>
<fileset dir="${acc.dir}/war/images">
<include name="**/*.*" />
</fileset>
</copy>-->
<!--<copy todir="${classes.dir}/webapp">
<fileset dir="${network.dir}/war">
<include name="**/*.html" />
<include name="**/*.jsp" />
</fileset>
</copy>-->
<mkdir dir="${classes.dir}/webapp" />
<mkdir dir="${classes.dir}/mapping" />
<copy todir="${classes.dir}/mapping">
<fileset dir="./mapping">
</fileset>
</copy>
<!--<copy todir="${classes.dir}/networkmapping">
<fileset dir="./networkmapping">
</fileset>
</copy>-->
<copy todir="${classes.dir}">
<fileset dir="src/">
<include name="**/*.properties" />
</fileset>
<fileset dir="${acc.dir}/src">
<include name="**/*.properties" />
</fileset>
</copy>
<copy todir="${libs.dir}">
<fileset dir="./">
<include name="*.jar" />
</fileset>
</copy>
<jar destfile="${libs.dir}/${ant.project.name}.jar" basedir="${classes.dir}" index="true">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
<delete dir="${classes.dir}">
</delete>
</target>
<!--tar Setup-->
<target name="linux-setup-tar" depends="setup">
<copy todir="${setup.dir}/tar">
<fileset dir="./">
<include name="config/**" />
<include name="libs/**" />
</fileset>
</copy>
<copy todir="${linuxtar-lib.dir}">
<fileset dir="${libs.dir}">
</fileset>
</copy>
<mkdir dir="${tmp.dir}" />
<copy todir="${tmp.dir}">
<fileset dir="${setup.dir}/tar">
<exclude name=".svn/*" />
</fileset>
</copy>
<chmod file="${tmp.dir}/collaberserver" perm="+x" />
<chmod file="${tmp.dir}/collaberserverd" perm="+x" />
<tar destfile="${output.dir}/bizantra-1.0.tar" basedir="${tmp.dir}" />
<gzip destfile="${output.dir}/bizantra-1.0.tar.gz" src="${output.dir}/bizantra-1.0.tar" />
<delete dir="${tmp.dir}" />
<delete file="${output.dir}/bizantra-1.0.tar" />
</target>
<!--Windows Setup-->
<target name="win-setup" depends="setup">
<copy todir="${setup.dir}/windows">
<fileset dir="./">
<include name="libs/**" />
</fileset>
</copy>
<copy todir="${win-lib.dir}">
<fileset dir="${libs.dir}">
<include name="*.jar" />
</fileset>
</copy>
<exec command="makensis ${setup.dir}/windows/BizantraSetup.nsi">
</exec>
<copy todir="${output.dir}">
<fileset dir="${setup.dir}/windows">
<include name="BizantraSetupWithJRE.exe" />
</fileset>
</copy>
<delete>
<fileset dir="${setup.dir}/windows">
<include name="BizantraSetupWithJRE.exe" />
</fileset>
</delete>
<move todir="${output.dir}">
<fileset dir="${setup.dir}/windows">
<include name="Bizantra.exe" />
</fileset>
</move>
</target>
<target name="clean-setup" depends="clean,setup" />
<target name="setupandclean" depends="clean-setup,linux-setup-tar,win-setup" />
I have problem with build path in ant build file. due to bug in gwt. I created 1 gwt package(com.google.gwt.user.client.ui) into my project & copied MenuBar class, I modified the Menubar class code to solve our problem. its work great. even i can compile it from eclipse too.
But problem is that when i run ant build file. Menu Bar class taking from gwt jar & throws exception that "unresolved methods". I want to ant builds takes MenuBar class from my project package instead of gwt jar.
Please help me out what to do for that.
Below is the build.xml file content
-->
-->
-->
<property name="main-class" value="com.my.project.main.Main" />
<!-- defbizserver libraries
<path id="libraries">
<fileset dir="./libs">
<include name="*.jar"/>
</fileset>
</path>-->
<!-- accounter server libraries-->
<!--<path id="acclibraries">
<pathelement location="${gwt.sdk}/gwt-user.jar"/>
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar"/>
<fileset dir="${acc.dir}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${acc.dir}/src"/>
</path>-->
<!-- gwt libraries-->
<path id="gwtlibraries">
<fileset dir="${bizantragui.dir}">
<include name="**/**.jar" />
</fileset>
<fileset dir="./libs">
<include name="*.jar" />
</fileset>
<fileset dir="${acc.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement location="${src.dir}" />
<pathelement location="${acc.dir}/src" />
<pathelement location="${gwt.sdk}/gwt-user.jar" />
<fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
<pathelement location="${bizantragui.dir}/src" />
<!--<pathelement location="${comet.dir}/src" />-->
<!--<pathelement location="${network.dir}/src" />-->
</path>
<fileset file="webapp" id="webapp">
<exclude name=".svn" />
</fileset>
<target name="clean">
<delete dir="${build.dir}" />
<delete defaultExcludes="false">
<fileset dir="./webapp/myprouject" />
</delete>
</target>
<!--Compiling-->
<target name="compile" depends="check-gwtpath" if="gwt.present">
<mkdir dir="${classes.dir}" />
<mkdir dir="${libs.dir}" />
<copy todir="${classes.dir}">
<fileset dir="${acc.dir}/war/WEB-INF/classes">
<include name="**/**" />
</fileset>
</copy>
<!--<javac srcdir="${comet.dir}/src" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
<javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />
<!--<javac srcdir="${network.dir}" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
<!--<javac srcdir="${acc.dir}/src" destdir="${classes.dir}" classpathref="gwtlibraries" debug="true" />-->
</target>
<target name="gwtcompile" description="GWT COMPILATION">
<mkdir dir="./webapp" />
<java classpathref="gwtlibraries" fork="true" classname="com.google.gwt.dev.Compiler">
<classpath>
<pathelement location="${bizantragui.dir}/src" />
<pathelement location="${acc.dir}/src" />
</classpath>
<jvmarg value="-Xmx1024m" />
<arg line="-war ./webapp/" />
<arg line="-style OBF" />
<arg line="com.bizantra.Bizantra">
</arg>
<arg line="-localWorkers 2" />
</java>
</target>
<target name="makewebapp">
<foreach target="compress_file" param="file">
<path>
<fileset dir="./webapp/bizantra" id="outputhtml">
<include name="*.cache.js" />
<include name="**/*.js" />
</fileset>
</path>
</foreach>
</target>
<target name="compress_file" description="Compress file and make gz file">
<gzip src="${file}" zipfile="${file}.gz" />
</target>
<target name="setup" depends="compile,gwtcompile,makewebapp">
<mkdir dir="${classes.dir}" />
<!-- <copy todir="${classes.dir}">
<fileset dir="./">
<exclude name="*xml" />
<exclude name="build.xml" />
</fileset>
<fileset dir="${acc.dir}/src">
<exclude name="*xml" />
</fileset>
</copy>-->
<!--<copy todir="${classes.dir}/webapp/images">
<fileset dir="${bizantragui.dir}/war/images">
<include name="**/*.*" />
</fileset>
<fileset dir="${acc.dir}/war/images">
<include name="**/*.*" />
</fileset>
</copy>-->
<!--<copy todir="${classes.dir}/webapp">
<fileset dir="${network.dir}/war">
<include name="**/*.html" />
<include name="**/*.jsp" />
</fileset>
</copy>-->
<mkdir dir="${classes.dir}/webapp" />
<mkdir dir="${classes.dir}/mapping" />
<copy todir="${classes.dir}/mapping">
<fileset dir="./mapping">
</fileset>
</copy>
<!--<copy todir="${classes.dir}/networkmapping">
<fileset dir="./networkmapping">
</fileset>
</copy>-->
<copy todir="${classes.dir}">
<fileset dir="src/">
<include name="**/*.properties" />
</fileset>
<fileset dir="${acc.dir}/src">
<include name="**/*.properties" />
</fileset>
</copy>
<copy todir="${libs.dir}">
<fileset dir="./">
<include name="*.jar" />
</fileset>
</copy>
<jar destfile="${libs.dir}/${ant.project.name}.jar" basedir="${classes.dir}" index="true">
<manifest>
<attribute name="Main-Class" value="${main-class}" />
</manifest>
</jar>
<delete dir="${classes.dir}">
</delete>
</target>
<!--tar Setup-->
<target name="linux-setup-tar" depends="setup">
<copy todir="${setup.dir}/tar">
<fileset dir="./">
<include name="config/**" />
<include name="libs/**" />
</fileset>
</copy>
<copy todir="${linuxtar-lib.dir}">
<fileset dir="${libs.dir}">
</fileset>
</copy>
<mkdir dir="${tmp.dir}" />
<copy todir="${tmp.dir}">
<fileset dir="${setup.dir}/tar">
<exclude name=".svn/*" />
</fileset>
</copy>
<chmod file="${tmp.dir}/collaberserver" perm="+x" />
<chmod file="${tmp.dir}/collaberserverd" perm="+x" />
<tar destfile="${output.dir}/bizantra-1.0.tar" basedir="${tmp.dir}" />
<gzip destfile="${output.dir}/bizantra-1.0.tar.gz" src="${output.dir}/bizantra-1.0.tar" />
<delete dir="${tmp.dir}" />
<delete file="${output.dir}/bizantra-1.0.tar" />
</target>
<!--Windows Setup-->
<target name="win-setup" depends="setup">
<copy todir="${setup.dir}/windows">
<fileset dir="./">
<include name="libs/**" />
</fileset>
</copy>
<copy todir="${win-lib.dir}">
<fileset dir="${libs.dir}">
<include name="*.jar" />
</fileset>
</copy>
<exec command="makensis ${setup.dir}/windows/BizantraSetup.nsi">
</exec>
<copy todir="${output.dir}">
<fileset dir="${setup.dir}/windows">
<include name="BizantraSetupWithJRE.exe" />
</fileset>
</copy>
<delete>
<fileset dir="${setup.dir}/windows">
<include name="BizantraSetupWithJRE.exe" />
</fileset>
</delete>
<move todir="${output.dir}">
<fileset dir="${setup.dir}/windows">
<include name="Bizantra.exe" />
</fileset>
</move>
</target>
<target name="clean-setup" depends="clean,setup" />
<target name="setupandclean" depends="clean-setup,linux-setup-tar,win-setup" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的源代码需要比 GWT 源代码更早地位于类路径中,以便首先找到您的 MenuBar 版本。
看起来您在 GWT 编译任务中同时使用了 classpathref 属性和嵌套类路径元素。嵌套的类路径显得多余。我并不是说这一定是您问题的原因,但我建议您花一些时间整理类路径声明。我猜你会在这个过程中解决这个问题。如果没有,至少会更容易看到类路径中发生了什么。
You need to have your source earlier in the classpath than the GWT source so that your version of MenuBar is found first.
It looks like you're using both a classpathref attribute and nested classpath element in your GWT compilation task. The nested classpath appears redundant. I'm not saying that's necessarily the cause of your problem, but I would suggest that you spend some time tidying up the classpath declarations. I would guess that you'll fix the problem in the process. If not, it will at least be easier to see what's going on in your classpath.