ant war 插件试图排除文件夹

ant war plugin trying to exclude folders

您好,我正在使用 ant war 插件并试图从 war 中排除一个文件夹。然而,这并不被排除在外。

结构如下

   XYZ
      src
         main
             webapp
                   web-inf
                         web.xml
                   common
                         api
                            a.js
                            b.js

我的 build.xml for target = production 看起来像这样,我试图排除公用文件夹。但是我看到它根本不排除它

<target name="production" depends="moveresources"
        description="Building the Production Directory Content">
    <echo message="Creating -> ${workingDirectory}"/>
    <war destfile="${workingDirectory}/horizonadmin.war" webxml="${srcDirectory}/WEB-INF/web.xml">
        <fileset dir="${webappsrc}"/>
        <lib dir="${srcDirectory}/WEB-INF/lib"/>
        <classes dir="${srcDirectory}/WEB-INF/classes"/>
        <exclude name="common/api/*.js/>
    </war>
    <echo message="Done Creating -> ${workingDirectory}"/>
</target>

在我的 pom.xml 中,我将文件夹引用为

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>production</id>
      <phase>package</phase>
      <goals>
        <goal>run</goal>
      </goals>
      <configuration>
        <target>
          <property name="unpackfolder" value="${unpack.folder}"/>
          <property name="webappsrc" value="src/main/webapp"/>
          <property name="srcDirectory" value="${project.basedir}/target"/>
          <property name="workingDirectory" value="${PUBLISH_DIR}/production"/> 
          <ant antfile="${project.basedir}/build.xml" target="production"/>
        </target>
      </configuration>
    </execution>

如何在我的 war 文件中排除这些 js 文件?对于生产模式。我计划排除这些 js 文件并包含一个缩小的 js 文件。任何指针

<fileset> 中包含 <exclude>

<fileset dir="${webappsrc}">
    <exclude name="common/api/*.js" />
</fileset>

您在未嵌套到 fileset 之一的任务中直接添加的 exclude 适用于使用 basedir 时的隐式 fileset 任务形式属性。没有任何 basedir 它什么都不做。这可能不会在 war 文档中提及,但会在链接的 jar 页面中提及。

您必须将 exclude 放在 fileset 中,它会拉入您不需要的文件。 libclasses 是具有不同名称的 fileset(它们实际上只是具有硬编码 prefix 属性的 zipfileset)。