簡體   English   中英

如何在Ant構建任務中將捆綁的jar添加到類路徑中?

[英]How can I add bundled jars to my classpath in an Ant build task?

我在Eclipse中有一個插件項目。 我想用ant編譯我的代碼。 現在,我需要在我的類路徑中添加一個jar,它的類路徑中也有幾個jar。 有幾個導出的軟件包,它們是編譯代碼所必需的。 當我將此jar添加到我的依賴項並使用Eclipse運行代碼時,一切正常。 但是螞蟻不知何故找不到所需的進口。 捆綁包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

這是螞蟻目標:

<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>

如@ greg-449所述,您將必須將所有必需的jar添加為類路徑的一部分。 像這樣的東西:

<classpath>
  <fileset dir="lib">
    <include name="**/*.jar"/>
  </fileset>
</classpath>

這只是包括多個(通配符條目)jar的示例。 您可以在類似路徑的結構中了解更多信息

這基本上是一個傳遞依賴,即您的依賴具有自己的依賴。 那就是可以使用Maven的地方,它會自動處理此類依賴性。 此處更多信息: Maven傳遞依賴項

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM