/** * Default constructor. * * @param log the Maven logger to use. * @param project the Maven project. * @param reportRelDir the project's relative path within the project. * @throws IllegalArgumentException if <code>project</code> is * <code>null</code> or <code>reportRelDir</code> is * <code>null</code> or contains only whitespaces. */ public MavenExternalReportFactory(final Log log, final MavenProject project, final String reportRelDir) throws IllegalArgumentException { checkArguments(project, reportRelDir); this.log = log; this.project = project; this.upPath = PathUtils.getUpPath(reportRelDir); }
private static String getPathFragment(final String relativePathBase) { return isNotCurrentDir(relativePathBase) ? relativePathBase + '/' : ""; }
/** * {@inheritDoc} * <p> * Configures the plugin logger. * </p> * * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ @Override protected void executeReport(final Locale locale) throws MavenReportException { super.executeReport(locale); final ExternalReportFactory factory = new MavenExternalReportFactory(project, ""); reports = new ExternalReportReferences(factory); addJxrReports(); addJavadocReports(); addSurefireReport(); addCoberturaReport(); if (presentJUnitReport) { junitManager = new DirectoryJUnitTestCaseManager(junitReportLocation); } }
private String createRelativeReportLocationLink(final ReportId reportId, final LinkConstructorStrategy strategy) { final LinkConstructorStrategyConfig config = strategy.getConfig(); final File reportLocation = config.getReportLocation(); final String reportArtifactId = reportId.getReportArtifactId(); final String location; if (reportLocation.exists() || isReportPluginRegistered(reportArtifactId)) { location = calcRelativePath(reportLocation); } else { location = null; if (log != null && log.isWarnEnabled()) { log.warn("Cannot locate report of '" + reportArtifactId + "'. Disabling references to that report."); } } return location; }
/** * {@inheritDoc} */ public ExternalReport createExternalReport(final ReportId reportId, final LinkConstructorStrategy strategy) { if (reportId == null) { throw new IllegalArgumentException("The report ID is required."); } if (strategy == null) { throw new IllegalArgumentException( "The link construction strategy is required."); } final String reportBasePath = createRelativeReportLocationLink(reportId, strategy); if (reportBasePath != null) { return new ExternalReport(reportId, reportBasePath, strategy); } else { return null; } }
private String calcRelativePath(final File reportLocation) { final String reportBaseDir = project.getReporting().getOutputDirectory(); final String reportLocationAbsolutePath = reportLocation.getAbsolutePath(); final String relativePathBase; if (reportLocationAbsolutePath.contains("..")) { relativePathBase = ".."; // Fix for BUG 622: Referencing Aggregate Reports } else { relativePathBase = PathTool.getRelativePath(reportBaseDir, reportLocationAbsolutePath); } final String relativePath = upPath + '/' + (getPathFragment(relativePathBase)) + reportLocation.getName(); return relativePath; }
/** * {@inheritDoc} * <p> * Configures the plugin logger. * </p> * * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale) */ @Override protected void executeReport(final Locale locale) throws MavenReportException { super.executeReport(locale); final ExternalReportFactory factory = new MavenExternalReportFactory(project, ""); reports = new ExternalReportReferences(factory); addJxrReports(); addJavadocReports(); addSurefireReport(); addCoberturaReport(); if (presentJUnitReport) { junitManager = new DirectoryJUnitTestCaseManager(junitReportLocation); } }