簡體   English   中英

在哪里使用標志通知GWT避免混淆Javascript?

[英]Where to use the flag to inform GWT to avoid obfuscating Javascript?

我需要在不混淆Javascript的情況下編譯GWT應用程序,但是我以前從未使用過GWT。

經過一些研究,我發現了有關-style標志( http://www.gwtproject.org/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideCompilerOptions )的信息,以通知GWT避免混淆Javascript。

我們的項目中也有一個pom.xml文件。 讓我們假設它看起來像這樣:

<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.example</groupId>
  <artifactId>test</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>war</packaging>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.gwt</groupId>
        <artifactId>gwt</artifactId>
        <version>2.7.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-user</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-dev</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-codeserver</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.gwt</groupId>
      <artifactId>gwt-servlet</artifactId>
      <scope>runtime</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.7.0</version>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <module>com.example.test.Test</module>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

這是我應該放置-style標志的地方嗎? 如果是這樣,我應該將它放在XML樹的確切位置?

您應該將標志放在gwt編譯插件配置中

 <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>gwt-maven-plugin</artifactId>
        <version>2.7.0</version>
        <executions>
          <execution>
              <configuration>
                  <style>${gwtcompiler.style}</style>
              </configuration>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <module>com.example.test.Test</module>
        </configuration>
      </plugin>
    </plugins>
  </build>

然后在pom中更早地定義變量,只需取消注釋要使用的行即可。

<properties>
    <gwtcompiler.style>PRETTY</gwtcompiler.style>
    <!-- <gwtcompiler.style>OBFUSCATED</gwtcompiler.style> -->
</properties>

或使用配置文件從命令行進行設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM