Compressing everything not just the source directory with Maven

665 views Asked by At

I am using maven to compress my javascript files using YUI compressor. I have the aggregation work ing and only combining what in want. However i need YUI to compress one folder in my web apps folder. I have specified the source folder but this seems to be ignored. Instead every .js file in src/main/webapps seems to be compressed. I need to leave existing files intact and only compress my files in the directory. Here is my code:

<plugin>
  <groupId>net.alchim31.maven</groupId>
  <artifactId>yuicompressor-maven-plugin</artifactId>
  <version>1.3.2</version>
  <configuration>
      <preProcessAggregates>true</preProcessAggregates>
      <aggregations>
          <aggregation>
              <insertNewLine>true</insertNewLine>
              <output>${project.basedir}/target/umadesktop/angular/app/single.js</output>
              <inputDir>${project.basedir}/src/main/webapp/angular/app</inputDir>
              <includes>
                  <include>**/*.js</include>
              </includes>
              <excludes>
                  <exclude>**/*abc.js</exclude>
                  <exclude>**/compressed.css</exclude>
              </excludes>
          </aggregation>
      </aggregations>
      <excludes>
          <exclude>**/scripts/**/*.js</exclude>
      </excludes>
      <jswarn>false</jswarn>
      <nosuffix>false</nosuffix>
      <sourceDirectory>${project.basedir}/src/main/webapp/angular/app</sourceDirectory>
      <outputDirectory>${project.basedir}/target/umadesktop/angular/app/</outputDirectory>
  </configuration>
  <executions>
      <execution>
          <id>compress_js_css</id>
          <phase>process-resources</phase>
          <goals>
              <goal>compress</goal>
          </goals>
      </execution>
  </executions>
</plugin>
1

There are 1 answers

0
Samuel Santos On

You should take a look to Minify Maven Plugin which sounds just like the thing you need.
Please let me know if you need any help configuring it.