Example usage for org.apache.maven.project MavenProject getReporting

List of usage examples for org.apache.maven.project MavenProject getReporting

Introduction

In this page you can find the example usage for org.apache.maven.project MavenProject getReporting.

Prototype

@Deprecated
    public Reporting getReporting() 

Source Link

Usage

From source file:com.xebia.mojo.dashboard.reports.HtmlFileXPathReport.java

License:Apache License

/** {@inheritDoc} */
protected File getReportingPath(MavenProject project) {
    //return new File(project.getBasedir(), project.getReporting().getOutputDirectory());
    return new File(project.getReporting().getOutputDirectory());
}

From source file:hudson.gridmaven.reporters.ReportCollector.java

License:Open Source License

public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener,
        Throwable error) throws InterruptedException, IOException {
    if (!(mojo.mojo instanceof MavenReport))
        return true; // not a maven report

    MavenReport report = (MavenReport) mojo.mojo;

    String reportPath = report.getReportOutputDirectory().getPath();
    String projectReportPath = pom.getReporting().getOutputDirectory();
    if (!reportPath.startsWith(projectReportPath)) {
        // report is placed outside site. Can't record it.
        listener.getLogger().println(Messages.ReportCollector_OutsideSite(reportPath, projectReportPath));
        return true;
    }/*ww w  .j ava 2  s  .  co m*/

    if (action == null)
        action = new ReportAction();

    // this is the entry point to the report
    File top = new File(report.getReportOutputDirectory(), report.getOutputName() + ".html");
    String relPath = top.getPath().substring(projectReportPath.length());

    action.add(new ReportAction.Entry(relPath, report.getName(Locale.getDefault())));

    return true;
}

From source file:org.mybatis.maven.mvnmigrate.report.StatusCommandReportMojo.java

License:Apache License

/** {@inheritDoc} */
@Override//from  w ww  . j a v a  2  s.  co  m
protected void executeReport(Locale locale) throws MavenReportException {
    if (aggregate && !project.isExecutionRoot()) {
        return;
    }

    if (skip && !aggregate) {
        if (this.getLog().isInfoEnabled()) {
            this.getLog().info(getBundle(locale).getString("migration.status.report.skipped"));
        }
        return;
    }

    // Step 0: Checking pom availability
    if ("pom".equals(this.project.getPackaging()) && !aggregate) {
        if (this.getLog().isInfoEnabled()) {
            this.getLog().info("migration.status.report.skipped.pom");
        }
        return;
    }

    if (this.outputDirectory == null || !this.outputDirectory.exists()) {
        if (this.getLog().isInfoEnabled()) {
            this.getLog().info(getBundle(locale)
                    .getString(getBundle(locale).getString("migration.status.report.skipped.no.target")));
        }
        return;
    }

    Map<MavenProject, List<Change>> aggregateReport = new HashMap<MavenProject, List<Change>>();

    for (MavenProject mavenProject : reactorProjects) {

        @SuppressWarnings("unchecked")
        Map<String, ReportPlugin> reportPluginMap = mavenProject.getReporting().getReportPluginsAsMap();
        ReportPlugin plug = reportPluginMap.get(getBundle(locale).getString("migration.plugin.key"));

        Xpp3Dom configurationDom = (Xpp3Dom) plug.getConfiguration();

        File reactorRepo = DEFAULT_REPO;
        String reactorEnv = DEFAULT_ENVIRONMENT;
        boolean reactorForce = DEFAULT_FORCE;
        boolean skipStatusCommand = false;

        for (int i = 0; i < configurationDom.getChildCount(); i++) {
            Xpp3Dom child = configurationDom.getChild(i);
            if ("repository".equalsIgnoreCase(child.getName())) {
                reactorRepo = new File(child.getValue());
            } else if ("environment".equalsIgnoreCase(child.getName())) {
                reactorEnv = child.getValue();
            } else if ("force".equalsIgnoreCase(child.getName())) {
                reactorForce = Boolean.valueOf(child.getValue());
            } else if ("skip".equalsIgnoreCase(child.getName())) {
                skipStatusCommand = Boolean.valueOf(child.getValue());
            }
        }

        if (skipStatusCommand) {
            continue;
        }

        final SelectedOptions options = new SelectedOptions();
        options.getPaths().setBasePath(reactorRepo);
        options.setEnvironment(reactorEnv);
        options.setForce(reactorForce);

        StatusCommand analyzer = new StatusCommand(options);
        try {
            analyzer.execute();
            StatusOperation operation = analyzer.getOperation();
            List<Change> analysis = operation.getCurrentStatus();

            aggregateReport.put(mavenProject, analysis);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new MavenReportException(getBundle(locale).getString("migration.status.report.error"), e);
        }
    }

    // Step 2: Create sink and bundle
    Sink sink = getSink();
    ResourceBundle bundle = getBundle(locale);

    // Step 3: Generate the report
    MigrationStatusReportView view = new MigrationStatusReportView();
    view.generateReport(aggregateReport, sink, bundle, aggregate);
}

