Search in sources :

Example 1 with MailingList

use of org.apache.maven.model.MailingList in project maven-plugins by apache.

the class PdfMojo method isValidGeneratedReport.

/**
     * Parsing the generated report to see if it is correct or not. Log the error for the user.
     *
     * @param mojoDescriptor not null
     * @param generatedReport not null
     * @param localReportName not null
     * @return <code>true</code> if Doxia is able to parse the generated report, <code>false</code> otherwise.
     * @since 1.1
     */
private boolean isValidGeneratedReport(Artifact pluginArtifact, File generatedReport, String localReportName) {
    SinkAdapter sinkAdapter = new SinkAdapter();
    Reader reader = null;
    try {
        reader = ReaderFactory.newXmlReader(generatedReport);
        doxia.parse(reader, generatedReport.getParentFile().getName(), sinkAdapter);
        reader.close();
        reader = null;
    } catch (ParseException e) {
        StringBuilder sb = new StringBuilder(1024);
        sb.append(EOL).append(EOL);
        sb.append("Error when parsing the generated report: ").append(generatedReport.getAbsolutePath());
        sb.append(EOL);
        sb.append(e.getMessage());
        sb.append(EOL).append(EOL);
        sb.append("You could:").append(EOL);
        sb.append("  * exclude all reports using -DincludeReports=false").append(EOL);
        sb.append("  * remove the ");
        sb.append(pluginArtifact.getGroupId());
        sb.append(":");
        sb.append(pluginArtifact.getArtifactId());
        sb.append(":");
        sb.append(pluginArtifact.getVersion());
        sb.append(" from the <reporting/> part. To not affect the site generation, ");
        sb.append("you could create a PDF profile.").append(EOL);
        sb.append(EOL);
        MavenProject pluginProject = getReportPluginProject(pluginArtifact);
        if (pluginProject == null) {
            sb.append("You could also contact the Plugin team.").append(EOL);
        } else {
            sb.append("You could also contact the Plugin team:").append(EOL);
            if (pluginProject.getMailingLists() != null && !pluginProject.getMailingLists().isEmpty()) {
                boolean appended = false;
                for (Object o : pluginProject.getMailingLists()) {
                    MailingList mailingList = (MailingList) o;
                    if (StringUtils.isNotEmpty(mailingList.getName()) && StringUtils.isNotEmpty(mailingList.getPost())) {
                        if (!appended) {
                            sb.append("  Mailing Lists:").append(EOL);
                            appended = true;
                        }
                        sb.append("    ").append(mailingList.getName());
                        sb.append(": ").append(mailingList.getPost());
                        sb.append(EOL);
                    }
                }
            }
            if (StringUtils.isNotEmpty(pluginProject.getUrl())) {
                sb.append("  Web Site:").append(EOL);
                sb.append("    ").append(pluginProject.getUrl());
                sb.append(EOL);
            }
            if (pluginProject.getIssueManagement() != null && StringUtils.isNotEmpty(pluginProject.getIssueManagement().getUrl())) {
                sb.append("  Issue Tracking:").append(EOL);
                sb.append("    ").append(pluginProject.getIssueManagement().getUrl());
                sb.append(EOL);
            }
        }
        sb.append(EOL).append("Ignoring the \"").append(localReportName).append("\" report in the PDF.").append(EOL);
        getLog().error(sb.toString());
        getLog().debug(e);
        return false;
    } catch (ParserNotFoundException e) {
        getLog().error("ParserNotFoundException: " + e.getMessage());
        getLog().debug(e);
        return false;
    } catch (IOException e) {
        getLog().error("IOException: " + e.getMessage());
        getLog().debug(e);
        return false;
    } finally {
        IOUtil.close(reader);
    }
    return true;
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ParserNotFoundException(org.apache.maven.doxia.parser.manager.ParserNotFoundException) MailingList(org.apache.maven.model.MailingList) XmlStreamReader(org.apache.commons.io.input.XmlStreamReader) Reader(java.io.Reader) DecorationXpp3Reader(org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader) StringReader(java.io.StringReader) ParseException(org.apache.maven.doxia.parser.ParseException) IOException(java.io.IOException) SinkAdapter(org.apache.maven.doxia.sink.impl.SinkAdapter)

Example 2 with MailingList

use of org.apache.maven.model.MailingList in project buck by facebook.

the class Pom method merge.

private Model merge(Model first, @Nullable Model second) {
    if (second == null) {
        return first;
    }
    Model model = first.clone();
    //---- Values from ModelBase
    List<String> modules = second.getModules();
    if (modules != null) {
        for (String module : modules) {
            model.addModule(module);
        }
    }
    DistributionManagement distributionManagement = second.getDistributionManagement();
    if (distributionManagement != null) {
        model.setDistributionManagement(distributionManagement);
    }
    Properties properties = second.getProperties();
    if (properties != null) {
        for (Map.Entry<Object, Object> entry : properties.entrySet()) {
            model.addProperty((String) entry.getKey(), (String) entry.getValue());
        }
    }
    DependencyManagement dependencyManagement = second.getDependencyManagement();
    if (dependencyManagement != null) {
        model.setDependencyManagement(dependencyManagement);
    }
    List<Dependency> dependencies = second.getDependencies();
    if (dependencies != null) {
        for (Dependency dependency : dependencies) {
            model.addDependency(dependency);
        }
    }
    List<Repository> repositories = second.getRepositories();
    if (repositories != null) {
        for (Repository repository : repositories) {
            model.addRepository(repository);
        }
    }
    List<Repository> pluginRepositories = second.getPluginRepositories();
    if (pluginRepositories != null) {
        for (Repository pluginRepository : pluginRepositories) {
            model.addPluginRepository(pluginRepository);
        }
    }
    // Ignore reports, reporting, and locations
    //----- From Model
    Parent parent = second.getParent();
    if (parent != null) {
        model.setParent(parent);
    }
    Organization organization = second.getOrganization();
    if (organization != null) {
        model.setOrganization(organization);
    }
    List<License> licenses = second.getLicenses();
    Set<String> currentLicenseUrls = new HashSet<>();
    if (model.getLicenses() != null) {
        for (License license : model.getLicenses()) {
            currentLicenseUrls.add(license.getUrl());
        }
    }
    if (licenses != null) {
        for (License license : licenses) {
            if (!currentLicenseUrls.contains(license.getUrl())) {
                model.addLicense(license);
                currentLicenseUrls.add(license.getUrl());
            }
        }
    }
    List<Developer> developers = second.getDevelopers();
    Set<String> currentDevelopers = new HashSet<>();
    if (model.getDevelopers() != null) {
        for (Developer developer : model.getDevelopers()) {
            currentDevelopers.add(developer.getName());
        }
    }
    if (developers != null) {
        for (Developer developer : developers) {
            if (!currentDevelopers.contains(developer.getName())) {
                model.addDeveloper(developer);
                currentDevelopers.add(developer.getName());
            }
        }
    }
    List<Contributor> contributors = second.getContributors();
    Set<String> currentContributors = new HashSet<>();
    if (model.getContributors() != null) {
        for (Contributor contributor : model.getContributors()) {
            currentDevelopers.add(contributor.getName());
        }
    }
    if (contributors != null) {
        for (Contributor contributor : contributors) {
            if (!currentContributors.contains(contributor.getName())) {
                model.addContributor(contributor);
                currentContributors.add(contributor.getName());
            }
        }
    }
    List<MailingList> mailingLists = second.getMailingLists();
    if (mailingLists != null) {
        for (MailingList mailingList : mailingLists) {
            model.addMailingList(mailingList);
        }
    }
    Prerequisites prerequisites = second.getPrerequisites();
    if (prerequisites != null) {
        model.setPrerequisites(prerequisites);
    }
    Scm scm = second.getScm();
    if (scm != null) {
        model.setScm(scm);
    }
    String url = second.getUrl();
    if (url != null) {
        model.setUrl(url);
    }
    String description = second.getDescription();
    if (description != null) {
        model.setDescription(description);
    }
    IssueManagement issueManagement = second.getIssueManagement();
    if (issueManagement != null) {
        model.setIssueManagement(issueManagement);
    }
    CiManagement ciManagement = second.getCiManagement();
    if (ciManagement != null) {
        model.setCiManagement(ciManagement);
    }
    Build build = second.getBuild();
    if (build != null) {
        model.setBuild(build);
    }
    List<Profile> profiles = second.getProfiles();
    Set<String> currentProfileIds = new HashSet<>();
    if (model.getProfiles() != null) {
        for (Profile profile : model.getProfiles()) {
            currentProfileIds.add(profile.getId());
        }
    }
    if (profiles != null) {
        for (Profile profile : profiles) {
            if (!currentProfileIds.contains(profile.getId())) {
                model.addProfile(profile);
                currentProfileIds.add(profile.getId());
            }
        }
    }
    return model;
}
Also used : Organization(org.apache.maven.model.Organization) Parent(org.apache.maven.model.Parent) License(org.apache.maven.model.License) MailingList(org.apache.maven.model.MailingList) Developer(org.apache.maven.model.Developer) Contributor(org.apache.maven.model.Contributor) Properties(java.util.Properties) Profile(org.apache.maven.model.Profile) Prerequisites(org.apache.maven.model.Prerequisites) Build(org.apache.maven.model.Build) DependencyManagement(org.apache.maven.model.DependencyManagement) IssueManagement(org.apache.maven.model.IssueManagement) HashSet(java.util.HashSet) Dependency(org.apache.maven.model.Dependency) Repository(org.apache.maven.model.Repository) Model(org.apache.maven.model.Model) CiManagement(org.apache.maven.model.CiManagement) DistributionManagement(org.apache.maven.model.DistributionManagement) Scm(org.apache.maven.model.Scm) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 3 with MailingList

use of org.apache.maven.model.MailingList in project maven-plugins by apache.

the class MavenJDOMWriter method iterateMailingList.

// -- void iterateLicense(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
     * Method iterateMailingList
     *
     * @param counter
     * @param childTag
     * @param parentTag
     * @param list
     * @param parent
     */
protected void iterateMailingList(Counter counter, Element parent, java.util.Collection list, java.lang.String parentTag, java.lang.String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            MailingList value = (MailingList) it.next();
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateMailingList(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Element(org.jdom.Element) Iterator(java.util.Iterator) MailingList(org.apache.maven.model.MailingList)

Example 4 with MailingList

use of org.apache.maven.model.MailingList in project felix by apache.

the class MavenJDOMWriter method iterateMailingList.

// -- void iterateLicense(Counter, Element, java.util.Collection, java.lang.String, java.lang.String)
/**
 * Method iterateMailingList
 *
 * @param counter
 * @param childTag
 * @param parentTag
 * @param list
 * @param parent
 */
protected void iterateMailingList(Counter counter, Element parent, Collection list, String parentTag, String childTag) {
    boolean shouldExist = list != null && list.size() > 0;
    Element element = updateElement(counter, parent, parentTag, shouldExist);
    if (shouldExist) {
        Iterator it = list.iterator();
        Iterator elIt = element.getChildren(childTag, element.getNamespace()).iterator();
        if (!elIt.hasNext()) {
            elIt = null;
        }
        Counter innerCount = new Counter(counter.getDepth() + 1);
        while (it.hasNext()) {
            MailingList value = (MailingList) it.next();
            Element el;
            if (elIt != null && elIt.hasNext()) {
                el = (Element) elIt.next();
                if (!elIt.hasNext()) {
                    elIt = null;
                }
            } else {
                el = factory.element(childTag, element.getNamespace());
                insertAtPreferredLocation(element, el, innerCount);
            }
            updateMailingList(value, childTag, innerCount, el);
            innerCount.increaseCount();
        }
        if (elIt != null) {
            while (elIt.hasNext()) {
                elIt.next();
                elIt.remove();
            }
        }
    }
}
Also used : Element(org.jdom.Element) Iterator(java.util.Iterator) MailingList(org.apache.maven.model.MailingList)

Example 5 with MailingList

use of org.apache.maven.model.MailingList in project archiva by apache.

the class Maven2RepositoryStorage method convertMailingLists.

private List<org.apache.archiva.metadata.model.MailingList> convertMailingLists(List<MailingList> mailingLists) {
    List<org.apache.archiva.metadata.model.MailingList> l = new ArrayList<>();
    for (MailingList mailingList : mailingLists) {
        org.apache.archiva.metadata.model.MailingList newMailingList = new org.apache.archiva.metadata.model.MailingList();
        newMailingList.setName(mailingList.getName());
        newMailingList.setMainArchiveUrl(mailingList.getArchive());
        newMailingList.setPostAddress(mailingList.getPost());
        newMailingList.setSubscribeAddress(mailingList.getSubscribe());
        newMailingList.setUnsubscribeAddress(mailingList.getUnsubscribe());
        newMailingList.setOtherArchives(mailingList.getOtherArchives());
        l.add(newMailingList);
    }
    return l;
}
Also used : MailingList(org.apache.maven.model.MailingList) ArrayList(java.util.ArrayList)

Aggregations

MailingList (org.apache.maven.model.MailingList)7 Element (org.jdom.Element)4 Iterator (java.util.Iterator)3 ImmutableMap (com.google.common.collect.ImmutableMap)1 IOException (java.io.IOException)1 Reader (java.io.Reader)1 StringReader (java.io.StringReader)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ListIterator (java.util.ListIterator)1 Map (java.util.Map)1 Properties (java.util.Properties)1 XmlStreamReader (org.apache.commons.io.input.XmlStreamReader)1 ParseException (org.apache.maven.doxia.parser.ParseException)1 ParserNotFoundException (org.apache.maven.doxia.parser.manager.ParserNotFoundException)1 SinkAdapter (org.apache.maven.doxia.sink.impl.SinkAdapter)1 DecorationXpp3Reader (org.apache.maven.doxia.site.decoration.io.xpp3.DecorationXpp3Reader)1 Build (org.apache.maven.model.Build)1 CiManagement (org.apache.maven.model.CiManagement)1 Contributor (org.apache.maven.model.Contributor)1