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

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