[英]Why ivy doesn't compile my class?
I am using ANT and IVY to resolve the dependencies and build the project. 我正在使用ANT和IVY来解决依赖关系并构建项目。 I have to write a selenium test case, so I have included the selenium dependency in the IVY file as below:
我必须编写一个硒测试用例,因此我在IVY文件中包括了硒依赖关系,如下所示:
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="2.48.2"/>
IVY is able to download the dependency, But When I compile the project using ANT it fails with the below error: IVY能够下载依赖项,但是当我使用ANT编译项目时,它失败并显示以下错误:
cannot find symbol
[javac] symbol : class WebDriver
[javac] location: class com.barclays.test.selenium.TestSelenium
[javac] WebDriver driver = new FirefoxDriver();
So could you please let me know anything I am missing. 所以你能让我知道我想念的任何东西吗?
EDIT: 编辑:
part of build.xml: build.xml的一部分:
<target name="init">
<ivy:resolve />
<ivy:cachepath pathid="compile.path" conf="compile" />
<ivy:cachepath pathid="test.path" conf="test" />
</target>
<target name="clean">
<delete dir="${target.dir}" />
</target>
<target name="prepare" depends="clean" description="Create working dirs and copy static files to work dir">
<mkdir dir="${target.dir}/WEB-INF/classes" />
<mkdir dir="${target.dir}/WEB-INF/classes-test" />
<!-- Copy static HTML and JSP files to work dir -->
<copy todir="${target.dir}">
<fileset dir="${web.home}" />
</copy>
</target>
<target name="compile" depends="prepare, init" description="Compile Java sources and copy to WEB-INF/classes dir">
<javac srcdir="${src.dir}" includeantruntime="false" debug="true" classpathref="compile.path" destdir="${target.dir}/WEB-INF/classes">
</javac>
<javac srcdir="${test.dir}" includeantruntime="false" debug="true" classpathref="test.path" destdir="${target.dir}/WEB-INF/classes-test">
<classpath>
<pathelement location="${target.dir}/WEB-INF/classes" />
</classpath>
</javac>
<copy todir="${target.dir}/WEB-INF/classes">
<fileset dir="${src.dir}" excludes="**/*.java" />
</copy>
</target>
And ivy.xml : 和ivy.xml:
<ivy-module version="2.0">
<info organisation="org.apache" module="test-ivy" />
<configurations>
<conf name="runtime" />
<conf name="compile" extends="runtime" description="provides the
compiler" />
<conf name="test" description="Required for test only" extends="runtime"/>
</configurations>
<dependencies>
<dependency org="javax.servlet" name="servlet-api" rev="2.5" />
<dependency org="junit" name="junit" rev="4.12" />
<dependency org="org.seleniumhq.selenium" name="selenium-java" rev="2.48.2" conf="test-java->default"/>
<dependency org="log4j" name="log4j" rev="1.2.16" conf="compile->*" />
</dependencies>
</ivy-module>
Same case with log4j as well. 与log4j同样的情况。 I have added the dependency, but when I tried to create a Logger object, eclipse doesn't list the log4j's logger when using code assist.
我已经添加了依赖性,但是当我尝试创建Logger对象时,使用代码辅助时eclipse不会列出log4j的记录器。
Thanks 谢谢
in your build.xml you're compiling the test classes not with the test classpath, but with compile classpath. 在build.xml中,您不是使用测试类路径来编译测试类,而是使用编译类路径来编译测试类。
Classpathref should be set to test.path
Classpathref应该设置为
test.path
<javac srcdir="${test.dir}" includeantruntime="false" debug="true" classpathref="test.path" destdir="${target.dir}/WEB-INF/classes-test">
<classpath>
<pathelement location="${target.dir}/WEB-INF/classes" />
</classpath>
</javac>
and you should define the scope for each of the ivy dependencies. 并且应该为每个常春藤依赖项定义范围。 Like this:
像这样:
<!-- Compile time-->
<dependency org="log4j" name="log4j" rev="1.2.14" conf="compile->*"/>
<!-- test time-->
<dependency org="log4j" name="log4j" rev="1.2.14" conf="test->*"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.