【问题标题】:ant war plugin trying to exclude folders蚂蚁战插件试图排除文件夹
【发布时间】:2016-01-30 23:32:46
【问题描述】:

您好,我正在使用 ant war 插件并试图从 teh 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 文件。任何指针

【问题讨论】:

  • 您没有使用maven-war-plugin 有什么特别的原因吗?会容易很多。

标签: maven ant war maven-antrun-plugin


【解决方案1】:

&lt;fileset&gt; 中包含&lt;exclude&gt;

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

【讨论】:

    【解决方案2】:

    当您使用basedir 属性时,您直接在未嵌套到filesets 之一的任务中添加的exclude 适用于隐含的fileset 任务表单。没有任何basedir 它什么也做不了。这可能不会在war 文档中提及,而是在链接的jar 页面中提及。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-13
      • 2011-08-18
      • 1970-01-01
      相关资源
      最近更新 更多