private void writeDoapFile()

in src/main/java/org/apache/maven/plugin/doap/DoapMojo.java [487:556]


    private void writeDoapFile(MavenProject project, File outputFile) throws MojoExecutionException {
        // ----------------------------------------------------------------------------
        // Includes ASF extensions
        // ----------------------------------------------------------------------------

        if (!asfExtOptions.isIncluded() && ASFExtOptionsUtil.isASFProject(project)) {
            getLog().info("This project is an ASF project, ASF Extensions to DOAP will be added.");
            asfExtOptions.setIncluded(true);
        }

        // ----------------------------------------------------------------------------
        // setup pretty print xml writer
        // ----------------------------------------------------------------------------

        Writer w;
        try {
            if (!outputFile.getParentFile().exists()) {
                FileUtils.mkdir(outputFile.getParentFile().getAbsolutePath());
            }

            w = WriterFactory.newXmlWriter(outputFile);
        } catch (IOException e) {
            throw new MojoExecutionException("Error creating DOAP file " + outputFile.getAbsolutePath(), e);
        }

        try {
            doWrite(project, outputFile, w);
        } finally {

            try {
                w.close();
            } catch (IOException e) {
                throw new MojoExecutionException("Error when closing the writer.", e);
            }
        }

        if (!messages.getWarnMessages().isEmpty()) {
            for (String warn : messages.getWarnMessages()) {
                getLog().warn(warn);
            }
        }

        if (!messages.getErrorMessages().isEmpty()) {
            getLog().error("");
            for (String error : messages.getErrorMessages()) {
                getLog().error(error);
            }
            getLog().error("");

            if (ASFExtOptionsUtil.isASFProject(project)) {
                getLog().error("For more information about the errors and possible solutions, "
                        + "please read the plugin documentation:");
                getLog().error("http://maven.apache.org/plugins/maven-doap-plugin/usage.html#DOAP_ASF_Configuration");
                throw new MojoExecutionException("The generated DOAP doesn't respect ASF rules, see above.");
            }
        }

        if (validate) {
            List<String> errors = DoapUtil.validate(outputFile);
            if (!errors.isEmpty()) {
                getLog().error("");
                for (String error : errors) {
                    getLog().error(error);
                }
                getLog().error("");

                throw new MojoExecutionException("Error parsing the generated DOAP file, see above.");
            }
        }
    }