0

Hi I am using ant war plugin and trying to exclude a folder from teh war. however this is not being excluded.

Here is the structure

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

My build.xml for target = production looks like this, i am try to exclude teh common folder. However I see that it is not excluding it at all

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

in my pom.xml i have referenced the folder as

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

How can i exclude these js files in my war file? for production mode . I plan to exclude these js files and include a minified js file. any pointers

Tunaki
  • 132,869
  • 46
  • 340
  • 423
looneytunes
  • 741
  • 4
  • 16
  • 35
  • 1
    Is there any particular reason you're not using the `maven-war-plugin`? It would be a lot easier. – Tunaki Jan 31 '16 at 00:30

2 Answers2

2

Include the <exclude> in the <fileset>:

<fileset dir="${webappsrc}">
    <exclude name="common/api/*.js" />
</fileset>
J. Titus
  • 9,535
  • 1
  • 32
  • 45
0

The exclude you add directly inside the task not nested into one of the filesets applies to the implicit fileset the task forms when you use the basedir attribute. Without any basedir it doesn't do anything. This may not be mentioned inside the war doc, but inside the linked jar page.

You have to place the exclude inside the fileset that pulls in the files you don't want. lib and classes are filesets with different names (they really only are zipfilesets with hard-coded prefix attributes).

Stefan Bodewig
  • 3,260
  • 15
  • 22