Search code examples
mavenantwarmaven-antrun-plugin

ant war plugin trying to exclude folders


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


Solution

  • Include the <exclude> in the <fileset>:

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