在gwt中将jar添加到ant类路径中



我是gwt和ant的新手。早些时候,我正在使用maven/sspring-playFramework/sbt。

我想在我的gwt项目中添加一些外部jar,比如:

  • gwt3引导
  • 休眠
  • mysql连接器等

我已将jar添加到项目中的lib文件夹中:-gwt束带3-0.9.1.jar-gwtbootstrap3-extras-0.91.jar

但我在控制台上得到了一个错误:

Runing CodeServer with parameters: [-noprecompile, -port, 42543, -sourceLevel, 1.7, -bindAddress, 127.0.0.1, -launcherDir, /home/danielo/eclipseGwt/StockWatcher/war, -logLevel, INFO, com.google.gwt.sample.stockwatcher.StockWatcher]
Super Dev Mode starting up
   workDir: /tmp/gwt-codeserver-6966154251496651044.tmp
   Loading inherited module 'com.google.gwt.sample.stockwatcher.StockWatcher'
      Loading inherited module 'com.github.gwtbootstrap.Bootstrap'
         [ERROR] Unable to find 'com/github/gwtbootstrap/Bootstrap.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
Loading modules
   com.google.gwt.sample.stockwatcher.StockWatcher
      Loading inherited module 'com.google.gwt.sample.stockwatcher.StockWatcher'
         Loading inherited module 'com.github.gwtbootstrap.Bootstrap'
            [ERROR] Unable to find 'com/github/gwtbootstrap/Bootstrap.gwt.xml' on your classpath; could be a typo, or maybe you forgot to include a classpath entry for source?
[ERROR] shell failed in doStartup method

MyProject.gwt.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.6.2//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.6.2/distro-source/core/src/gwt-module.dtd">
<module rename-to='stockwatcher'>
    <!-- Inherit the core Web Toolkit stuff. -->
    <inherits name='com.google.gwt.user.User' />
    <!-- Inherit the default GWT style sheet. You can change -->
    <!-- the theme of your GWT application by uncommenting -->
    <!-- any one of the following lines. -->
    <inherits name='com.google.gwt.user.theme.standard.Standard' />
    <inherits name="com.github.gwtbootstrap.Bootstrap" />
    <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
    <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
    <!-- Other module inherits -->
    <!-- Specify the app entry point class. -->
    <entry-point class='com.google.gwt.sample.stockwatcher.client.StockWatcher' />
</module>

build.xml:

