在哪里使用标志来通知 GWT 以避免混淆 Javascript?
Where to use the flag to inform GWT to avoid obfuscating Javascript?
我需要在不混淆的情况下编译 GWT 应用程序 Javascript,但我以前从未使用过 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>
或使用配置文件从命令行进行设置。
我需要在不混淆的情况下编译 GWT 应用程序 Javascript,但我以前从未使用过 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>
或使用配置文件从命令行进行设置。