Author: [EMAIL PROTECTED]
Date: Thu Dec 4 10:44:43 2008
New Revision: 4250
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/EmittedArtifact.java
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/SyntheticArtifact.java
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardGeneratedResource.java
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardPublicResource.java
Log:
Fix for issue #2280; adds EmittedArtifact.getLastModified() which is used
to set the mtime on files written to disk by the compiler.
The default implementation in the EmittedArtifact base class is concrete to
avoid breaking changes and always returns the current time, which is
consistent with the previous behavior.
Patch by: bobv
Review by: me
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/EmittedArtifact.java
==============================================================================
---
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/EmittedArtifact.java
(original)
+++
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/EmittedArtifact.java
Thu Dec 4 10:44:43 2008
@@ -53,6 +53,20 @@
throws UnableToCompleteException;
/**
+ * Returns the time, measured in milliseconds from the epoch, at which
the
+ * Artifact was last modified. This will be used to set the last-modified
+ * timestamp on the files written to disk.
+ * <p>
+ * The default implementation always returns the current time. Subclasses
+ * should override this method to provide a type-appropriate value.
+ *
+ * @return the time at which the Artifact was last modified
+ */
+ public long getLastModified() {
+ return System.currentTimeMillis();
+ }
+
+ /**
* Returns the partial path within the output directory of the
* EmittedArtifact.
*/
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/SyntheticArtifact.java
==============================================================================
---
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/SyntheticArtifact.java
(original)
+++
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/SyntheticArtifact.java
Thu Dec 4 10:44:43 2008
@@ -27,6 +27,7 @@
*/
public class SyntheticArtifact extends EmittedArtifact {
private final byte[] data;
+ private final long lastModified = System.currentTimeMillis();
SyntheticArtifact(Class<? extends Linker> linkerType, String partialPath,
byte[] data) {
@@ -40,4 +41,9 @@
throws UnableToCompleteException {
return new ByteArrayInputStream(data);
}
-}
\ No newline at end of file
+
+ @Override
+ public long getLastModified() {
+ return lastModified;
+ }
+}
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardGeneratedResource.java
==============================================================================
---
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardGeneratedResource.java
(original)
+++
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardGeneratedResource.java
Thu Dec 4 10:44:43 2008
@@ -20,30 +20,36 @@
import com.google.gwt.core.ext.UnableToCompleteException;
import com.google.gwt.core.ext.linker.GeneratedResource;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URL;
/**
* The standard implementation of [EMAIL PROTECTED] GeneratedResource}.
*/
public class StandardGeneratedResource extends GeneratedResource {
- private final URL url;
+ private final File file;
public StandardGeneratedResource(Class<? extends Generator>
generatorType,
- String partialPath, URL url) {
+ String partialPath, File file) {
super(StandardLinkerContext.class, generatorType, partialPath);
- this.url = url;
+ this.file = file;
}
@Override
public InputStream getContents(TreeLogger logger)
throws UnableToCompleteException {
try {
- return url.openStream();
+ return new FileInputStream(file);
} catch (IOException e) {
logger.log(TreeLogger.ERROR, "Unable to open file", e);
throw new UnableToCompleteException();
}
+ }
+
+ @Override
+ public long getLastModified() {
+ return file.lastModified();
}
}
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
==============================================================================
---
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
(original)
+++
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardLinkerContext.java
Thu Dec 4 10:44:43 2008
@@ -446,6 +446,7 @@
// assert !outFile.exists() : "Attempted to overwrite " +
// outFile.getPath();
Util.copy(artifactLogger, artifact.getContents(artifactLogger),
outFile);
+ outFile.setLastModified(artifact.getLastModified());
}
}
Modified:
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardPublicResource.java
==============================================================================
---
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardPublicResource.java
(original)
+++
releases/1.6/dev/core/src/com/google/gwt/core/ext/linker/impl/StandardPublicResource.java
Thu Dec 4 10:44:43 2008
@@ -37,10 +37,13 @@
*/
private static final class SerializedPublicResource extends
PublicResource {
private final byte[] data;
+ private final long lastModified;
- protected SerializedPublicResource(String partialPath, byte[] data) {
+ protected SerializedPublicResource(String partialPath, byte[] data,
+ long lastModified) {
super(StandardLinkerContext.class, partialPath);
this.data = data;
+ this.lastModified = lastModified;
}
@Override
@@ -48,6 +51,11 @@
throws UnableToCompleteException {
return new ByteArrayInputStream(data);
}
+
+ @Override
+ public long getLastModified() {
+ return lastModified;
+ }
}
private final Resource resource;
@@ -63,6 +71,11 @@
return resource.openContents();
}
+ @Override
+ public long getLastModified() {
+ return resource.getLastModified();
+ }
+
private Object writeReplace() {
if (resource instanceof Serializable) {
return this;
@@ -71,7 +84,8 @@
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Util.copy(resource.openContents(), baos);
- return new SerializedPublicResource(getPartialPath(),
baos.toByteArray());
+ return new SerializedPublicResource(getPartialPath(),
baos.toByteArray(),
+ getLastModified());
} catch (IOException e) {
throw new RuntimeException(e);
}
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---