Reviewers: jbrosenberg, tobyr,
Description:
The logic to avoid rewriting compilation units into archived units
failed in some build environments where the output of the CompileModule
tool does not end up on the classpath. Each resulting .gwtar file
contained all compilation units, regardless of whether a nested .gwtar
file already contained the units.
Please review this at http://gwt-code-reviews.appspot.com/1518803/
Affected files:
M dev/core/src/com/google/gwt/dev/CompileModule.java
M dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
M dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
Index: dev/core/src/com/google/gwt/dev/CompileModule.java
===================================================================
--- dev/core/src/com/google/gwt/dev/CompileModule.java (revision 10516)
+++ dev/core/src/com/google/gwt/dev/CompileModule.java (working copy)
@@ -34,6 +34,7 @@
import com.google.gwt.dev.util.arg.OptionStrict;
import com.google.gwt.dev.util.log.speedtracer.CompilerEventType;
import com.google.gwt.dev.util.log.speedtracer.SpeedTracerLogger;
+import com.google.gwt.thirdparty.guava.common.collect.Sets;
import java.io.File;
import java.io.IOException;
@@ -191,7 +192,10 @@
// same archive twice. Key is archive URL string. Maps to the set of
unit resource paths
// for the archive.
Map<String, Set<String>> unitsInArchives = new HashMap<String,
Set<String>>();
-
+ // Modules archived in this session. They may not have been written
to the classpath,
+ // but assume that we don't want to redundantly archive compilation
units into
+ // modules compiled in the same session.
+ Map<String, Set<String>> compiledModules = new HashMap<String,
Set<String>>();
File outputDir = options.getOutDir();
if (!outputDir.isDirectory() && !outputDir.mkdirs()) {
logger.log(Type.ERROR, "Error creating directories for ouptut: "
@@ -225,6 +229,15 @@
}
}
+ // Don't re-archive previously compiled units from this session.
+ for (String compiledModuleName : compiledModules.keySet()) {
+ if (module.isInherited(compiledModuleName)) {
+
currentModuleArchivedUnits.addAll(compiledModules.get(compiledModuleName));
+ }
+ }
+
+ // Don't re-archive units that are already archived in another
archive
+ // on the classpath.
for (URL archiveURL : archiveURLs) {
String archiveURLString = archiveURL.toString();
Set<String> unitPaths = unitsInArchives.get(archiveURLString);
@@ -277,12 +290,15 @@
return false;
}
+ Set<String> compiledUnits = Sets.newHashSet();
CompilationUnitArchive outputArchive = new
CompilationUnitArchive(moduleToCompile);
for (CompilationUnit unit : compilationState.getCompilationUnits()) {
if (!currentModuleArchivedUnits.contains(unit.getResourcePath())) {
outputArchive.addUnit(unit);
- }
- }
+ compiledUnits.add(unit.getResourcePath());
+ }
+ }
+ compiledModules.put(moduleToCompile, compiledUnits);
String slashedModuleName =
module.getName().replace('.', '/') +
ModuleDefLoader.COMPILATION_UNIT_ARCHIVE_SUFFIX;
Index: dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java
===================================================================
--- dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java (revision 10516)
+++ dev/core/src/com/google/gwt/dev/cfg/ModuleDef.java (working copy)
@@ -113,6 +113,8 @@
private final Set<File> gwtXmlFiles = new HashSet<File>();
+ private final Set<String> inheritedModules = new HashSet<String>();
+
/**
* All resources found on the public path, specified by <public>
directives in
* modules (or the implicit ./public directory). Marked 'lazy' because
it does not
@@ -133,7 +135,7 @@
private final Map<String, Class<? extends Linker>> linkerTypesByName =
new LinkedHashMap<String, Class<? extends Linker>>();
-
+
private final long moduleDefCreationTime = System.currentTimeMillis();
private final String name;
@@ -197,13 +199,13 @@
publicPrefixSet.add(new PathPrefix(publicPackage,
defaultFilters.customResourceFilter(
includeList, excludeList, skipList, defaultExcludes,
caseSensitive), true, excludeList));
}
-
+
public void addSourcePackage(String sourcePackage, String[] includeList,
String[] excludeList,
String[] skipList, boolean defaultExcludes, boolean caseSensitive) {
addSourcePackageImpl(sourcePackage, includeList, excludeList,
skipList, defaultExcludes,
caseSensitive, false);
}
-
+
public void addSourcePackageImpl(String sourcePackage, String[]
includeList,
String[] excludeList, String[] skipList, boolean defaultExcludes,
boolean caseSensitive,
boolean isSuperSource) {
@@ -443,6 +445,10 @@
return lastModified() > moduleDefCreationTime;
}
+ public boolean isInherited(String moduleName) {
+ return inheritedModules.contains(moduleName);
+ }
+
public long lastModified() {
long lastModified = 0;
for (File xmlFile : gwtXmlFiles) {
@@ -486,6 +492,10 @@
void addCompilationUnitArchiveURL(URL url) {
archiveURLs.add(url);
+ }
+
+ void addInteritedModule(String moduleName) {
+ inheritedModules.add(moduleName);
}
/**
Index: dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java
===================================================================
--- dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java (revision
10516)
+++ dev/core/src/com/google/gwt/dev/cfg/ModuleDefLoader.java (working copy)
@@ -32,9 +32,7 @@
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
/**
* The top-level API for loading module XML.
@@ -180,8 +178,6 @@
return moduleDef;
}
- private final Set<String> alreadyLoadedModules = new HashSet<String>();
-
private final ClassLoader classLoader;
private final LoadStrategy strategy;
@@ -230,20 +226,20 @@
void nestedLoad(TreeLogger parentLogger, String moduleName, ModuleDef
moduleDef)
throws UnableToCompleteException {
- if (alreadyLoadedModules.contains(moduleName)) {
+ if (moduleDef.isInherited(moduleName)) {
// No need to parse module again.
return;
}
-
+
TreeLogger logger = parentLogger.branch(TreeLogger.DEBUG, "Loading
inherited module '"
+ moduleName + "'", null);
- alreadyLoadedModules.add(moduleName);
if (!ModuleDef.isValidModuleName(moduleName)) {
logger.log(TreeLogger.ERROR, "Invalid module name: '" + moduleName
+ "'",
null);
throw new UnableToCompleteException();
}
+ moduleDef.addInteritedModule(moduleName);
// Find the specified module using the classpath.
//
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors