[英]How can I add bundled jars to my classpath in an Ant build task?
I have a plugin-project in Eclipse. 我在Eclipse中有一个插件项目。 I want to compile my code with ant.
我想用ant编译我的代码。 Now I need to add a jar to my classpath, which has also a couple of jars in its classpath.
现在,我需要在我的类路径中添加一个jar,它的类路径中也有几个jar。 There are several packages exported, which are required to compile the code.
有几个导出的软件包,它们是编译代码所必需的。 When I add this jar to my dependencies and run the code with Eclipse, everything works fine.
当我将此jar添加到我的依赖项并使用Eclipse运行代码时,一切正常。 But ant somehow can't find the required imports.
但是蚂蚁不知何故找不到所需的进口。 The Manifest of the bundle testfxplugin.jar:
捆绑包testfxplugin.jar的清单:
Manifest-Version: 1.0
Automatic-Module-Name: dummyjar
Bundle-SymbolicName: dummyjar
Export-Package: com.sun.glass.ui.monocle,org.hamcrest,org.hamcrest.cor
e,org.hamcrest.internal,org.testfx.api,org.testfx.assertions.api,org.
testfx.assertions.impl,org.testfx.framework.junit,org.testfx.internal
,org.testfx.matcher.base,org.testfx.matcher.control,org.testfx.osgi,o
rg.testfx.osgi.service,org.testfx.robot,org.testfx.robot.impl,org.tes
tfx.service.adapter,org.testfx.service.adapter.impl,org.testfx.servic
e.finder,org.testfx.service.finder.impl,org.testfx.service.locator,or
g.testfx.service.locator.impl,org.testfx.service.query,org.testfx.ser
vice.query.impl,org.testfx.service.support,org.testfx.service.support
.impl,org.testfx.toolkit,org.testfx.toolkit.impl,org.testfx.util
Bundle-Name: Dummyjar
Bundle-Version: 1.0.0.qualifier
Bundle-ClassPath: libs/openjfx-monocle-8u76-b04.jar,libs/testfx-core-4
.0.15-alpha.jar,libs/testfx-junit-4.0.15-alpha.jar,.,libs/org.hamcres
t.core_1.3.0.v201303031735.jar
Class-Path: libs/openjfx-monocle-8u76-b04.jar,libs/testfx-core-4
.0.15-alpha.jar,libs/testfx-junit-4.0.15-alpha.jar,.,libs/org.hamcres
t.core_1.3.0.v201303031735.jar
Bundle-ManifestVersion: 2
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Here is the ant-Target: 这是蚂蚁目标:
<path id="classpath.test">
<pathelement location="${test.lib}/testfxplugin.jar" />
<pathelement location="${test.lib}/junit-4.9.jar" />
</path>
<target name="test-compile">
<mkdir dir="${test.build}"/>
<javac srcdir="${test.src}" destdir="${test.build}" includeantruntime="false">
<classpath refid="classpath.test" />
</javac>
</target>
As mentioned by @greg-449, you will have to add all the required jars as part of classpath. 如@ greg-449所述,您将必须将所有必需的jar添加为类路径的一部分。 Something like this :
像这样的东西:
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
This is just an example to include multiple (wildcard entries) jars. 这只是包括多个(通配符条目)jar的示例。 You can read more about it at Path-like Structures
您可以在类似路径的结构中了解更多信息
This is basically a transitive dependency, ie your dependencies have their own dependencies. 这基本上是一个传递依赖,即您的依赖具有自己的依赖。 That is where Maven can be used, which automatically takes care of such dependencies.
那就是可以使用Maven的地方,它会自动处理此类依赖性。 More on it here : Maven Transitive Dependencies
此处更多信息: Maven传递依赖项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.