3

I am trying to minify my JS file using google closure compiler

I used the following simple POM file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.xxx</groupId>
<artifactId>closurecompiler</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>closurecompiler Maven Webapp</name>
<url>http://maven.apache.org</url>

<build>
    <finalName>closurecompilertest</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId> 
            <executions>
                <execution>
                    <phase>validate</phase>
                    <goals>
                        <goal>copy</goal> 
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.google.javascript</groupId> 
                                <artifactId>closure-compiler</artifactId>
                                <version>r1810</version>
                                <type>jar</type> 
                                <overWrite>true</overWrite>
                                <outputDirectory>target/builddependency</outputDirectory> 
                                <destFileName>closure-compiler.jar</destFileName>
                            </artifactItem>
                            <artifactItem> 
                                <groupId>args4j</groupId>
                                <artifactId>args4j</artifactId>
                                <version>2.0.12</version> 
                                <type>jar</type>
                                <overWrite>true</overWrite>
                                <outputDirectory>target/builddependency</outputDirectory> 
                                <destFileName>args4j.jar</destFileName>
                            </artifactItem>
                            <artifactItem>
                                <groupId>com.google.guava</groupId> 
                                <artifactId>guava</artifactId>
                                <version>r07</version>
                                <type>jar</type>
                                <overWrite>true</overWrite> 
                                <outputDirectory>target/builddependency</outputDirectory>
                                <destFileName>guava.jar</destFileName> 
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions> 
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-antrun-plugin</artifactId>
            <version>1.7</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <configuration>
                        <target>
                            <echo
                                message="Minifying JS files. This takes a few minutes, please be patient" />
                            <apply executable="java" failOnError="true">
                                <arg line="-cp target/builddependency/args4j.jar;target/builddependency/guava.jar;target/builddependency/closure-compiler.jar com.google.javascript.jscomp.CommandLineRunner --compilation_level WHITESPACE_ONLY --charset UTF-8 --js " />
                                <fileset dir="src/main/webapp/js/" includes="*.js" />
                                <redirector>
                                    <outputmapper id="out" type="glob" from="*.js" to="target/cc/*.js" />
                                </redirector>
                            </apply>
                        </target>
                    </configuration>
                    <goals>
                        <goal>run</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

i placed three js files in the source and when I check the output folder, i am getting empty files without any content

The same command works fine if run in command prompt. any idea why i am getting empty file?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.