我正在使用 Enunciate 来构建原型REST API,并且需要包含一个包含自定义代码的jar图书馆。

我的Ant脚本看起来像这样:

<!--include all jars-->
<path id="en.classpath">
    <fileset dir="${lib}">
        <include name="**/*.jar" />
    </fileset>
</path>

<!--define the task-->
<taskdef name="enunciate" classname="org.codehaus.enunciate.main.EnunciateTask">
    <classpath refid="en.classpath" />
</taskdef>

<mkdir dir="${dist}" />

<enunciate dir="${src}" configFile="${basedir}/enunciate.xml">
    <include name="**/*.java" />
    <classpath refid="en.classpath"/>
    <export artifactId="spring.war.file" destination="${dist}/${war.name}" />
</enunciate>

问题是我的自定义jar被从WAR文件中排除。有必要编译enunciate带注释的类,因此jar在编译时显然在类路径上,但是enunciate未能将它包含在发行版中。我还注意到,enunciate所需的几个jar文件没有包含在WAR文件中。

他们为什么被排除在外,我该如何解决?

有帮助吗?

解决方案 2

事实证明,我们试图包含的其中一个罐子里面有一个依赖关系,它包含了Enunciate依赖的jar的Manifest文件(freemarker)。 Enunciate自动排除freemarker,乍一看似乎它会自动排除任何依赖于freemarker的内容。如果我们从代码清单文件中的依赖jar列表中删除freemarker,它就可以正常工作。

然而;我已经和Enunciate的主要开发者(Ryan Heaten)谈过了,他向我保证这不是正在发生的事情。包括他的回复如下:

  

真的吗?!

     

哇。有趣。我无法解释   它; Enunciate不看什么   在清单中以确定   什么要包括在战争中,所以我   有点难过。它也可以   是一些奇怪的Ant行为(不是   包括那个罐子里面   &QUOT; en.classpath&QUOT;参考一些   原因)。

     

〜瑞恩

其他提示

我从未使用过enunciate,但作为一个快速黑客,你可以将罐子添加到战争中:

<jar jarfile="${dist}/${war.name}" update="true">
   <fileset dir="${lib}">
        <include name="**/*.jar" />
    </fileset>
</jar>

注意:您可能希望将jar添加到 WEB-INF / lib 目录,而不是根目录。

我猜测发音会使mininum干扰你自己的构建过程,因为你最了解要放在jar文件中的内容。

在enunciate.xml中我告诉它不要复制任何libs本身:

<webapp doLibCopy="false">

然后在enunciate任务结束时的ant构建文件中我更新战争(你可以这样做来更新包含/排除的jar,无论你是否在上面的步骤中为你复制了罐子): / p>

<war destfile="build-output/{mywar}" update="true">
    <lib dir="WebContent/WEB-INF/lib">
        <include name="**/*.jar" />
    </lib>
    <lib dir="build-output">
        <include name="some_other.jar" />
    </lib>
</war>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top