From source file:org.opennms.maven.plugins.tgz.AbstractAssemblyMojo.java

License:Apache License

private void processModules(Archiver archiver, List moduleSets, boolean includeBaseDirectory)
        throws MojoFailureException, MojoExecutionException {
    for (Iterator i = moduleSets.iterator(); i.hasNext();) {
        ModuleSet moduleSet = (ModuleSet) i.next();

        AndArtifactFilter filter = new AndArtifactFilter();

        if (!moduleSet.getIncludes().isEmpty()) {
            filter.add(new AssemblyIncludesArtifactFilter(moduleSet.getIncludes()));
        }//  w ww .ja v a2 s. co m
        if (!moduleSet.getExcludes().isEmpty()) {
            filter.add(new AssemblyExcludesArtifactFilter(moduleSet.getExcludes()));
        }

        Set set = getModulesFromReactor(getExecutedProject());

        List moduleFileSets = new ArrayList();

        for (Iterator j = set.iterator(); j.hasNext();) {
            MavenProject moduleProject = (MavenProject) j.next();

            if (filter.include(moduleProject.getArtifact())) {
                String name = moduleProject.getBuild().getFinalName();

                ModuleSources sources = moduleSet.getSources();

                if (sources != null) {
                    String output = sources.getOutputDirectory();
                    output = getOutputDirectory(output, moduleProject, includeBaseDirectory);

                    FileSet moduleFileSet = new FileSet();

                    moduleFileSet.setDirectory(moduleProject.getBasedir().getAbsolutePath());
                    moduleFileSet.setOutputDirectory(output);

                    List excludesList = new ArrayList();
                    excludesList.add(PathUtils.toRelative(moduleProject.getBasedir(),
                            moduleProject.getBuild().getDirectory()) + "/**");
                    excludesList.add(PathUtils.toRelative(moduleProject.getBasedir(),
                            moduleProject.getBuild().getOutputDirectory()) + "/**");
                    excludesList.add(PathUtils.toRelative(moduleProject.getBasedir(),
                            moduleProject.getBuild().getTestOutputDirectory()) + "/**");
                    excludesList.add(PathUtils.toRelative(moduleProject.getBasedir(),
                            moduleProject.getReporting().getOutputDirectory()) + "/**");
                    moduleFileSet.setExcludes(excludesList);

                    moduleFileSets.add(moduleFileSet);
                }

                ModuleBinaries binaries = moduleSet.getBinaries();

                if (binaries != null) {
                    Artifact artifact = moduleProject.getArtifact();

                    if (artifact.getFile() == null) {
                        throw new MojoExecutionException("Included module: " + moduleProject.getId()
                                + " does not have an artifact with a file. Please ensure the package phase is run before the assembly is generated.");
                    }

                    String output = binaries.getOutputDirectory();
                    output = getOutputDirectory(output, moduleProject, includeBaseDirectory);

                    archiver.setDefaultDirectoryMode(Integer.parseInt(binaries.getDirectoryMode(), 8));

                    archiver.setDefaultFileMode(Integer.parseInt(binaries.getFileMode(), 8));

                    getLog().debug("ModuleSet[" + output + "]" + " dir perms: "
                            + Integer.toString(archiver.getDefaultDirectoryMode(), 8) + " file perms: "
                            + Integer.toString(archiver.getDefaultFileMode(), 8));

                    if (binaries.isUnpack()) {
                        // TODO: something like zipfileset in plexus-archiver
                        //                        archiver.addJar(  )

                        // TODO refactor into the AbstractUnpackMojo
                        File tempLocation = new File(workDirectory, name);
                        boolean process = false;
                        if (!tempLocation.exists()) {
                            tempLocation.mkdirs();
                            process = true;
                        } else if (artifact.getFile().lastModified() > tempLocation.lastModified()) {
                            process = true;
                        }

                        if (process) {
                            try {
                                unpack(artifact.getFile(), tempLocation);

                                if (binaries.isIncludeDependencies()) {
                                    Set artifactSet = moduleProject.getArtifacts();

                                    for (Iterator artifacts = artifactSet.iterator(); artifacts.hasNext();) {
                                        Artifact dependencyArtifact = (Artifact) artifacts.next();

                                        unpack(dependencyArtifact.getFile(), tempLocation);
                                    }
                                }
                            } catch (NoSuchArchiverException e) {
                                throw new MojoExecutionException(
                                        "Unable to obtain unarchiver: " + e.getMessage(), e);
                            }

                            /*
                            * If the assembly is 'jar-with-dependencies', remove the security files in all dependencies
                            * that will prevent the uberjar to execute.  Please see MASSEMBLY-64 for details.
                            */
                            if (archiver instanceof JarArchiver) {
                                String[] securityFiles = { "*.RSA", "*.DSA", "*.SF", "*.rsa", "*.dsa", "*.sf" };
                                org.apache.maven.shared.model.fileset.FileSet securityFileSet = new org.apache.maven.shared.model.fileset.FileSet();
                                securityFileSet.setDirectory(tempLocation.getAbsolutePath() + "/META-INF/");

                                for (int sfsi = 0; sfsi < securityFiles.length; sfsi++) {
                                    securityFileSet.addInclude(securityFiles[sfsi]);
                                }

                                FileSetManager fsm = new FileSetManager(getLog());
                                try {
                                    fsm.delete(securityFileSet);
                                } catch (IOException e) {
                                    throw new MojoExecutionException(
                                            "Failed to delete security files: " + e.getMessage(), e);
                                }
                            }
                        }

                        addDirectory(archiver, tempLocation, output, null,
                                FileUtils.getDefaultExcludesAsList());
                    } else {
                        try {
                            String outputFileNameMapping = binaries.getOutputFileNameMapping();

                            archiver.addFile(artifact.getFile(),
                                    output + evaluateFileNameMapping(artifact, outputFileNameMapping));

                            if (binaries.isIncludeDependencies()) {
                                Set artifactSet = moduleProject.getArtifacts();

                                for (Iterator artifacts = artifactSet.iterator(); artifacts.hasNext();) {
                                    Artifact dependencyArtifact = (Artifact) artifacts.next();

                                    archiver.addFile(dependencyArtifact.getFile(),
                                            output + evaluateFileNameMapping(dependencyArtifact,
                                                    outputFileNameMapping));
                                }
                            }
                        } catch (ArchiverException e) {
                            throw new MojoExecutionException("Error adding file to archive: " + e.getMessage(),
                                    e);
                        }
                    }
                }

            } else {
                // would be better to have a way to find out when a specified include or exclude
                // is never triggered and warn() it.
                getLog().debug("module: " + moduleProject.getId() + " not included");
            }

            if (!moduleFileSets.isEmpty()) {
                // TODO: includes and excludes
                processFileSets(archiver, moduleFileSets, includeBaseDirectory);
            }
        }
    }
}

