org.apache.maven.reporting.MavenReportException Java Examples

The following examples show how to use org.apache.maven.reporting.MavenReportException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractRepairMojo.java    From repairnator with MIT License 6 votes vote down vote up
public List<String> getFailingTests() {
    List<String> result = new ArrayList<>();

    for (MavenProject mavenProject : reactorProjects) {
        File surefireReportsDirectory = getSurefireReportsDirectory(mavenProject);
        SurefireReportParser parser = new SurefireReportParser(Collections.singletonList(surefireReportsDirectory), Locale.ENGLISH, new NullConsoleLogger());

        try {
            List<ReportTestSuite> testSuites = parser.parseXMLReportFiles();
            for (ReportTestSuite reportTestSuite : testSuites) {
                if (reportTestSuite.getNumberOfErrors()+reportTestSuite.getNumberOfFailures() > 0) {
                    result.add(reportTestSuite.getFullClassName());
                }
            }
        } catch (MavenReportException e) {
            e.printStackTrace();;
        }

    }

    return result;
}
 
Example #2
Source File: PropertyUpdatesReport.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
protected void doGenerateReport( Locale locale, Sink sink )
    throws MavenReportException
{
    final Map<Property, PropertyVersions> updateSet;
    try
    {
        updateSet = getHelper().getVersionPropertiesMap( getProject(), properties, includeProperties,
                                                         excludeProperties, autoLinkItems );
    }
    catch ( MojoExecutionException e )
    {
        throw new MavenReportException( e.getMessage(), e );
    }
    PropertyUpdatesRenderer renderer =
        new PropertyUpdatesRenderer( sink, getI18n(), getOutputName(), locale, updateSet );
    renderer.render();
}
 
Example #3
Source File: AbstractVersionsReport.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
public VersionsHelper getHelper()
    throws MavenReportException
{
    if ( helper == null )
    {
        try
        {
            helper = new DefaultVersionsHelper( artifactFactory, artifactResolver, artifactMetadataSource,
                                                remoteArtifactRepositories, remotePluginRepositories,
                                                localRepository, wagonManager, settings, serverId, rulesUri,
                                                getLog(), session, pathTranslator );
        }
        catch ( MojoExecutionException e )
        {
            throw new MavenReportException( e.getMessage(), e );
        }
    }
    return helper;
}
 
Example #4
Source File: AbstractVersionsReport.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
protected void executeReport( Locale locale )
    throws MavenReportException
{
    if ( !skip )
    {
        try
        {
            doGenerateReport( locale, getSink() );
        }
        catch ( MojoExecutionException e )
        {
            throw new MavenReportException( e.getMessage(), e );
        }
    }
}
 
Example #5
Source File: AbstractVersionsReport.java    From versions-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the latest version of the specified artifact that matches the version range.
 *
 * @param artifact The artifact.
 * @param versionRange The version range.
 * @param allowingSnapshots <code>null</code> for no override, otherwise the local override to apply.
 * @param usePluginRepositories Use plugin repositories
 * @return The latest version of the specified artifact that matches the specified version range or
 *         <code>null</code> if no matching version could be found.
 * @throws MavenReportException If the artifact metadata could not be found.
 * @since 1.0-alpha-1
 */
protected ArtifactVersion findLatestVersion( Artifact artifact, VersionRange versionRange,
                                             boolean allowingSnapshots, boolean usePluginRepositories )
    throws MavenReportException
{
    boolean includeSnapshots = this.allowSnapshots;
    if ( allowingSnapshots )
    {
        includeSnapshots = true;
    }
    if ( allowingSnapshots )
    {
        includeSnapshots = false;
    }
    try
    {
        final ArtifactVersions artifactVersions =
            getHelper().lookupArtifactVersions( artifact, usePluginRepositories );
        return artifactVersions.getNewestVersion( versionRange, includeSnapshots );
    }
    catch ( ArtifactMetadataRetrievalException e )
    {
        throw new MavenReportException( e.getMessage(), e );
    }
}
 
