diff --git a/0001-Fix-manifests-for-guava-and-use-OSGi-fied-archetypes.patch b/0001-Fix-manifests-for-guava-and-use-OSGi-fied-archetypes.patch index f77d94a..9c66970 100644 --- a/0001-Fix-manifests-for-guava-and-use-OSGi-fied-archetypes.patch +++ b/0001-Fix-manifests-for-guava-and-use-OSGi-fied-archetypes.patch @@ -1,4 +1,4 @@ -From 998973a4b3cbb738b017e9561fa7d00266de041f Mon Sep 17 00:00:00 2001 +From 65d22d3bb41c5c8cf9e8f7f512ef839b15bcfa0a Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Tue, 18 Jun 2019 15:35:48 +0100 Subject: [PATCH 1/6] Fix manifests for guava and use OSGi-fied archetypes @@ -12,7 +12,7 @@ Subject: [PATCH 1/6] Fix manifests for guava and use OSGi-fied archetypes 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF b/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF -index c4d5114..842e7d2 100644 +index 037fee4..fd7d01c 100644 --- a/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core.ui/META-INF/MANIFEST.MF @@ -37,7 +37,9 @@ Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.16.0,1.17.0)", @@ -27,10 +27,10 @@ index c4d5114..842e7d2 100644 org.eclipse.ltk.core.refactoring, org.slf4j;version="1.6.2" diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF -index d3ecce2..af681a0 100644 +index e27e14a..7f97012 100644 --- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF -@@ -13,7 +13,9 @@ +@@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.10.0", org.eclipse.core.runtime;bundle-version="3.12.0", org.eclipse.core.resources;bundle-version="3.9.0", org.eclipse.core.filesystem;bundle-version="1.7.700", @@ -42,7 +42,7 @@ index d3ecce2..af681a0 100644 Bundle-ClassPath: . Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/org.eclipse.m2e.editor.xml/META-INF/MANIFEST.MF b/org.eclipse.m2e.editor.xml/META-INF/MANIFEST.MF -index c9db5ed..ad892c7 100644 +index 0fcba39..519e140 100644 --- a/org.eclipse.m2e.editor.xml/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.editor.xml/META-INF/MANIFEST.MF @@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.core.runtime, @@ -55,7 +55,7 @@ index c9db5ed..ad892c7 100644 org.eclipse.search;bundle-version="3.11.700", org.eclipse.ui.views diff --git a/org.eclipse.m2e.editor/META-INF/MANIFEST.MF b/org.eclipse.m2e.editor/META-INF/MANIFEST.MF -index 01be1cf..86402e7 100644 +index 5f1b2e6..bbf5492 100644 --- a/org.eclipse.m2e.editor/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.editor/META-INF/MANIFEST.MF @@ -30,7 +30,7 @@ Require-Bundle: org.eclipse.core.runtime, @@ -81,4 +81,5 @@ index 5993fbe..380c9dd 100644 org.eclipse.core.variables;bundle-version="3.2.0" Import-Package: org.slf4j;version="1.6.2" -- -2.26.2 +2.28.0 + diff --git a/0002-Port-to-latest-versions-of-maven-indexer-and-lucene.patch b/0002-Port-to-latest-versions-of-maven-indexer-and-lucene.patch index 193a3ea..35764f1 100644 --- a/0002-Port-to-latest-versions-of-maven-indexer-and-lucene.patch +++ b/0002-Port-to-latest-versions-of-maven-indexer-and-lucene.patch @@ -1,4 +1,4 @@ -From 14bc75f92c9fa3d94e1c29b56458e981f9ec7833 Mon Sep 17 00:00:00 2001 +From 07055ab88ebbe85a14846839a3bd4919cceb1529 Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Tue, 18 Jun 2019 15:45:18 +0100 Subject: [PATCH 2/6] Port to latest versions of maven-indexer and lucene @@ -442,5 +442,5 @@ index 37d6906..e7e0688 100644 } catch(NoSuchAlgorithmException ex) { throw new IOException("Unable to calculate digest"); -- -2.26.2 +2.28.0 diff --git a/0003-Adapt-to-API-change-in-aether.patch b/0003-Adapt-to-API-change-in-aether.patch index e54e6d3..8c3f412 100644 --- a/0003-Adapt-to-API-change-in-aether.patch +++ b/0003-Adapt-to-API-change-in-aether.patch @@ -1,12 +1,11 @@ -From c4fceef8e2f7a03171eb703e4f6ffba0cd3e451f Mon Sep 17 00:00:00 2001 +From 109bc51f5eab1e29ea3928fbd3efc9cb48712c6a Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Fri, 21 Jun 2019 11:24:15 +0100 Subject: [PATCH 3/6] Adapt to API change in aether --- - .../embedder/ContextRepositorySystemSessionImpl.java | 6 ------ .../internal/lifecyclemapping/LifecycleMappingFactory.java | 6 +++--- - 2 files changed, 3 insertions(+), 9 deletions(-) + 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/lifecyclemapping/LifecycleMappingFactory.java index 416decc..630992a 100644 @@ -29,5 +28,5 @@ index 416decc..630992a 100644 } } -- -2.26.2 +2.28.0 diff --git a/0004-Remove-mandatory-attirbutes-from-OSGi-manifests-whic.patch b/0004-Remove-mandatory-attirbutes-from-OSGi-manifests-whic.patch index 5298489..b67ef6c 100644 --- a/0004-Remove-mandatory-attirbutes-from-OSGi-manifests-whic.patch +++ b/0004-Remove-mandatory-attirbutes-from-OSGi-manifests-whic.patch @@ -1,4 +1,4 @@ -From 7c8940ab74e95d0dc5c4e093ba4372f995ac3540 Mon Sep 17 00:00:00 2001 +From 8e70962da8183da5476130f470e75f23d7b2c2f9 Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Fri, 21 Jun 2019 11:27:12 +0100 Subject: [PATCH 4/6] Remove mandatory attirbutes from OSGi manifests, which @@ -63,5 +63,5 @@ index cc868e7..0ff5875 100644 -- -2.26.2 +2.28.0 diff --git a/0005-Port-to-latest-version-of-maven-archetypes.patch b/0005-Port-to-latest-version-of-maven-archetypes.patch index b68c04f..4887483 100644 --- a/0005-Port-to-latest-version-of-maven-archetypes.patch +++ b/0005-Port-to-latest-version-of-maven-archetypes.patch @@ -1,4 +1,4 @@ -From 5242f2d4a7d852c8d75df4b492d90e73e1a3fe61 Mon Sep 17 00:00:00 2001 +From cb5abc1b4420421bbba1b35e46cb58cc37e1524c Mon Sep 17 00:00:00 2001 From: Mat Booth Date: Wed, 25 Mar 2020 11:26:45 +0000 Subject: [PATCH 5/6] Port to latest version of maven-archetypes @@ -16,7 +16,7 @@ Subject: [PATCH 5/6] Port to latest version of maven-archetypes 9 files changed, 43 insertions(+), 339 deletions(-) diff --git a/m2e-maven-runtime/org.eclipse.m2e.archetype.common/pom.xml b/m2e-maven-runtime/org.eclipse.m2e.archetype.common/pom.xml -index 96ec268..42de5a3 100644 +index 96ec268..6bb1bd0 100644 --- a/m2e-maven-runtime/org.eclipse.m2e.archetype.common/pom.xml +++ b/m2e-maven-runtime/org.eclipse.m2e.archetype.common/pom.xml @@ -24,7 +24,7 @@ @@ -602,5 +602,5 @@ index e7e0688..61e3762 100644 throw new NoSuchComponentException(ex); } -- -2.26.2 +2.28.0 diff --git a/0006-Remove-dep-on-aether-connector.patch b/0006-Remove-dep-on-aether-connector.patch index 36652b1..2db21e0 100644 --- a/0006-Remove-dep-on-aether-connector.patch +++ b/0006-Remove-dep-on-aether-connector.patch @@ -1,33 +1,34 @@ -From 789069406cc9f0ee5e048db1c8e4b0019fdff9b6 Mon Sep 17 00:00:00 2001 +From 87b628fc0fc231a690708bbfe798e8e0836d2fce Mon Sep 17 00:00:00 2001 From: Mat Booth -Date: Mon, 13 Jul 2020 13:52:18 +0100 +Date: Tue, 17 Nov 2020 10:32:54 +0000 Subject: [PATCH 6/6] Remove dep on aether-connector -Change-Id: I08f91c9ddc84f6f34205452467a71b18badad4a0 -Signed-off-by: Mat Booth --- - .../org.eclipse.m2e.maven.runtime/pom.xml | 15 +- + .../.factorypath | 3 - + .../org.eclipse.m2e.maven.runtime/pom.xml | 18 +- org.eclipse.m2e.core/META-INF/MANIFEST.MF | 2 +- - .../nexus/AetherClientResourceFetcher.java | 201 ------------------ - .../index/nexus/HttpResourceFetcher.java | 153 +++++++++++++ - .../index/nexus/NexusIndexManager.java | 2 +- - 5 files changed, 156 insertions(+), 217 deletions(-) - delete mode 100644 org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java - create mode 100644 org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/HttpResourceFetcher.java + .../nexus/AetherClientResourceFetcher.java | 198 +++++++----------- + 4 files changed, 79 insertions(+), 142 deletions(-) +diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/.factorypath b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/.factorypath +index 72b8866..fe9f4ca 100644 +--- a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/.factorypath ++++ b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/.factorypath +@@ -38,9 +38,6 @@ + + + +- +- +- + + + diff --git a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml -index 0ff5875..0440325 100644 +index 0ff5875..10b69ff 100644 --- a/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml +++ b/m2e-maven-runtime/org.eclipse.m2e.maven.runtime/pom.xml -@@ -33,7 +33,6 @@ - 3.6.3 - - 0.0.7 -- 0.17.8 - - - -@@ -76,17 +75,6 @@ +@@ -76,17 +76,6 @@ ${plexus-build-api.version} true @@ -45,7 +46,18 @@ index 0ff5875..0440325 100644 org.apache.maven.resolver maven-resolver-impl -@@ -143,8 +131,7 @@ +@@ -106,6 +95,10 @@ + org.apache.maven.wagon + wagon-file + ++ ++ org.apache.maven.wagon ++ wagon-http ++ + + org.fusesource.jansi + jansi +@@ -143,8 +136,7 @@ org.codehaus.plexus.*;provider=m2e, org.sonatype.plexus.*;provider=m2e, org.eclipse.aether.*;provider=m2e, @@ -56,10 +68,10 @@ index 0ff5875..0440325 100644 diff --git a/org.eclipse.m2e.core/META-INF/MANIFEST.MF b/org.eclipse.m2e.core/META-INF/MANIFEST.MF -index af681a0..51766cf 100644 +index 7f97012..6d8a47f 100644 --- a/org.eclipse.m2e.core/META-INF/MANIFEST.MF +++ b/org.eclipse.m2e.core/META-INF/MANIFEST.MF -@@ -18,7 +18,7 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.10.0", +@@ -19,7 +19,7 @@ Require-Bundle: org.eclipse.osgi;bundle-version="3.10.0", com.google.guava;bundle-version="[20.0,29.0)" Bundle-ActivationPolicy: lazy Bundle-ClassPath: . @@ -69,33 +81,19 @@ index af681a0..51766cf 100644 org.eclipse.m2e.core.archetype;x-friends:="org.eclipse.m2e.core.ui", org.eclipse.m2e.core.embedder, diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java -deleted file mode 100644 -index b311824..0000000 +index b311824..b508478 100644 --- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java -+++ /dev/null -@@ -1,201 +0,0 @@ --/******************************************************************************* -- * Copyright (c) 2010 Sonatype, Inc. -- * All rights reserved. This program and the accompanying materials -- * are made available under the terms of the Eclipse Public License 2.0 -- * which accompanies this distribution, and is available at -- * https://www.eclipse.org/legal/epl-2.0/ -- * -- * SPDX-License-Identifier: EPL-2.0 -- * -- * Contributors: -- * Sonatype, Inc. - initial API and implementation -- *******************************************************************************/ -- --package org.eclipse.m2e.core.internal.index.nexus; -- --import java.io.BufferedOutputStream; --import java.io.File; --import java.io.FileNotFoundException; --import java.io.FileOutputStream; --import java.io.IOException; --import java.io.InputStream; --import java.io.OutputStream; ++++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/AetherClientResourceFetcher.java +@@ -15,21 +15,27 @@ package org.eclipse.m2e.core.internal.index.nexus; + + import java.io.BufferedOutputStream; + import java.io.File; ++import java.io.FileInputStream; + import java.io.FileNotFoundException; + import java.io.FileOutputStream; + import java.io.IOException; + import java.io.InputStream; + import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.NoSuchAlgorithmException; @@ -106,17 +104,28 @@ index b311824..0000000 - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -- --import org.eclipse.core.runtime.IProgressMonitor; --import org.eclipse.core.runtime.NullProgressMonitor; --import org.eclipse.core.runtime.OperationCanceledException; -- --import org.apache.maven.index.updater.ResourceFetcher; --import org.apache.maven.wagon.authentication.AuthenticationInfo; --import org.apache.maven.wagon.proxy.ProxyInfo; --import org.apache.maven.wagon.proxy.ProxyUtils; -- --import org.eclipse.m2e.core.internal.MavenPluginActivator; ++import java.net.Authenticator; ++import java.net.InetSocketAddress; ++import java.net.PasswordAuthentication; ++import java.net.Proxy; ++import java.net.ProxySelector; ++import java.net.SocketAddress; ++import java.net.URI; ++import java.net.http.HttpClient; ++import java.net.http.HttpClient.Redirect; ++import java.net.http.HttpClient.Version; ++import java.net.http.HttpRequest; ++import java.net.http.HttpResponse; ++import java.net.http.HttpResponse.BodyHandlers; ++import java.time.Duration; ++import java.util.List; + + import org.eclipse.core.runtime.IProgressMonitor; + import org.eclipse.core.runtime.NullProgressMonitor; +@@ -41,161 +47,103 @@ import org.apache.maven.wagon.proxy.ProxyInfo; + import org.apache.maven.wagon.proxy.ProxyUtils; + + import org.eclipse.m2e.core.internal.MavenPluginActivator; -import org.eclipse.m2e.core.internal.Messages; - -import io.takari.aether.client.AetherClient; @@ -125,58 +134,103 @@ index b311824..0000000 -import io.takari.aether.client.AetherClientProxy; -import io.takari.aether.client.Response; -import io.takari.aether.okhttp.OkHttpAetherClient; -- -- --public class AetherClientResourceFetcher implements ResourceFetcher { -- + + + public class AetherClientResourceFetcher implements ResourceFetcher { + - private AetherClient aetherClient; -- ++ private HttpClient client; + - private final AuthenticationInfo authInfo; -- ++ private Authenticator auth; + - private final ProxyInfo proxyInfo; -- ++ private ProxySelector proxy; + - private final String userAgent; - - private final IProgressMonitor monitor; -- -- private String baseUrl; -- -- public AetherClientResourceFetcher(final AuthenticationInfo authInfo, final ProxyInfo proxyInfo, -- final IProgressMonitor monitor) { ++ private IProgressMonitor monitor; + + private String baseUrl; + + public AetherClientResourceFetcher(final AuthenticationInfo authInfo, final ProxyInfo proxyInfo, + final IProgressMonitor monitor) { - this.authInfo = authInfo; - this.proxyInfo = proxyInfo; -- this.monitor = (monitor != null) ? monitor : new NullProgressMonitor(); ++ if(authInfo != null) { ++ auth = new Authenticator() { ++ @Override ++ protected PasswordAuthentication getPasswordAuthentication() { ++ return new PasswordAuthentication(authInfo.getUserName(), authInfo.getPassword().toCharArray()); ++ } ++ }; ++ } ++ proxy = new WagonProxySelector(proxyInfo); + this.monitor = (monitor != null) ? monitor : new NullProgressMonitor(); - this.userAgent = MavenPluginActivator.getUserAgent(); -- } -- + } + - public void connect(String id, String url) { - this.baseUrl = url; - aetherClient = new OkHttpAetherClient( - new AetherClientConfigAdapter(baseUrl, authInfo, proxyInfo, userAgent, - new HashMap())); -- } -- -- public void disconnect() throws IOException { ++ public void connect(String id, String url) throws IOException { ++ baseUrl = url; ++ HttpClient.Builder builder = HttpClient.newBuilder().version(Version.HTTP_1_1).followRedirects(Redirect.NORMAL) ++ .connectTimeout(Duration.ofSeconds(10)).proxy(proxy); ++ if(auth != null) { ++ builder.authenticator(auth); ++ } ++ client = builder.build(); + } + + public void disconnect() throws IOException { - aetherClient.close(); -- } -- + } + - @Deprecated -- public void retrieve(String name, File targetFile) throws IOException, FileNotFoundException { ++ public InputStream retrieve(String name) throws IOException, FileNotFoundException { ++ final File target = File.createTempFile(name, ""); ++ retrieve(name, target); ++ return new FileInputStream(target) { ++ @Override ++ public void close() throws IOException { ++ super.close(); ++ target.delete(); ++ } ++ }; ++ } ++ + public void retrieve(String name, File targetFile) throws IOException, FileNotFoundException { - String url = baseUrl + "/" + name; - try (Response response = aetherClient.get(url); - InputStream is = response.getInputStream(); - OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile))) { -- final byte[] buffer = new byte[1024 * 1024]; -- int n = 0; ++ System.out.println(); ++ System.out.println("Requesting: " + baseUrl + "/" + name); ++ HttpRequest request = HttpRequest.newBuilder().uri(URI.create(baseUrl + "/" + name)).timeout(Duration.ofMinutes(2)) ++ .header("User-Agent", MavenPluginActivator.getUserAgent()).GET().build(); ++ System.out.println(request.headers()); ++ try (OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile))) { ++ HttpResponse response = client.send(request, BodyHandlers.ofInputStream()); ++ System.out.println(response.headers()); + final byte[] buffer = new byte[1024 * 1024]; + int n = 0; - while(-1 != (n = is.read(buffer))) { -- os.write(buffer, 0, n); -- if(monitor.isCanceled()) { -- throw new OperationCanceledException(); -- } -- } -- } -- } -- ++ while(-1 != (n = response.body().read(buffer))) { + os.write(buffer, 0, n); + if(monitor.isCanceled()) { + throw new OperationCanceledException(); + } + } ++ } catch(InterruptedException ex) { ++ throw new OperationCanceledException(); + } ++ monitor.worked(1); + } + - public InputStream retrieve(String name) throws IOException, FileNotFoundException { - String url = baseUrl + "/" + name; - Response response = aetherClient.get(url); @@ -198,14 +252,17 @@ index b311824..0000000 - String userAgent; - - String baseUrl; -- ++ static class WagonProxySelector extends ProxySelector { + - Map headers; -- ++ private ProxyInfo proxyInfo; + - public AetherClientConfigAdapter(String baseUrl, AuthenticationInfo authInfo, ProxyInfo proxyInfo, String userAgent, - Map headers) { - this.baseUrl = baseUrl; - this.authInfo = authInfo; -- this.proxyInfo = proxyInfo; ++ public WagonProxySelector(ProxyInfo proxyInfo) { + this.proxyInfo = proxyInfo; - this.userAgent = userAgent; - this.headers = headers; - @@ -219,8 +276,8 @@ index b311824..0000000 - - public String getUserAgent() { - return userAgent; -- } -- + } + - public int getConnectionTimeout() { - return connectionTimeout; - } @@ -233,7 +290,10 @@ index b311824..0000000 - - if(proxyInfo == null) { - return null; -- } ++ public List select(URI uri) { ++ if(proxyInfo == null || ProxyUtils.validateNonProxyHosts(proxyInfo, uri.getHost())) { ++ return List.of(Proxy.NO_PROXY); + } - //Bug 512006 don't return the proxy for nonProxyHosts - try { - if(ProxyUtils.validateNonProxyHosts(proxyInfo, new URL(baseUrl).getHost())) { @@ -266,188 +326,21 @@ index b311824..0000000 - - if(authInfo != null) { - return new AetherClientAuthentication(authInfo.getUserName(), authInfo.getPassword()); -- } -- return null; -- } -- -- public Map getHeaders() { -- return headers; -- } -- } --} -diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/HttpResourceFetcher.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/HttpResourceFetcher.java -new file mode 100644 -index 0000000..d1f467d ---- /dev/null -+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/HttpResourceFetcher.java -@@ -0,0 +1,154 @@ -+/******************************************************************************* -+ * Copyright (c) 2020 Red Hat, Inc. -+ * All rights reserved. This program and the accompanying materials -+ * are made available under the terms of the Eclipse Public License 2.0 -+ * which accompanies this distribution, and is available at -+ * https://www.eclipse.org/legal/epl-2.0/ -+ * -+ * SPDX-License-Identifier: EPL-2.0 -+ *******************************************************************************/ -+ -+package org.eclipse.m2e.core.internal.index.nexus; -+ -+import java.io.BufferedOutputStream; -+import java.io.File; -+import java.io.FileNotFoundException; -+import java.io.FileInputStream; -+import java.io.FileOutputStream; -+import java.io.IOException; -+import java.io.InputStream; -+import java.io.OutputStream; -+import java.net.Authenticator; -+import java.net.InetSocketAddress; -+import java.net.PasswordAuthentication; -+import java.net.Proxy; -+import java.net.ProxySelector; -+import java.net.SocketAddress; -+import java.net.URI; -+import java.net.http.HttpClient; -+import java.net.http.HttpClient.Redirect; -+import java.net.http.HttpClient.Version; -+import java.net.http.HttpRequest; -+import java.net.http.HttpResponse; -+import java.net.http.HttpResponse.BodyHandlers; -+import java.time.Duration; -+import java.util.List; -+ -+import org.eclipse.core.runtime.IProgressMonitor; -+import org.eclipse.core.runtime.NullProgressMonitor; -+import org.eclipse.core.runtime.OperationCanceledException; -+ -+import org.apache.maven.index.updater.ResourceFetcher; -+import org.apache.maven.wagon.authentication.AuthenticationInfo; -+import org.apache.maven.wagon.proxy.ProxyInfo; -+import org.apache.maven.wagon.proxy.ProxyUtils; -+ -+import org.eclipse.m2e.core.internal.MavenPluginActivator; -+ -+ -+/** -+ * Resource fetcher implementation based on the JDK's built-in HTTP client. -+ */ -+public class HttpResourceFetcher implements ResourceFetcher { -+ -+ private HttpClient client; -+ -+ private Authenticator auth; -+ -+ private ProxySelector proxy; -+ -+ private IProgressMonitor monitor; -+ -+ private String baseUrl; -+ -+ public HttpResourceFetcher(final AuthenticationInfo authInfo, final ProxyInfo proxyInfo, -+ final IProgressMonitor monitor) { -+ if(authInfo != null) { -+ auth = new Authenticator() { -+ @Override -+ protected PasswordAuthentication getPasswordAuthentication() { -+ return new PasswordAuthentication(authInfo.getUserName(), authInfo.getPassword().toCharArray()); -+ } -+ }; -+ } -+ proxy = new WagonProxySelector(proxyInfo); -+ this.monitor = (monitor != null) ? monitor : new NullProgressMonitor(); -+ } -+ -+ public void connect(String id, String url) throws IOException { -+ baseUrl = url; -+ HttpClient.Builder builder = HttpClient.newBuilder().version(Version.HTTP_1_1).followRedirects(Redirect.NORMAL) -+ .connectTimeout(Duration.ofSeconds(10)).proxy(proxy); -+ if(auth != null) { -+ builder.authenticator(auth); -+ } -+ client = builder.build(); -+ } -+ -+ public void disconnect() throws IOException { -+ } -+ -+ public InputStream retrieve( String name ) -+ throws IOException, FileNotFoundException -+ { -+ final File target = File.createTempFile( name, "" ); -+ retrieve( name, target ); -+ return new FileInputStream( target ) -+ { -+ @Override -+ public void close() -+ throws IOException -+ { -+ super.close(); -+ target.delete(); -+ } -+ }; -+ } -+ -+ public void retrieve(String name, File targetFile) throws IOException, FileNotFoundException { -+ System.out.println(); -+ System.out.println("Requesting: " + baseUrl + "/" + name); -+ HttpRequest request = HttpRequest.newBuilder().uri(URI.create(baseUrl + "/" + name)).timeout(Duration.ofMinutes(2)) -+ .header("User-Agent", MavenPluginActivator.getUserAgent()).GET().build(); -+ System.out.println(request.headers()); -+ try (OutputStream os = new BufferedOutputStream(new FileOutputStream(targetFile))) { -+ HttpResponse response = client.send(request, BodyHandlers.ofInputStream()); -+ System.out.println(response.headers()); -+ final byte[] buffer = new byte[1024 * 1024]; -+ int n = 0; -+ while(-1 != (n = response.body().read(buffer))) { -+ os.write(buffer, 0, n); -+ if(monitor.isCanceled()) { -+ throw new OperationCanceledException(); -+ } -+ } -+ } catch(InterruptedException ex) { -+ throw new OperationCanceledException(); -+ } -+ monitor.worked(1); -+ } -+ -+ static class WagonProxySelector extends ProxySelector { -+ -+ private ProxyInfo proxyInfo; -+ -+ public WagonProxySelector(ProxyInfo proxyInfo) { -+ this.proxyInfo = proxyInfo; -+ } -+ -+ public List select(URI uri) { -+ if(proxyInfo == null || ProxyUtils.validateNonProxyHosts(proxyInfo, uri.getHost())) { -+ return List.of(Proxy.NO_PROXY); -+ } + Proxy.Type type = Proxy.Type.HTTP; + if(!proxyInfo.getType().equals(ProxyInfo.PROXY_HTTP)) { + type = Proxy.Type.SOCKS; -+ } + } +- return null; + Proxy p = new Proxy(type, new InetSocketAddress(proxyInfo.getHost(), proxyInfo.getPort())); + return List.of(p); -+ } -+ -+ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { -+ } -+ } -+} -diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java -index 61e3762..5426327 100644 ---- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java -+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/index/nexus/NexusIndexManager.java -@@ -1181,7 +1181,7 @@ public class NexusIndexManager implements IndexManager, IMavenProjectChangedList - ProxyInfo proxyInfo = maven.getProxyInfo(repository.getProtocol()); - AuthenticationInfo authenticationInfo = repository.getAuthenticationInfo(); + } -- IndexUpdateRequest request = new IndexUpdateRequest(context, new AetherClientResourceFetcher(authenticationInfo, -+ IndexUpdateRequest request = new IndexUpdateRequest(context, new HttpResourceFetcher(authenticationInfo, - proxyInfo, monitor)); - File localRepo = repositoryRegistry.getLocalRepository().getBasedir(); - File indexCacheBasedir = new File(localRepo, ".cache/m2e/" + MavenPluginActivator.getVersion()).getCanonicalFile(); //$NON-NLS-1$ +- public Map getHeaders() { +- return headers; ++ public void connectFailed(URI uri, SocketAddress sa, IOException ioe) { + } + } + } -- -2.26.2 +2.28.0 diff --git a/eclipse-m2e-core.spec b/eclipse-m2e-core.spec index 70124ef..13780b6 100644 --- a/eclipse-m2e-core.spec +++ b/eclipse-m2e-core.spec @@ -2,7 +2,7 @@ Name: eclipse-m2e-core Version: 1.16.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Maven integration for Eclipse # Most of components are under EPL, but some of them are licensed under @@ -168,14 +168,20 @@ Requires: apache-commons-lang3 Requires: atinject Requires: cdi-api Requires: eclipse-m2e-workspace -Requires: glassfish-el-api Requires: google-gson Requires: google-guice Requires: hawtjni-runtime +Requires: httpcomponents-client +Requires: httpcomponents-core +Requires: jakarta-annotations +Requires: jakarta-el-api Requires: jansi Requires: jansi-native Requires: jchardet +Requires: jcl-over-slf4j Requires: jdom +Requires: jsoup +Requires: jsr-305 Requires: lucene-highlighter Requires: lucene-memory Requires: lucene-queries @@ -198,6 +204,7 @@ Requires: maven-resolver-util Requires: maven-shared-utils Requires: maven-wagon-file Requires: maven-wagon-http +Requires: maven-wagon-http-shared Requires: maven-wagon-provider-api Requires: plexus-build-api Requires: plexus-cipher @@ -359,6 +366,10 @@ xmvn-subst -s $(find %{buildroot}%{_datadir}/eclipse/droplets/m2e-core -name jar %license LICENSE-2.0.txt %changelog +* Tue Nov 17 2020 Mat Booth - 1.16.2-2 +- Fix failure to transfer artifacts from remote repositories caused missing + wagon provider for http connections + * Tue Nov 10 2020 Mat Booth - 1.16.2-1 - Update to latest upstream release