Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ under the License.
<mavenReportingImplVersion>4.0.0</mavenReportingImplVersion>
<fluidoSkinVersion>2.0.0-M11</fluidoSkinVersion>
<project.build.outputTimestamp>2024-07-17T13:43:56Z</project.build.outputTimestamp>

<!-- remove with parent pom upgrade -->
<version.maven-invoker-plugin>3.9.1</version.maven-invoker-plugin>
</properties>

<dependencies>
Expand Down Expand Up @@ -294,6 +295,11 @@ under the License.
<artifactId>commons-io</artifactId>
<version>2.20.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-api</artifactId>
<version>2.1.0</version>
</dependency>

<!-- dependencies to annotations -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/effective-site/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ under the License.
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>43</version>
<version>45</version>
</parent>

<groupId>org.apache.maven.plugins.site.its</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/full-reporting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ under the License.
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven-parent</artifactId>
<version>43</version>
<version>45</version>
</parent>

<groupId>org.apache.maven.plugins.site.its</groupId>
Expand Down
2 changes: 1 addition & 1 deletion src/it/projects/full-reporting/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ assert content.contains( 'Tests run: 1, Failures: 0, Errors: 0, Skipped: 0' );

sitedir = new File( basedir, 'target/site' );

assert new File( sitedir, 'surefire-report.html' ).exists();
assert new File( sitedir, 'surefire.html' ).exists();
assert new File( sitedir, 'index.html' ).exists();
assert new File( sitedir, 'checkstyle.html' ).exists();
assert new File( sitedir, 'cpd.html' ).exists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@
*/
package org.apache.maven.plugins.site;

import javax.inject.Inject;

import java.util.List;
import java.util.Locale;