<?xml version="1.0" encoding="utf-8" ?>
<project name="StockWatcher" default="build" basedir=".">
    <!-- Configure path to GWT SDK -->
    <property name="gwt.sdk" location="/path/to/gwt.sdk" />
    <path id="project.class.path">
        <pathelement location="war/WEB-INF/classes" />
        <pathelement location="${gwt.sdk}/gwt-user.jar" />
        <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
        <!-- Add any additional non-server libs (such as JUnit) -->
        <fileset dir="war/WEB-INF/lib" includes="**/*.jar" />
    </path>
    <target name="libs" description="Copy libs to WEB-INF/lib">
        <mkdir dir="war/WEB-INF/lib" />
        <copy todir="war/WEB-INF/lib" file="${gwt.sdk}/gwt-servlet.jar" />
        <!-- Add any additional server libs that need to be copied -->
    </target>
    <target name="javac" depends="libs" description="Compile java source">
        <mkdir dir="war/WEB-INF/classes" />
        <javac srcdir="src" includes="**" encoding="utf-8" destdir="war/WEB-INF/classes" source="1.5" target="1.5" nowarn="true" debug="true" debuglevel="lines,vars,source">
            <classpath refid="project.class.path" />
        </javac>
        <copy todir="war/WEB-INF/classes">
            <fileset dir="src" excludes="**/*.java" />
        </copy>
    </target>
    <target name="gwtc" depends="javac" description="GWT compile to JavaScript">
        <java failonerror="true" fork="true" classname="com.google.gwt.dev.Compiler">
            <classpath>
                <pathelement location="src" />
                <path refid="project.class.path" />
            </classpath>
            <!-- add jvmarg -Xss16M or similar if you see a StackOverflowError -->
            <jvmarg value="-Xmx256M" />
            <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
            <arg value="com.google.gwt.sample.stockwatcher.StockWatcher" />
        </java>
    </target>
    <target name="devmode" depends="javac" description="Run development mode">
        <java failonerror="true" fork="true" classname="com.google.gwt.dev.DevMode">
            <classpath>
                <pathelement location="src" />
                <path refid="project.class.path" />
            </classpath>
            <jvmarg value="-Xmx256M" />
            <arg value="-startupUrl" />
            <arg value="StockWatcher.html" />
            <!-- Additional arguments like -style PRETTY or -logLevel DEBUG -->
            <arg value="com.google.gwt.sample.stockwatcher.StockWatcher" />
        </java>
    </target>
    <target name="javac.tests" depends="javac" description="Compiles test code">
        <javac srcdir="test" includes="**" encoding="utf-8" source="1.5" target="1.5" nowarn="true" debug="true" debuglevel="lines,vars,source">
            <classpath location="path_to_the_junit_jar" />
            <classpath refid="project.class.path" />
        </javac>
    </target>
    <target name="test.dev" depends="javac.tests" description="Run development mode tests">
        <mkdir dir="reports/htmlunit.dev" />
        <junit fork="yes" printsummary="yes" haltonfailure="yes">
            <jvmarg line="-Xmx256m" />
            <sysproperty key="gwt.args" value="-logLevel WARN" />
            <sysproperty key="java.awt.headless" value="true" />
            <classpath>
                <pathelement location="src" />
                <pathelement location="test" />
                <path refid="project.class.path" />
                <pathelement location="path_to_the_junit_jar" />
            </classpath>
            <batchtest todir="reports/htmlunit.dev">
                <fileset dir="test">
                    <include name="**/*Test.java" />
                </fileset>
            </batchtest>
            <formatter type="plain" />
            <formatter type="xml" />
        </junit>
    </target>
    <target name="test.prod" depends="javac.tests" description="Run production mode tests">
        <mkdir dir="reports/htmlunit.prod" />
        <junit fork="yes" printsummary="yes" haltonfailure="yes">
            <jvmarg line="-Xmx256m" />
            <sysproperty key="gwt.args" value="-prod -logLevel WARN -out www-test" />
            <sysproperty key="java.awt.headless" value="true" />
            <classpath>
                <pathelement location="src" />
                <pathelement location="test" />
                <path refid="project.class.path" />
                <pathelement location="path_to_the_junit_jar" />
            </classpath>
            <batchtest todir="reports/htmlunit.prod">
                <fileset dir="test">
                    <include name="**/*Test.java" />
                </fileset>
            </batchtest>
            <formatter type="plain" />
            <formatter type="xml" />
        </junit>
    </target>
    <target name="test" description="Run development and production mode tests">
        <antcall target="test.dev" />
        <antcall target="test.prod" />
    </target>
    <target name="hosted" depends="devmode" description="Run development mode (NOTE: the 'hosted' target is deprecated)" />
    <target name="build" depends="gwtc" description="Build this project" />
    <target name="war" depends="build" description="Create a war file">
        <zip destfile="StockWatcher.war" basedir="war" />
    </target>
    <target name="clean" description="Cleans this project">
        <delete dir="war/WEB-INF/classes" failonerror="false" />
        <delete dir="war/stockwatcher" failonerror="false" />
    </target>
</project>

我还尝试在项目->属性->Java构建路径->库选项卡->添加外部JAR 上使用eclipse RMB添加这个jar

但这对我没有帮助。

请给我一些帮助。

我已经搜索了很多论坛帖子中的相同问题,但无法自行解决。

只需使用gwtBootstrap3,您就必须下载它的jar!这里是链接

比您必须在build.xml 中声明pathelement

<path id="project.class.path">
        <pathelement location="war/WEB-INF/classes" />
        <pathelement location="${gwt.sdk}/gwt-user.jar" />
        <pathelement location="yourpathtojar/gwtbootstrap3-0.9.1.jar" />
        <fileset dir="${gwt.sdk}" includes="gwt-dev*.jar" />
        <!-- Add any additional non-server libs (such as JUnit) -->
        <fileset dir="war/WEB-INF/lib" includes="**/*.jar" />
    </path>

如果您使用maven项目,则可以遵循以下示例

相关内容

  • 没有找到相关文章

最新更新