Skip to content

Commit

Permalink
Avoid touching old plexus anymore
Browse files Browse the repository at this point in the history
Why direct lookup, when it goes without touching
the plexus APIs.
  • Loading branch information
cstamas committed Nov 19, 2024
1 parent 8e9f3ea commit 424e976
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,9 @@ under the License.

<!-- Plexus -->
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
<version>1.4.2</version>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>0.9.0.M3</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.net.URL;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import org.apache.maven.doxia.site.inheritance.URIPathDescriptor;
import org.apache.maven.doxia.tools.SiteTool;
Expand Down Expand Up @@ -53,8 +54,6 @@
import org.apache.maven.wagon.observers.Debug;
import org.apache.maven.wagon.proxy.ProxyInfo;
import org.apache.maven.wagon.repository.Repository;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;

/**
* Abstract base class for deploy mojos.
Expand Down Expand Up @@ -124,7 +123,7 @@ public abstract class AbstractDeployMojo extends AbstractSiteMojo {
private Site deploySite;

@Component
private PlexusContainer container;
private Map<String, Wagon> wagons;

@Component
SettingsDecrypter settingsDecrypter;
Expand Down Expand Up @@ -277,16 +276,15 @@ private Wagon getWagon(final Repository repository) throws MojoExecutionExceptio
if (protocol == null) {
throw new MojoExecutionException("Unspecified protocol");
}
try {
Wagon wagon = container.lookup(Wagon.class, protocol.toLowerCase(Locale.ROOT));
if (!wagon.supportsDirectoryCopy()) {
throw new MojoExecutionException(
"Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying");
}
return wagon;
} catch (ComponentLookupException e) {
throw new MojoExecutionException("Cannot find wagon which supports the requested protocol: " + protocol, e);
Wagon wagon = wagons.get(protocol.toLowerCase(Locale.ROOT));
if (wagon == null) {
throw new MojoExecutionException("Cannot find wagon which supports the requested protocol: " + protocol);
}
if (!wagon.supportsDirectoryCopy()) {
throw new MojoExecutionException(
"Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying");
}
return wagon;
}

public AuthenticationInfo getAuthenticationInfo(String id) {
Expand Down Expand Up @@ -558,7 +556,7 @@ private static String encodeURI(final String uriString) {
uri.append(c);
} else {
uri.append('%');
uri.append(Integer.toHexString((int) c));
uri.append(Integer.toHexString(c));
}
}
return uri.toString();
Expand Down

0 comments on commit 424e976

Please sign in to comment.