Skip to content

Commit

Permalink
[MSHADE-420] fix time when read from extra field
Browse files Browse the repository at this point in the history
  • Loading branch information
hboutemy committed Jan 30, 2024
1 parent 0fe7700 commit eee3cb0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/org/apache/maven/plugins/shade/DefaultShader.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.TimeZone;
import java.util.concurrent.Callable;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
Expand Down Expand Up @@ -89,6 +90,15 @@ public DefaultShader(final Logger logger) {
this.logger = Objects.requireNonNull(logger);
}

// workaround for MSHADE-420
private long getTime(ZipEntry entry) {
if (entry.getExtra() == null) {
return entry.getTime();
}
// TODO check more precisely that extra fields define mtime...
return entry.getTime() - TimeZone.getDefault().getRawOffset();
}

public void shade(ShadeRequest shadeRequest) throws IOException, MojoExecutionException {
Set<String> resources = new HashSet<>();

Expand Down Expand Up @@ -332,7 +342,7 @@ public InputStream call() throws Exception {
}
},
name,
entry.getTime(),
getTime(entry),
entry.getMethod());
} catch (Exception e) {
throw new IOException(String.format("Problem shading JAR %s entry %s: %s", jar, name, e), e);
Expand Down Expand Up @@ -423,7 +433,7 @@ private void goThroughAllJarEntriesForManifestTransformer(
resources.add(resource);
try (InputStream inputStream = jarFile.getInputStream(entry)) {
manifestTransformer.processResource(
resource, inputStream, shadeRequest.getRelocators(), entry.getTime());
resource, inputStream, shadeRequest.getRelocators(), getTime(entry));
}
break;
}
Expand Down

0 comments on commit eee3cb0

Please sign in to comment.