Example #6
Source File: SCoverageReportMojo.java    From scoverage-maven-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Generates SCoverage report.
 * 
 * @throws MojoExecutionException if unexpected problem occurs
 */
@Override
public void execute()
    throws MojoExecutionException
{
    if ( !canGenerateReport() )
    {
        getLog().info( "Skipping SCoverage report generation" );
        return;
    }

    try
    {
        RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );
        SiteRendererSink sink = new SiteRendererSink( context );
        Locale locale = Locale.getDefault();
        generate( sink, locale );
    }
    catch ( MavenReportException e )
    {
        String prefix = "An error has occurred in " + getName( Locale.ENGLISH ) + " report generation";
        throw new MojoExecutionException( prefix + ": " + e.getMessage(), e );
    }
}
 
Example #7
Source File: ReportMojo.java    From revapi with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeReport(Locale locale) throws MavenReportException {
    ensureAnalyzed(locale);

    if (skip) {
        return;
    }

    if (oldAPI == null || newAPI == null) {
        getLog().warn("Could not determine the artifacts to compare. If you're comparing the" +
                " currently built version, have you run the package goal?");
        return;
    }

    if (generateSiteReport) {
        Sink sink = getSink();
        ResourceBundle bundle = getBundle(locale);

        ReportTimeReporter reporter =
                analysisResult.getExtensions().getFirstExtension(ReportTimeReporter.class, null);

        startReport(sink, bundle);
        reportBody(reporter, oldAPI, newAPI, sink, bundle);
        endReport(sink);
    }
}
 
Example #8
Source File: AbstractPitAggregationReportMojo.java    From pitest with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeReport(final Locale locale)
    throws MavenReportException {
  try {
    final Collection<MavenProject> allProjects = findDependencies();

    final ReportAggregator.Builder reportAggregationBuilder = ReportAggregator
        .builder();

    for (final MavenProject proj : allProjects) {
      addProjectFiles(reportAggregationBuilder, proj);
    }

    final ReportAggregator reportAggregator = reportAggregationBuilder
        .resultOutputStrategy(new DirectoryResultOutputStrategy(
            getReportsDirectory().getAbsolutePath(),
            new UndatedReportDirCreationStrategy()))
        .build();

    reportAggregator.aggregateReport();
  } catch (final Exception e) {
    throw new MavenReportException(e.getMessage(), e);
  }
}
 
Example #9
Source File: PitReportMojo.java    From pitest with Apache License 2.0 6 votes vote down vote up
@Override
protected void executeReport(Locale locale) throws MavenReportException {
  this.getLog().debug("PitReportMojo - starting");

  if (!this.reportsDirectory.exists()) {
    throw new PitError("could not find reports directory ["
        + this.reportsDirectory + "]");
  }

  if (!this.reportsDirectory.canRead()) {
    throw new PitError("reports directory [" + this.reportsDirectory
        + "] not readable");
  }

  if (!this.reportsDirectory.isDirectory()) {
    throw new PitError("reports directory [" + this.reportsDirectory
        + "] is actually a file, it must be a directory");
  }

  this.reportGenerationManager.generateSiteReport(this
      .buildReportGenerationContext(locale));

  this.getLog().debug("PitReportMojo - ending");
}
 
Example #10
Source File: UnitTestMojo.java    From wisdom with Apache License 2.0 5 votes vote down vote up
private static void computeTestFailureMessageFromReports(StringBuilder message, SurefireReportParser parser)
        throws MavenReportException {
    List<ReportTestSuite> suites = parser.parseXMLReportFiles();
    Map<String, String> summary = parser.getSummary(suites);
    message
            .append(summary.get("totalTests"))
            .append(" tests, ")
            .append(summary.get("totalErrors"))
            .append(" errors, ")
            .append(summary.get("totalFailures"))
            .append(" failures, ")
            .append(summary.get("totalSkipped"))
            .append(" skipped ")
            .append("(executed in ")
            .append(summary.get("totalElapsedTime"))
            .append("s)<br/><ul>");
    for (ReportTestSuite suite : suites) {
        if (suite.getNumberOfErrors() > 0 || suite.getNumberOfFailures() > 0) {
            for (ReportTestCase tc : suite.getTestCases()) {
                if (tc.getFailure() != null
                        && !"skipped".equalsIgnoreCase((String) tc.getFailure().get("message"))) {
                    message
                            .append("<li><em>")
                            .append(tc.getFullName())
                            .append("</em> failed: ")
                            .append(tc.getFailure().get("message"))
                            .append("</li>");
                }
            }
        }
    }
    message.append("</ul>");
}
 