import org.apache.maven.doxia.tools.SiteTool;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.i18n.I18N;
Expand Down Expand Up @@ -54,13 +55,13 @@ public abstract class AbstractSiteMojo extends AbstractMojo {
/**
* SiteTool.
*/
@Component
@Inject
protected SiteTool siteTool;

/**
* Internationalization.
*/
@Component
@Inject
protected I18N i18n;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@
*/
package org.apache.maven.plugins.site.deploy;

import javax.inject.Inject;

import java.io.File;
import java.net.MalformedURLException;
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 All @@ -31,10 +34,10 @@
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Site;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.site.AbstractSiteMojo;
import org.apache.maven.project.MavenProject;
import org.apache.maven.scm.provider.ScmUrlUtils;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Server;
import org.apache.maven.settings.Settings;
Expand All @@ -53,8 +56,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 @@ -123,10 +124,10 @@ public abstract class AbstractDeployMojo extends AbstractSiteMojo {

private Site deploySite;

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

@Component
@Inject
SettingsDecrypter settingsDecrypter;

/**
Expand Down Expand Up @@ -277,16 +278,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 @@ -493,6 +493,66 @@ private static String getFullName(MavenProject project) {
+ project.getVersion() + ')';
}

/**
* Extracts the provider-specific URL from an SCM URL for comparison purposes.
* For non-SCM URLs, returns the original URL.
* For SCM URLs with SCP-like syntax (e.g., git@github.com:user/repo.git),
* converts them to a comparable format.
* For hierarchical SCM systems like SVN, normalizes the scheme to enable
* proper comparison of URLs that differ only in http vs https.
*
* @param url the URL to process
* @return the provider-specific URL for SCM URLs, or the original URL otherwise
*/
static String extractComparableUrl(String url) {
if (url != null && url.startsWith("scm:")) {
// Extract the SCM provider (e.g., "git", "svn")
String provider = ScmUrlUtils.getProvider(url);

// Extract the provider-specific part of the SCM URL
// For example: "scm:git:https://github.com/user/repo.git" -> "https://github.com/user/repo.git"
String providerSpecificPart = ScmUrlUtils.getProviderSpecificPart(url);
if (providerSpecificPart != null && !providerSpecificPart.isEmpty()) {
// Handle SCP-like Git syntax (e.g., git@github.com:user/repo.git or user@host:path)
// Convert it to a more standard format for comparison
// Note: This is a heuristic check - we look for the pattern of user@host:path
// where the colon comes after the @ symbol and is followed by a path
if (providerSpecificPart.contains("@")
&& !providerSpecificPart.startsWith("http://")
&& !providerSpecificPart.startsWith("https://")
&& !providerSpecificPart.startsWith("ssh://")) {
// Find the @ symbol and look for the first : after it that's not part of a URL scheme
int atIndex = providerSpecificPart.lastIndexOf('@');
int colonIndex = providerSpecificPart.indexOf(':', atIndex);

// Verify this looks like SCP syntax: user@host:path
// The colon should come after @ and before the end
if (atIndex >= 0 && colonIndex > atIndex + 1 && colonIndex < providerSpecificPart.length() - 1) {
String host = providerSpecificPart.substring(atIndex + 1, colonIndex);
String path = providerSpecificPart.substring(colonIndex + 1);
// Convert to a pseudo-URL format for comparison
// Note: IPv6 addresses in brackets are handled by this approach
// as the brackets will be preserved in the host part
return "ssh://" + host + "/" + path;
}
}

// For hierarchical VCS systems like SVN, normalize the scheme to allow
// comparison of URLs that differ only in http vs https
// SVN repositories can be accessed via both protocols and should be considered the same
if ("svn".equalsIgnoreCase(provider) && providerSpecificPart.startsWith("https://")) {
// Normalize https to http for SVN URLs to enable proper comparison
return "http" + providerSpecificPart.substring(5);
}

// Return the provider-specific part as-is for standard URLs or
// if SCP syntax conversion is not applicable
return providerSpecificPart;
}
}
return url;
}

/**
* Extract the distributionManagement site of the top level parent of the given MavenProject.
* This climbs up the project hierarchy and returns the site of the last project
Expand Down Expand Up @@ -524,8 +584,12 @@ protected MavenProject getTopLevelProject(MavenProject project) throws MojoExecu
}

// MSITE-600
URIPathDescriptor siteURI = new URIPathDescriptor(URIEncoder.encodeURI(site.getUrl()), "");
URIPathDescriptor oldSiteURI = new URIPathDescriptor(URIEncoder.encodeURI(oldSite.getUrl()), "");
// MSITE-1033: For SCM URLs, extract the provider-specific part for comparison
String siteUrlToCompare = extractComparableUrl(site.getUrl());
String oldSiteUrlToCompare = extractComparableUrl(oldSite.getUrl());

URIPathDescriptor siteURI = new URIPathDescriptor(URIEncoder.encodeURI(siteUrlToCompare), "");
URIPathDescriptor oldSiteURI = new URIPathDescriptor(URIEncoder.encodeURI(oldSiteUrlToCompare), "");

if (!siteURI.sameSite(oldSiteURI.getBaseURI())) {
return oldProject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
Expand Down Expand Up @@ -57,7 +58,6 @@
import org.apache.maven.reporting.exec.MavenReportExecution;
import org.apache.maven.reporting.exec.MavenReportExecutor;
import org.apache.maven.reporting.exec.MavenReportExecutorRequest;
import org.codehaus.plexus.util.ReaderFactory;

import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;

Expand Down Expand Up @@ -192,7 +192,9 @@ protected AbstractSiteRenderingMojo(
* @return The input files encoding, never <code>null</code>.
*/
protected String getInputEncoding() {
return (inputEncoding == null || inputEncoding.isEmpty()) ? ReaderFactory.FILE_ENCODING : inputEncoding;
return (inputEncoding == null || inputEncoding.isEmpty())
? Charset.defaultCharset().displayName()
: inputEncoding;
}

/**
Expand All @@ -215,8 +217,8 @@ protected String getOutputEncoding() {

protected void checkInputEncoding() {
if (inputEncoding == null || inputEncoding.isEmpty()) {
getLog().warn("Input file encoding has not been set, using platform encoding " + ReaderFactory.FILE_ENCODING
+ ", i.e. build is platform dependent!");
getLog().warn("Input file encoding has not been set, using platform encoding "
+ Charset.defaultCharset().displayName() + ", i.e. build is platform dependent!");
}
}

Expand Down
Loading