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', 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( java_library(
name = 'annotations', name = 'annotations',
srcs = ANNOTATIONS, srcs = ANNOTATIONS,
@@ -24,13 +14,18 @@ java_library(
gwt_module( gwt_module(
name = 'client', name = 'client',
srcs = glob([SRC + 'common/**/*.java'], excludes = EXCLUDES), srcs = glob([SRC + 'common/**/*.java']),
gwt_xml = SRC + 'Common.gwt.xml', gwt_xml = SRC + 'Common.gwt.xml',
exported_deps = [ exported_deps = [
'//gerrit-extension-api:client', '//gerrit-extension-api:api',
'//gerrit-prettify:client', '//gerrit-prettify:client',
'//lib:guava',
'//lib:gwtorm_client', '//lib:gwtorm_client',
'//lib/joda:joda-time',
'//lib/log:api',
'@jgit//org.eclipse.jgit:jgit',
], ],
provided_deps = ['//lib:servlet-api-3_1'],
visibility = ['PUBLIC'], visibility = ['PUBLIC'],
) )
@@ -43,9 +38,9 @@ java_library(
'//gerrit-patch-jgit:server', '//gerrit-patch-jgit:server',
'//gerrit-prettify:server', '//gerrit-prettify:server',
'//gerrit-reviewdb:server', '//gerrit-reviewdb:server',
'//lib:guava',
'//lib:gwtjsonrpc', '//lib:gwtjsonrpc',
'//lib:gwtorm', '//lib:gwtorm',
'//lib:guava',
'//lib/joda:joda-time', '//lib/joda:joda-time',
'//lib/log:api', '//lib/log:api',
'@jgit//org.eclipse.jgit:jgit', '@jgit//org.eclipse.jgit:jgit',

View File

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

View File

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

View File

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

View File

@@ -16,6 +16,7 @@ package com.google.gerrit.common;
import static java.nio.charset.StandardCharsets.UTF_8; import static java.nio.charset.StandardCharsets.UTF_8;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.gerrit.extensions.restapi.RawInput; import com.google.gerrit.extensions.restapi.RawInput;
@@ -25,6 +26,7 @@ import java.io.InputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@GwtIncompatible("Unemulated classes in java.io and javax.servlet")
public class RawInputUtil { public class RawInputUtil {
public static RawInput create(String content) { public static RawInput create(String content) {
return create(content.getBytes(UTF_8)); return create(content.getBytes(UTF_8));
@@ -52,7 +54,7 @@ public class RawInputUtil {
} }
public static RawInput create(final byte[] bytes) { 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) { 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 static com.google.gerrit.common.FileUtil.lastModified;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.collect.ComparisonChain; import com.google.common.collect.ComparisonChain;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering; import com.google.common.collect.Ordering;
@@ -30,6 +31,7 @@ import java.nio.file.NoSuchFileException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.List; import java.util.List;
@GwtIncompatible("Unemulated classes in java.nio and Guava")
public final class SiteLibraryLoaderUtil { public final class SiteLibraryLoaderUtil {
private static final Logger log = private static final Logger log =
LoggerFactory.getLogger(SiteLibraryLoaderUtil.class); LoggerFactory.getLogger(SiteLibraryLoaderUtil.class);

View File

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

View File

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

View File

@@ -16,7 +16,7 @@
</listAttribute> </listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/> <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.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.PROJECT_ATTR" value="gerrit"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M&#10;-XX:MaxPermSize=256M&#10;-Dgerrit.disable-gwtui-recompile=true"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx1024M&#10;-XX:MaxPermSize=256M&#10;-Dgerrit.disable-gwtui-recompile=true"/>
</launchConfiguration> </launchConfiguration>