Example #11
Source File: SurefireReporter.java    From testgrid with Apache License 2.0 5 votes vote down vote up
/**
 * Parses the surefire reports and returns a summarized TestResult object.
 *
 * @param testPlan the testplan
 * @return test result
 */
public TestResult getReport(TestPlan testPlan) {
    TestResult testResult = new TestResult();
    try {
        Path filePath = TestGridUtil.getSurefireReportsDir(testPlan);
        final SurefireReportParser surefireReportParser = new SurefireReportParser(
                Collections.singletonList(filePath.toFile()),
                ENGLISH,
                new NullConsoleLogger());
        final List<ReportTestSuite> reportTestSuites = surefireReportParser.parseXMLReportFiles();
        final Map<String, String> summary = surefireReportParser.getSummary(reportTestSuites);
        testResult.totalTests = summary.get("totalTests");
        testResult.totalFailures = summary.get("totalFailures");
        testResult.totalErrors = summary.get("totalErrors");
        testResult.totalSkipped = summary.get("totalSkipped");

        final List<ReportTestCase> failureDetails = surefireReportParser.getFailureDetails(reportTestSuites);
        testResult.failureTests = getTests(failureDetails, ReportTestCase::hasFailure);
        testResult.errorTests = getTests(failureDetails, ReportTestCase::hasError);

        return testResult;
    } catch (MavenReportException e) {
        logger.warn("Error while processing surefire-reports for " + testPlan.getId() + " for infra combination:"
                + " " + testPlan.getInfraParameters() + ". Continuing processing of other test plans", e);
    }

    return testResult;
}
 
Example #12
Source File: UnitTestMojo.java    From wisdom with Apache License 2.0 5 votes vote down vote up
/**
 * Notifies the watcher that a new file is created. It selects and executes the test. Failures and errors are
 * reported in the thrown {@link org.wisdom.maven.WatchingException}.
 *
 * @param file is the file.
 * @return return {@code true}
 * @throws org.wisdom.maven.WatchingException if the test execution failed.
 */
@Override
public boolean fileCreated(File file) throws WatchingException {
    // Check selection policy
    String testParameter = null;
    if (testSelectionPolicy == TestSelectionPolicy.SELECTIVE) {
        // The test selection is done using the -Dtest parameter from surefire
        // We should also take care that the changed file is not a 'test', in that case, we run only this one.
        final String filename = file.getName().substring(0, file.getName().lastIndexOf("."));
        if (filename.startsWith("Test")  || filename.endsWith("Test")  || filename.endsWith("TestCase")) {
            testParameter = filename;
        } else {
            // It's a business class
            // Be aware of #365, the selection must select only unit tests, so the expression should be
            // TestFileName*,*FileNameTest*
            // The *FileNameTestCase case can be ignored (included by the second expression)
            testParameter = "Test" + filename + "*,*" + filename + "Test*";
        }
    }

    try {
        execute(testParameter);
        return true;
    } catch (MojoExecutionException e) {
        getLog().debug("An error occurred while executing Surefire", e);
        // Compute the Watching Exception content.
        StringBuilder message = new StringBuilder();
        SurefireReportParser parser = new SurefireReportParser(ImmutableList.of(reports), Locale.ENGLISH);
        try {
            computeTestFailureMessageFromReports(message, parser);
            throw new WatchingException("Unit Test Failures", message.toString(), file, e);
        } catch (MavenReportException reportException) {
            // Cannot read the reports.
            throw new WatchingException("Unit Test Failures", file, reportException);
        }}
}
 
