为什么Jars不能从Enunciate的部署中排除?

时间:2020-03-06 15:01:56  来源:igfitidea点击:

我正在使用Enunciate来构建原型REST api,并且需要包含一个包含自定义代码的jar作为库。

我的蚂蚁脚本看起来像这样:

<!--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文件中排除。有必要编译带注释的带注释的类,以便jar显然在编译时位于类路径上,但带注释的未能将其包含在分发中。我还注意到,WAR文件中未包含需要阐明的几个jar。

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

解决方案

我从没用过模棱两可的方法,但是作为一个快速技巧,我们可以将罐子添加到战争中:

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

注意:我们可能想将罐子添加到WEB-INF / lib目录,而不是根目录。

我猜这说明最小值会干扰我们自己的构建过程,因为我们最清楚在jar文件中放入什么。

事实证明,我们尝试包含的一个jar包含一个清单,该清单的清单是Enunciate所依赖的jar的清单文件(freemarker)。 Enunciate自动排除了freemarker,乍一看似乎也自动排除了所有依赖freemarker的东西。如果我们从代码清单文件中的依赖jar列表中删除freemarker,它就可以正常工作。

然而;我已经与Enunciate的主要开发人员(Ryan Heaten)进行了交谈,他向我保证这不是正在发生的事情。以下包括他的回应:

Really?!
  
  Wow.  Interesting.  I can't explain
  it; Enunciate doesn't look at what's
  in the Manifest in order to determine
  what to include in the war, so I'm
  kind of stumped here.  It could also
  be some weird Ant behavior (not
  including that jar in the
  "en.classpath" reference for some
  reason).
  
  ~Ryan