From source file:org_scala_tools_maven.ScalaDocMojo.java

License:Apache License

@SuppressWarnings("unchecked")
protected void aggregate(MavenProject parent) throws Exception {
    List<MavenProject> modules = parent.getCollectedProjects();
    File dest = new File(parent.getReporting().getOutputDirectory() + "/" + outputDirectory);
    getLog().info("start aggregation into " + dest);
    StringBuilder mpath = new StringBuilder();
    for (MavenProject module : modules) {
        if ("pom".equals(module.getPackaging().toLowerCase())) {
            continue;
        }//w w  w  . j  a v  a  2  s  .  c o m
        if (aggregateDirectOnly && module.getParent() != parent) {
            continue;
        }
        File subScaladocPath = new File(module.getReporting().getOutputDirectory() + "/" + outputDirectory)
                .getAbsoluteFile();
        //System.out.println(" -> " + project.getModulePathAdjustment(module)  +" // " + subScaladocPath + " // " + module.getBasedir() );
        if (subScaladocPath.exists()) {
            mpath.append(subScaladocPath).append(File.pathSeparatorChar);
        }
    }
    if (mpath.length() != 0) {
        getLog().info("aggregate vscaladoc from : " + mpath);
        JavaMainCaller jcmd = getScalaCommand();
        jcmd.addOption("-d", dest.getAbsolutePath());
        jcmd.addOption("-aggregate", mpath.toString());
        jcmd.run(displayCmd);
    } else {
        getLog().warn("no vscaladoc to aggregate");
    }
    tryAggregateUpper(parent);
}