Example #13
Source File: SCoverageReportMojo.java    From scoverage-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void mkdirs( File directory )
    throws MavenReportException
{
    if ( !directory.exists() && !directory.mkdirs() )
    {
        throw new MavenReportException( String.format( "Cannot create \"%s\" directory ",
                                                       directory.getAbsolutePath() ) );
    }
    else if ( directory.exists() && !directory.isDirectory() )
    {
        throw new MavenReportException( String.format( "Directory \"%s\" exists but is not a directory ",
                                                       directory.getAbsolutePath() ) );
    }
}
 
Example #14
Source File: SCoverageReportMojo.java    From scoverage-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void generateReports()
    throws MavenReportException /*, RuntimeException*/
{
    @SuppressWarnings( "unchecked" )
    List<String> sourceDirs = project.getExecutionProject().getCompileSourceRoots();
    List<File> sourceRoots = new ArrayList<File>( sourceDirs.size() );
    for ( String dir: sourceDirs )
    {
        sourceRoots.add( new File( dir ) );
    }

    mkdirs( outputDirectory );
    mkdirs( xmlOutputDirectory );

    File coverageFile = Serializer.coverageFile( dataDirectory );
    getLog().info( String.format( "Reading scoverage instrumentation [%s]...", coverageFile.getAbsolutePath() ) );
    Coverage coverage = Serializer.deserialize( coverageFile );

    getLog().info( String.format( "Reading scoverage measurements [%s*]...",
                                  new File( dataDirectory, Constants.MeasurementsPrefix() ).getAbsolutePath() ) );
    List<File> measurementFiles = Arrays.asList( IOUtils.findMeasurementFiles( dataDirectory ) );
    scala.collection.Set<Object> measurements = IOUtils.invoked( JavaConverters.asScalaBuffer( measurementFiles ) );
    coverage.apply( measurements );

    getLog().info( "Generating coverage reports..." );
    writeReports( coverage, sourceRoots, xmlOutputDirectory, xmlOutputDirectory, outputDirectory );
    getLog().info( "Coverage reports completed." );
}
 
Example #15
Source File: SCoverageReportMojo.java    From scoverage-maven-plugin with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public boolean canGenerateReport()
{
    if ( !skip && !"pom".equals( project.getPackaging() ) )
    {
        SCoverageForkedLifecycleConfigurator.afterForkedLifecycleExit( project, reactorProjects );
    }

    boolean canGenerateNonAggregatedReport = canGenerateNonAggregatedReport();
    boolean canAttachAggregatedReportToSite = canAttachAggregatedReportToSite();

    boolean result = canGenerateNonAggregatedReport || canAttachAggregatedReportToSite; 

    if ( !result && canGenerateAggregatedReport() )
    {
        // last project, but not top-level one
        // generate here, because 'false' must be returned to Maven in order to avoid adding to this module's site
        try
        {
            generateAggregatedReports();
        }
        catch ( MavenReportException e )
        {
            throw new RuntimeException( e );
        }
    }
    return result;
}
 
Example #16
Source File: AbstractMailetdocsReport.java    From james-project with Apache License 2.0 5 votes vote down vote up
@Override
protected void executeReport(Locale locale) throws MavenReportException {
    
    getLog().info("Executing Mailets/Matchers Report");

    getSink().head();
    getSink().title();
    getSink().text("Mailet and Matchers Reference");
    getSink().title_();
    getSink().head_();

    getSink().body();

    getSink().section1();
    getSink().sectionTitle1();
    getSink().text("Mailets and Matchers Reference");
    getSink().sectionTitle1_();
    getSink().text("Items marked as Experimental are not yet supported by James; however, you can try them.");
    getSink().section1_();
    
    writeDescriptions();

    getSink().body_();

    getSink().flush();
    getSink().close();
}
 
