From 9705f5d07beedc746671c282aecf9a4ad17c0563 Mon Sep 17 00:00:00 2001 From: Sebastian Ratz Date: Tue, 11 Oct 2022 19:22:56 +0200 Subject: [PATCH] MvnProtocolHandlerService: Implement lastModfified() Determine last-modified timestamp based on the referenced file. This silences warnings such as Server returned lastModified <= 0 for mvn:org.eclipse.jetty:jetty-p2:11.0.12:zip:p2site/content.xml Fixes #982. --- .../core/internal/MvnProtocolHandlerService.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MvnProtocolHandlerService.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MvnProtocolHandlerService.java index 903d7b710..b5a1ffec4 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MvnProtocolHandlerService.java +++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/MvnProtocolHandlerService.java @@ -129,6 +129,19 @@ public InputStream getInputStream() throws IOException { String urlSpec = "jar:" + location.toURI() + "!" + subPath; return new URL(urlSpec).openStream(); } + + @Override + public long getLastModified() { + try { + connect(); + } catch (IOException e) { + return 0; + } + if(artifactResult == null || artifactResult.isMissing()) { + return 0; + } + return artifactResult.getArtifact().getFile().lastModified(); + } } }