Use @GwtIncompatible to exclude files incompatible with GWT

Currently, GWT's Super Dev Mode shows "Ignored 7 units with
compilation errors in first pass". This is because the 6 files listed
in this change refer to classes / methods that are not emulated in GWT
and should be excluded from the compilation. The production build
doesn't suffer from this problem because we exclude them in
gerrit-common/BUCK.

Instead of listing them in BUCK, rely on Guava's handy
@GwtIncompatible annotation. This tells the GWT compiler to ignore the
file entirely, both in Super Dev Mode and production build.

Add "-strict" to the launch configurations of Super Dev Mode so that
developers can catch errors earlier.

Change-Id: I6e2d6be303fa888a9b4776aaae1148d4fd9a211c
This commit is contained in:
Michael Zhou 2016-03-29 00:57:29 -04:00
parent 309f8835f3
commit 42c22a8fc8
9 changed files with 27 additions and 15 deletions

View File

@ -6,16 +6,6 @@ ANNOTATIONS = [
SRC + 'common/auth/SignInRequired.java',
]
EXCLUDES = [
SRC + 'common/SiteLibraryLoaderUtil.java',
SRC + 'common/PluginData.java',
SRC + 'common/FileUtil.java',
SRC + 'common/IoUtil.java',
SRC + 'common/RawInputUtil.java',
SRC + 'common/TimeUtil.java',
SRC + 'common/data/SubscribeSection.java',
]
java_library(
name = 'annotations',
srcs = ANNOTATIONS,
@ -24,13 +14,18 @@ java_library(
gwt_module(
name = 'client',
srcs = glob([SRC + 'common/**/*.java'], excludes = EXCLUDES),
srcs = glob([SRC + 'common/**/*.java']),
gwt_xml = SRC + 'Common.gwt.xml',
exported_deps = [
'//gerrit-extension-api:client',
'//gerrit-extension-api:api',
'//gerrit-prettify:client',
'//lib:guava',
'//lib:gwtorm_client',
'//lib/joda:joda-time',
'//lib/log:api',
'@jgit//org.eclipse.jgit:jgit',
],
provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'],
)
@ -43,9 +38,9 @@ java_library(
'//gerrit-patch-jgit:server',
'//gerrit-prettify:server',
'//gerrit-reviewdb:server',
'//lib:guava',
'//lib:gwtjsonrpc',
'//lib:gwtorm',
'//lib:guava',
'//lib/joda:joda-time',
'//lib/log:api',
'@jgit//org.eclipse.jgit:jgit',

View File

@ -14,6 +14,8 @@
package com.google.gerrit.common;
import com.google.common.annotations.GwtIncompatible;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.IO;
@ -25,6 +27,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
@GwtIncompatible("Unemulated classes in java.io, java.nio and JGit")
public class FileUtil {
public static boolean modified(FileBasedConfig cfg) throws IOException {
byte[] curVers;

View File

@ -14,6 +14,7 @@
package com.google.gerrit.common;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.Sets;
import java.io.IOException;
@ -29,6 +30,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
@GwtIncompatible("Unemulated methods in Class and OutputStream")
public final class IoUtil {
public static void copyWithThread(final InputStream src,
final OutputStream dst) {

View File

@ -14,9 +14,12 @@
package com.google.gerrit.common;
import com.google.common.annotations.GwtIncompatible;
import java.nio.file.Path;
import java.util.Objects;
@GwtIncompatible("Unemulated java.nio.file.Path")
public class PluginData {
public final String name;
public final String version;

View File

@ -16,6 +16,7 @@ package com.google.gerrit.common;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions;
import com.google.gerrit.extensions.restapi.RawInput;
@ -25,6 +26,7 @@ import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
@GwtIncompatible("Unemulated classes in java.io and javax.servlet")
public class RawInputUtil {
public static RawInput create(String content) {
return create(content.getBytes(UTF_8));
@ -52,7 +54,7 @@ public class RawInputUtil {
}
public static RawInput create(final byte[] bytes) {
return create (bytes, "application/octet-stream");
return create(bytes, "application/octet-stream");
}
public static RawInput create(final HttpServletRequest req) {

View File

@ -16,6 +16,7 @@ package com.google.gerrit.common;
import static com.google.gerrit.common.FileUtil.lastModified;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
@ -30,6 +31,7 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.List;
@GwtIncompatible("Unemulated classes in java.nio and Guava")
public final class SiteLibraryLoaderUtil {
private static final Logger log =
LoggerFactory.getLogger(SiteLibraryLoaderUtil.class);

View File

@ -14,11 +14,14 @@
package com.google.gerrit.common;
import com.google.common.annotations.GwtIncompatible;
import org.joda.time.DateTimeUtils;
import java.sql.Timestamp;
/** Static utility methods for dealing with dates and times. */
@GwtIncompatible("Unemulated org.joda.time.DateTimeUtils")
public class TimeUtil {
public static long nowMs() {
return DateTimeUtils.currentTimeMillis();

View File

@ -14,6 +14,7 @@
package com.google.gerrit.common.data;
import com.google.common.annotations.GwtIncompatible;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.client.Project;
@ -25,6 +26,7 @@ import java.util.Collections;
import java.util.List;
/** Portion of a {@link Project} describing superproject subscription rules. */
@GwtIncompatible("Unemulated org.eclipse.jgit.transport.RefSpec")
public class SubscribeSection {
private final List<RefSpec> refSpecs;

View File

@ -16,7 +16,7 @@
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gerrit.gwtdebug.GerritGwtDebugLauncher"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-noprecompile -src ${resource_loc:/gerrit} -workDir ${resource_loc:/gerrit}/buck-out/gen/gerrit-gwtui com.google.gerrit.GerritGwtUI -src ${resource_loc:/gerrit}/gerrit-plugin-gwtui/src/main/java -- --console-log --show-stack-trace -d ${resource_loc:/gerrit}/../gerrit_testsite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-strict -noprecompile -src ${resource_loc:/gerrit} -workDir ${resource_loc:/gerrit}/buck-out/gen/gerrit-gwtui com.google.gerrit.GerritGwtUI -src ${resource_loc:/gerrit}/gerrit-plugin-gwtui/src/main/java -- --console-log --show-stack-trace -d ${resource_loc:/gerrit}/../gerrit_testsite"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M&#10;-XX:MaxPermSize=256M&#10;-Dgerrit.disable-gwtui-recompile=true"/>
</launchConfiguration>