Example #17
Source File: JnlpReportMojo.java    From webstart with MIT License 5 votes vote down vote up
private void copyJnlpFiles()
        throws MavenReportException
{
    if ( !jnlpSourceDirectory.exists() )
    {
        throw new MavenReportException( "jnlpSourceDirectory does not exist" );
    }
    try
    {
        File destinationDirectory = new File( outputDirectory, siteJnlpDirectory );
        List<File> files = FileUtils.getFiles( jnlpSourceDirectory, "**/*", "" );
        for ( File file : files )
        {
            getLog().debug( "Copying " + file + " to " + destinationDirectory );
            String path = file.getAbsolutePath().substring( jnlpSourceDirectory.getAbsolutePath().length() + 1 );
            File destDir = new File( destinationDirectory, path );
            getLog().debug( "Copying " + file + " to " + destDir );
            if ( file.isDirectory() )
            {
                destDir.mkdirs();
            }
            else
            {
                FileUtils.copyFileToDirectory( file, destDir.getParentFile() );
            }
        }
    }
    catch ( IOException e )
    {
        throw new MavenReportException( "Failed to copy jnlp files", e );
    }
}
 
Example #18
Source File: JnlpReportMojo.java    From webstart with MIT License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public void executeReport( Locale locale )
        throws MavenReportException
{
    copyJnlpFiles();
    fillReport( locale );
}
 
Example #19
Source File: ReportAggregateMojo.java    From revapi with Apache License 2.0 4 votes vote down vote up
@Override
protected void executeReport(Locale locale) throws MavenReportException {
    if (skip) {
        return;
    }

    if (!canGenerateReport()) {
        return;
    }

    List<MavenProject> dependents = mavenSession.getProjectDependencyGraph().getDownstreamProjects(project, true);
    Collections.sort(dependents, (a, b) -> {
        String as = a.getArtifact().toString();
        String bs = b.getArtifact().toString();
        return as.compareTo(bs);
    });

    Map<MavenProject, ProjectVersions> projectVersions = dependents.stream().collect(
            Collectors.toMap(Function.identity(), this::getRunConfig));
    projectVersions.put(project, getRunConfig(project));

    ResourceBundle messages = getBundle(locale);
    Sink sink = getSink();

    if (generateSiteReport) {
        startReport(sink, messages);
    }

    try {
        Analyzer topAnalyzer = prepareAnalyzer(null, project, locale, projectVersions.get(project));

        Revapi sharedRevapi = topAnalyzer == null ? null : topAnalyzer.getRevapi();

        for (MavenProject p : dependents) {
            Analyzer projectAnalyzer = prepareAnalyzer(sharedRevapi, p, locale, projectVersions.get(p));
            if (projectAnalyzer != null) {
                try (AnalysisResult res = projectAnalyzer.analyze()) {
                    res.throwIfFailed();

                    ReportTimeReporter reporter =
                            res.getExtensions().getFirstExtension(ReportTimeReporter.class, null);

                    if (generateSiteReport && reporter != null) {
                        reportBody(reporter, projectAnalyzer.getResolvedOldApi(),
                                projectAnalyzer.getResolvedNewApi(), sink, messages);
                    }
                }
            }
        }

        if (generateSiteReport) {
            endReport(sink);
        }
    } catch (Exception e) {
        throw new MavenReportException("Failed to generate the report.", e);
    }
}
 
