Question

I am trying to minify some JavaScript and getting it to the right location within the Maven build process. We're using the 1.5 JDK, which limits some of the options available to me to accomplish this task. It appears that I have set up the plugins in the right order, but I believe that during the WAR assembly process, the work I performed during the prepare-package goal is being overwritten. Below is the build portion of the POM and the partial results (abbreviated for clarity). Any assistance offered in welcomed. Thanks!

<build>

    <plugins>

        <plugin>
            <groupId>com.samaxes.maven</groupId>
            <artifactId>minify-maven-plugin</artifactId>
            <version>1.5.2</version>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>minify</goal>
                    </goals>
                    <configuration>
                        <verbose>true</verbose>
                        <jsSourceDir>broker/app</jsSourceDir>
                        <jsSourceFiles>
                            <jsSourceFile>controller/Navigation.js</jsSourceFile>
                            <jsSourceFile>view/MainView.js</jsSourceFile>
                        </jsSourceFiles>
                        <jsFinalFile>minified.js</jsFinalFile>
                        <webappTargetDir>${project.basedir}/src/main/webapp/broker/app/controller</webappTargetDir>
                    </configuration>
                </execution>
            </executions>

        </plugin>

        <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-resources</phase>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <configuration>
                        <tasks>
                            <echo message="processing files..."/>
                            <copy 
                                file="${project.basedir}/src/main/webapp/broker/app/controller/js/minified.min.js" 
                                tofile="target/${project.build.finalName}/broker/app/controller/Navigation.js"
                                overwrite="true"
                                verbose="true"/>
                        </tasks>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>

            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <configuration>
                <packagingExcludes>broker/app/controller/Navigation.js, broker/app/view/MainView.js</packagingExcludes>
                <archive>
                    <manifestEntries>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Implementation-Title>${project.name}</Implementation-Title>
                    </manifestEntries>
                </archive>
            </configuration>

        </plugin>

    </plugins>

</build>

output from process

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building VFIS AS RQ WAR Module 1.0.0.37-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) @ rq-vfis-as-war ---
[INFO] Deleting C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target
[INFO] 
[INFO] --- minify-maven-plugin:1.5.2:minify (default) @ rq-vfis-as-war ---
[INFO] Processing source file [Navigation.js].
[INFO] Processing source file [MainView.js].
[INFO] Creating merged file [minified.js].
[INFO] Creating minified file [minified.min.js].
<snipped output>
[INFO] 
[INFO] --- maven-antrun-plugin:1.3:run (default) @ rq-vfis-as-war ---
[INFO] Executing tasks
     [echo] processing files...
     [copy] Copying 1 file to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT\broker\app\controller
     [copy] Copying C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\src\main\webapp\broker\app\controller\js\minified.min.js to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT\broker\app\controller\Navigation.js
[INFO] Executed tasks
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) @ rq-vfis-as-war ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 10 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ rq-vfis-as-war ---
[INFO] Compiling 35 source files to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.4.3:testResources (default-testResources) @ rq-vfis-as-war ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ rq-vfis-as-war ---
[INFO] Compiling 10 source files to C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.7.2:test (default-test) @ rq-vfis-as-war ---
[INFO] Surefire report directory: C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
<snipped test results>
[INFO] 
[INFO] --- maven-war-plugin:2.2:war (default-war) @ rq-vfis-as-war ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rq-vfis-as-war] in [C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\src\main\webapp]
[INFO] Webapp assembled in [7816 msecs]
[INFO] Building war: C:\Users\jwillmore\Workspaces\MyEclipse Bling Edition 10\VFIS AS RQ POM Module\rq-vfis-as-war\target\rq-vfis-as-war-1.0.0.37-SNAPSHOT.war
[INFO] WEB-INF\web.xml already added, skipping
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 19.266s
[INFO] Finished at: Wed Apr 30 09:38:29 EDT 2014
[INFO] Final Memory: 41M/111M
[INFO] ------------------------------------------------------------------------
Was it helpful?

Solution

Use <warSourceExcludes>broker/app/controller/Navigation.js,broker/app/view/MainView.js</warSourceExcludes> instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top