Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace deprecated methods #198

Merged
merged 7 commits into from
Jul 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
import org.apache.maven.reporting.exec.MavenReportExecution;
import org.apache.maven.reporting.exec.MavenReportExecutor;
import org.apache.maven.reporting.exec.MavenReportExecutorRequest;
import org.apache.maven.shared.utils.WriterFactory;
import org.codehaus.plexus.util.ReaderFactory;

import static org.apache.maven.shared.utils.logging.MessageUtils.buffer;
Expand Down Expand Up @@ -195,7 +194,7 @@ protected String getInputEncoding() {
* @return The effective reporting output file encoding, never <code>null</code>.
*/
protected String getOutputEncoding() {
return (outputEncoding == null) ? WriterFactory.UTF_8 : outputEncoding;
return outputEncoding == null ? "UTF-8" : outputEncoding;
}

/**
Expand Down Expand Up @@ -295,7 +294,7 @@ protected SiteRenderingContext createSiteRenderingContext(Locale locale)

getLog().info(buffer().a("Rendering content with ")
.strong(skinArtifact.getId() + " skin")
.toString());
.build());

context = siteRenderer.createContextForSkin(
skinArtifact, templateProperties, siteModel, project.getName(), locale);
Expand Down Expand Up @@ -355,7 +354,7 @@ protected Map<String, MavenReport> locateReports(
for (MavenReportExecution mavenReportExecution : reports) {
MavenReport report = mavenReportExecution.getMavenReport();

String outputName = report.getOutputName();
String outputName = report.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
String filename = outputName + ".html";

// Always add the report to the menu, see MSITE-150
Expand Down Expand Up @@ -460,7 +459,7 @@ protected Map<String, DocumentRenderer> locateDocuments(
DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());

String filename = docRenderer.getOutputName();
String filename = docRenderer.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
if (!documents.containsKey(filename)) {
documents.put(filename, docRenderer);
} else {
Expand All @@ -483,7 +482,7 @@ protected Map<String, DocumentRenderer> locateDocuments(
DocumentRenderer docRenderer = new CategorySummaryDocumentRenderer(
subMojoExecution, docRenderingContext, title, desc1, desc2, i18n, categoryReports, getLog());

String filename = docRenderer.getOutputName();
String filename = docRenderer.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
if (!documents.containsKey(filename)) {
documents.put(filename, docRenderer);
} else {
Expand All @@ -502,7 +501,7 @@ protected Map<String, DocumentRenderer> locateDocuments(
DocumentRenderer docRenderer = new SitemapDocumentRenderer(
subMojoExecution, docRenderingContext, title, context.getSiteModel(), i18n, getLog());

String filename = docRenderer.getOutputName();
String filename = docRenderer.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
if (!documents.containsKey(filename)) {
documents.put(filename, docRenderer);
} else {
Expand Down Expand Up @@ -533,7 +532,7 @@ private void populateItemRefs(List<MenuItem> items, Locale locale, Map<String, M
}

if (item.getHref() == null || item.getHref().length() == 0) {
item.setHref(report.getOutputName() + ".html");
item.setHref(report.getOutputPath() + ".html");
michael-o marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
getLog().warn("Unrecognised reference: '" + item.getRef() + "'");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public CategorySummaryDocumentRenderer(
this.log = log;
}

@Override
public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderingContext siteRenderingContext)
throws RendererException, IOException {
String msg = "Generating \"" + buffer().strong(title) + "\" report";
Expand Down Expand Up @@ -149,7 +150,7 @@ public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderi
for (MavenReport report : categoryReports) {
sink.tableRow();
sink.tableCell();
sink.link(report.getOutputName() + ".html");
sink.link(report.getOutputPath() + ".html");
michael-o marked this conversation as resolved.
Show resolved Hide resolved
sink.text(report.getName(locale));
sink.link_();
sink.tableCell_();
Expand Down Expand Up @@ -177,18 +178,22 @@ public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderi
siteRenderer.mergeDocumentIntoSite(writer, sink, siteRenderingContext);
}

@Override
public String getOutputName() {
return docRenderingContext.getOutputName();
return docRenderingContext.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public DocumentRenderingContext getRenderingContext() {
return docRenderingContext;
}

@Override
public boolean isOverwrite() {
return true;
}

@Override
public boolean isExternalReport() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderi

@Override
public String getOutputName() {
return docRenderingContext.getOutputName();
return docRenderingContext.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public class SiteMojo extends AbstractSiteRenderingMojo {
/**
* {@inheritDoc}
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("maven.site.skip = true: Skipping site generation");
Expand All @@ -104,7 +105,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
(!locale.equals(SiteTool.DEFAULT_LOCALE)
? "locale '" + locale + "'"
: "default locale"))
.toString());
.build());
File outputDirectory = getOutputDirectory(locale);
List<MavenReportExecution> reports =
generateReports ? getReports(outputDirectory) : Collections.emptyList();
Expand Down Expand Up @@ -209,7 +210,7 @@ private List<DocumentRenderer> renderDoxiaDocuments(
mb.strong(entry.getValue() + " " + entry.getKey());
}

getLog().info(mb.toString());
getLog().info(mb.build());

siteRenderer.render(doxiaDocuments, context, outputDirectory);
}
Expand All @@ -231,7 +232,7 @@ private List<DocumentRenderer> renderDoxiaDocuments(
mb.strong(entry.getValue() + " " + entry.getKey());
}

getLog().info(mb.toString());
getLog().info(mb.build());

siteRenderer.render(generatedDoxiaDocuments, context, outputDirectory);
}
Expand Down Expand Up @@ -275,7 +276,7 @@ private void renderNonDoxiaDocuments(
mb.a("Rendering ");
mb.strong(count + " " + type + " document" + (count > 1 ? "s" : ""));

getLog().info(mb.toString());
getLog().info(mb.build());
}

siteRenderer.render(documents, context, outputDirectory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public SitemapDocumentRenderer(
this.log = log;
}

@Override
public void renderDocument(Writer writer, SiteRenderer siteRenderer, SiteRenderingContext siteRenderingContext)
throws RendererException, IOException {
Locale locale = siteRenderingContext.getLocale();
Expand Down Expand Up @@ -162,18 +163,22 @@ private static String relativePath(String href) {
return href.startsWith("/") ? "." + href : href;
}

@Override
public String getOutputName() {
return docRenderingContext.getOutputName();
return docRenderingContext.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
public DocumentRenderingContext getRenderingContext() {
return docRenderingContext;
}

@Override
public boolean isOverwrite() {
return true;
}

@Override
public boolean isExternalReport() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class DoxiaFilter implements Filter {
/**
* @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
*/
@Override
public void init(FilterConfig filterConfig) throws ServletException {
servletContext = filterConfig.getServletContext();

Expand All @@ -89,6 +90,7 @@ public void init(FilterConfig filterConfig) throws ServletException {
/**
* @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest, javax.servlet.ServletResponse, javax.servlet.FilterChain)
*/
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
throws IOException, ServletException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
Expand Down Expand Up @@ -139,7 +141,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
try {
DocumentRenderer docRenderer = documents.get(path);
logDocumentRenderer(path, localeWanted, docRenderer);
String outputName = docRenderer.getOutputName();
String outputName = docRenderer.getOutputPath();
michael-o marked this conversation as resolved.
Show resolved Hide resolved
String contentType = MimeTypes.getDefaultMimeByExtension(outputName);
if (contentType != null) {
servletResponse.setContentType(contentType);
Expand Down Expand Up @@ -194,5 +196,6 @@ private void logDocumentRenderer(String path, String locale, DocumentRenderer do
/**
* @see javax.servlet.Filter#destroy()
*/
@Override
public void destroy() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class SiteRunMojo extends AbstractSiteRenderingMojo {
/**
* @see org.apache.maven.plugin.AbstractMojo#execute()
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
checkInputEncoding();

Expand All @@ -91,7 +92,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoExecutionException("Error executing Jetty", e);
}

getLog().info(buffer().a("Started Jetty on ").strong(server.getURI()).toString());
getLog().info(buffer().a("Started Jetty on ").strong(server.getURI()).build());

// Watch it
try {
Expand Down