Example #20
Source File: SCoverageReportMojo.java    From scoverage-maven-plugin with Apache License 2.0 4 votes vote down vote up
private void generateAggregatedReports()
    throws MavenReportException
{
    List<File> scoverageDataDirs = new ArrayList<File>();
    List<File> sourceRoots = new ArrayList<File>();
    MavenProject topLevelModule = null;
    for ( MavenProject module : reactorProjects )
    {
        if ( module.isExecutionRoot() )
        {
            topLevelModule = module;
        }
        else if ( !module.getPackaging().equals( "pom" ) )
        {
            File scoverageDataDir = rebase( dataDirectory, module );
            if ( scoverageDataDir.isDirectory() )
            {
                scoverageDataDirs.add( scoverageDataDir );

                File sourceRootsFile = new File( scoverageDataDir, "source.roots" );
                if ( sourceRootsFile.isFile() )
                {
                    try
                    {
                        BufferedReader r = new BufferedReader( new InputStreamReader(
                                new FileInputStream( sourceRootsFile ), "UTF-8" ) );
                        try
                        {
                            String path = r.readLine();
                            while ( path != null )
                            {
                                sourceRoots.add( new File( path ) );
                                path = r.readLine();
                            }
                        }
                        finally
                        {
                            r.close();
                        }
                    }
                    catch ( IOException e )
                    {
                        throw new MavenReportException( "...", e );
                    }
                }
            }
        }
    }

    /* Empty report must be generated or top-level site will contain invalid link to non-existent Scoverage report
    if ( scoverageDataDirs.isEmpty() )
    {
        getLog().info( "No subproject data to aggregate, skipping SCoverage report generation" );
        return;
    }*/

    if ( getLog().isDebugEnabled() && scoverageDataDirs.size() > 0 )
    {
        getLog().debug( String.format( "Found %d subproject subproject scoverage data directories:",
                scoverageDataDirs.size() ) );
        for ( File dataDir: scoverageDataDirs )
        {
            getLog().debug( String.format( "- %s", dataDir.getAbsolutePath() ) );
        }
    }
    else
    {
        getLog().info( String.format( "Found %d subproject scoverage data directories.",
                scoverageDataDirs.size() ) );
    }

    File topLevelModuleOutputDirectory = rebase( outputDirectory, topLevelModule );
    File topLevelModuleXmlOutputDirectory = rebase( xmlOutputDirectory, topLevelModule );

    mkdirs( topLevelModuleOutputDirectory );
    mkdirs( topLevelModuleXmlOutputDirectory );

    Coverage coverage =
        CoverageAggregator.aggregatedCoverage( JavaConverters.asScalaBuffer( scoverageDataDirs ).toSeq() );

    getLog().info( "Generating coverage aggregated reports..." );
    writeReports( coverage, sourceRoots, topLevelModuleXmlOutputDirectory, topLevelModuleXmlOutputDirectory,
                  topLevelModuleOutputDirectory );
    getLog().info( "Coverage aggregated reports completed." );
}
 
Example #21
Source File: AjcReportMojo.java    From aspectj-maven-plugin with MIT License 4 votes vote down vote up
/**
 * Executes this ajdoc-report generation.
 */
@SuppressWarnings( "unchecked" )
protected void executeReport( Locale locale )
    throws MavenReportException
{
    getLog().info( "Starting generating ajdoc" );

    project.getCompileSourceRoots().add( basedir.getAbsolutePath() + "/" + aspectDirectory );
    project.getTestCompileSourceRoots().add( basedir.getAbsolutePath() + "/" + testAspectDirectory );

    List<String> arguments = new ArrayList<String>();
    // Add classpath
    arguments.add( "-classpath" );
    arguments.add( AjcHelper.createClassPath( project, pluginArtifacts, getClasspathDirectories() ) );

    arguments.addAll( ajcOptions );

    Set<String> includes;
    try
    {
        if ( null != ajdtBuildDefFile )
        {
            includes = AjcHelper.getBuildFilesForAjdtFile( ajdtBuildDefFile, basedir );
        }
        else
        {
            includes = AjcHelper.getBuildFilesForSourceDirs( getSourceDirectories(), this.includes, this.excludes );
        }
    }
    catch ( MojoExecutionException e )
    {
        throw new MavenReportException( "AspectJ Report failed", e );
    }

    // add target dir argument
    arguments.add( "-d" );
    arguments.add( StringUtils.replace( getOutputDirectory(), "//", "/" ) );

    arguments.addAll( includes );

    if ( getLog().isDebugEnabled() )
    {
        StringBuilder command = new StringBuilder( "Running : ajdoc " );
        for ( String argument : arguments )
        {
            command.append( ' ' ).append( argument );
        }
        getLog().debug( command );
    }

    // There seems to be a difference in classloading when calling 'mvn site' or 'mvn aspectj:aspectj-report'.
    // When calling mvn site, without the contextClassLoader set, you might see the next message:
    // javadoc: error - Cannot find doclet class com.sun.tools.doclets.standard.Standard
    ClassLoader oldContextClassLoader = Thread.currentThread().getContextClassLoader();
    try
    {
        Thread.currentThread().setContextClassLoader( this.getClass().getClassLoader() );

        // MASPECTJ-11: Make the ajdoc use the ${project.build.directory} directory for its intermediate folder.
        // The argument should be the absolute path to the parent directory of the "ajdocworkingdir" folder.
        Main.setOutputWorkingDir( buildDirectory.getAbsolutePath() );

        // Now produce the JavaDoc.
        Main.main( (String[]) arguments.toArray( new String[0] ) );
    }
    finally
    {
        Thread.currentThread().setContextClassLoader( oldContextClassLoader );
    }

}
 
