3

我正在尝试使用谷歌闭包编译器缩小我的 JS 文件

我使用了以下简单的 POM 文件

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

我在源代码中放置了三个 js 文件,当我检查输出文件夹时,我得到没有任何内容的空文件

如果在命令提示符下运行,相同的命令可以正常工作。知道为什么我得到空文件吗?

4

0 回答 0