Example #22
Source File: PluginUpdatesReport.java    From versions-maven-plugin with Apache License 2.0 4 votes vote down vote up
/**
 * generates an empty report in case there are no sources to generate a report with
 *
 * @param locale the locale to generate the report for.
 * @param sink the report formatting tool
 */
protected void doGenerateReport( Locale locale, Sink sink )
    throws MavenReportException
{
    Set<Plugin> pluginManagement = new TreeSet<>( new PluginComparator() );
    if ( haveBuildPluginManagementPlugins() )
    {
        pluginManagement.addAll( getProject().getBuild().getPluginManagement().getPlugins() );
    }

    Set<Plugin> plugins = new TreeSet<>( new PluginComparator() );
    if ( haveBuildPlugins() )
    {
        plugins.addAll( getProject().getBuild().getPlugins() );
    }

    plugins = removePluginManagment( plugins, pluginManagement );

    try
    {
        Map<Plugin, PluginUpdatesDetails> pluginUpdates =
            getHelper().lookupPluginsUpdates( plugins, getAllowSnapshots() );
        Map<Plugin, PluginUpdatesDetails> pluginManagementUpdates =
            getHelper().lookupPluginsUpdates( pluginManagement, getAllowSnapshots() );
        for ( String format : formats )
        {
            if ( "html".equals( format ) )
            {
                PluginUpdatesRenderer renderer =
                    new PluginUpdatesRenderer( sink, getI18n(), getOutputName(), locale, pluginUpdates,
                                               pluginManagementUpdates );
                renderer.render();
            }
            else if ( "xml".equals( format ) )
            {
                File outputDir = new File(getProject().getBuild().getDirectory());
                if (!outputDir.exists())
                {
                    outputDir.mkdirs();
                }
                String outputFile =
                    outputDir.getAbsolutePath() + File.separator + getOutputName() + ".xml";
                PluginUpdatesXmlRenderer xmlGenerator =
                    new PluginUpdatesXmlRenderer( pluginUpdates, pluginManagementUpdates, outputFile );
                xmlGenerator.render();
            }
        }
    }
    catch ( InvalidVersionSpecificationException | ArtifactMetadataRetrievalException e )
    {
        throw new MavenReportException( e.getMessage(), e );
    }
}
 
Example #23
Source File: AbstractVersionsReport.java    From versions-maven-plugin with Apache License 2.0 2 votes vote down vote up
/**
 * generates the report.
 *
 * @param locale the locale to generate the report for.
 * @param sink the report formatting tool.
 * @throws MavenReportException when things go wrong.
 * @throws MojoExecutionException if something goes wrong.
 */
protected abstract void doGenerateReport( Locale locale, Sink sink )
    throws MavenReportException, MojoExecutionException;