当前位置: 首页>>代码示例>>Java>>正文


Java ModuleDescriptor.getLicenses方法代码示例

本文整理汇总了Java中org.apache.ivy.core.module.descriptor.ModuleDescriptor.getLicenses方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleDescriptor.getLicenses方法的具体用法?Java ModuleDescriptor.getLicenses怎么用?Java ModuleDescriptor.getLicenses使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ivy.core.module.descriptor.ModuleDescriptor的用法示例。


在下文中一共展示了ModuleDescriptor.getLicenses方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testLicense

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
@Test
public void testLicense() throws Exception {
    ModuleDescriptor md = PomModuleDescriptorParser.getInstance().parseDescriptor(settings,
        getClass().getResource("spring-hibernate3-2.0.2.pom"), false);

    License[] licenses = md.getLicenses();
    assertNotNull(licenses);
    assertEquals(1, licenses.length);
    assertEquals("The Apache Software License, Version 2.0", licenses[0].getName());
    assertEquals("http://www.apache.org/licenses/LICENSE-2.0.txt", licenses[0].getUrl());
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:12,代码来源:PomModuleDescriptorParserTest.java

示例2: testLicenseFromParent

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
 * Tests that if a module doesn't have a license specified, then parent pom's license (if any)
 * is used for the child module
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testLicenseFromParent() throws Exception {
    final IvySettings customIvySettings = createIvySettingsForParentLicenseTesting("test-parent-with-licenses.pom",
            "org.apache", "test-ivy-license-parent");
    final String pomFile = "test-project-with-parent-licenses.pom";
    final ModuleDescriptor childModule = PomModuleDescriptorParser.getInstance().parseDescriptor(customIvySettings,
            this.getClass().getResource(pomFile), false);
    assertNotNull("Could not find " + pomFile, pomFile);
    final License[] licenses = childModule.getLicenses();
    assertNotNull("No licenses found in the module " + childModule, licenses);
    assertEquals("Unexpected number of licenses found in the module " + childModule, 1, licenses.length);
    assertEquals("Unexpected license name", "MIT License", licenses[0].getName());
    assertEquals("Unexpected license URL", "http://opensource.org/licenses/MIT", licenses[0].getUrl());
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:21,代码来源:PomModuleDescriptorParserTest.java

示例3: testOverriddenLicense

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
/**
 * Tests that if a project explicitly specifies the licenses, then the licenses (if any) from
 * its parent pom aren't applied to the child project
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testOverriddenLicense() throws Exception {
    final IvySettings customIvySettings = createIvySettingsForParentLicenseTesting("test-parent-with-licenses.pom",
            "org.apache", "test-ivy-license-parent");
    final String pomFile = "test-project-with-overridden-licenses.pom";
    final ModuleDescriptor childModule = PomModuleDescriptorParser.getInstance().parseDescriptor(customIvySettings,
            this.getClass().getResource(pomFile), false);
    assertNotNull("Could not find " + pomFile, pomFile);
    final License[] licenses = childModule.getLicenses();
    assertNotNull("No licenses found in the module " + childModule, licenses);
    assertEquals("Unexpected number of licenses found in the module " + childModule, 1, licenses.length);
    assertEquals("Unexpected license name", "The Apache Software License, Version 2.0", licenses[0].getName());
    assertEquals("Unexpected license URL", "http://www.apache.org/licenses/LICENSE-2.0.txt", licenses[0].getUrl());
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:21,代码来源:PomModuleDescriptorParserTest.java

示例4: cloneMd

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private DefaultModuleDescriptor cloneMd(ModuleDescriptor md, Artifact af) {

        DefaultModuleDescriptor newMd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
                "release", null, true);
        newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
        newMd.setLastModified(System.currentTimeMillis());

        newMd.setDescription(md.getDescription());
        newMd.setHomePage(md.getHomePage());
        newMd.setLastModified(md.getLastModified());
        newMd.setPublicationDate(md.getPublicationDate());
        newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
        newMd.setStatus(md.getStatus());

        Configuration[] allConfs = md.getConfigurations();
        if (allConfs.length == 0) {
            newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
        } else {
            for (Configuration conf : allConfs) {
                newMd.addConfiguration(conf);
                newMd.addArtifact(conf.getName(), af);
            }
        }

        for (DependencyDescriptor dependency : md.getDependencies()) {
            newMd.addDependency(dependency);
        }

        for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
            newMd.addExcludeRule(excludeRule);
        }

        newMd.getExtraInfos().addAll(md.getExtraInfos());

        for (License license : md.getLicenses()) {
            newMd.addLicense(license);
        }

        return newMd;
    }
 
开发者ID:apache,项目名称:ant-ivyde,代码行数:41,代码来源:WorkspaceResolver.java

示例5: printInfoTag

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private static void printInfoTag(ModuleDescriptor md, PrintWriter out) {
    out.println("\t<info organisation=\""
            + XMLHelper.escape(md.getModuleRevisionId().getOrganisation()) + "\"");
    out.println("\t\tmodule=\"" + XMLHelper.escape(md.getModuleRevisionId().getName()) + "\"");
    String branch = md.getResolvedModuleRevisionId().getBranch();
    if (branch != null) {
        out.println("\t\tbranch=\"" + XMLHelper.escape(branch) + "\"");
    }
    String revision = md.getResolvedModuleRevisionId().getRevision();
    if (revision != null) {
        out.println("\t\trevision=\"" + XMLHelper.escape(revision) + "\"");
    }
    out.println("\t\tstatus=\"" + XMLHelper.escape(md.getStatus()) + "\"");
    out.println("\t\tpublication=\"" + DateUtil.format(md.getResolvedPublicationDate()) + "\"");
    if (md.isDefault()) {
        out.println("\t\tdefault=\"true\"");
    }
    if (md instanceof DefaultModuleDescriptor) {
        DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
        if (dmd.getNamespace() != null && !dmd.getNamespace().getName().equals("system")) {
            out.println("\t\tnamespace=\"" + XMLHelper.escape(dmd.getNamespace().getName())
                    + "\"");
        }
    }
    if (!md.getExtraAttributes().isEmpty()) {
        printExtraAttributes(md, out, "\t\t");
        out.println();
    }
    if (requireInnerInfoElement(md)) {
        out.println("\t>");
        for (ExtendsDescriptor parent : md.getInheritedDescriptors()) {
            ModuleRevisionId mrid = parent.getParentRevisionId();
            out.print(String.format("\t\t<extends organisation=\"%s\" module=\"%s\" revision=\"%s\"",
                    XMLHelper.escape(mrid.getOrganisation()),
                    XMLHelper.escape(mrid.getName()),
                    XMLHelper.escape(mrid.getRevision())));

            String location = parent.getLocation();
            if (location != null) {
                out.print(" location=\"" + XMLHelper.escape(location) + "\"");
            }
            out.print(" extendType=\"" + joinArray(parent.getExtendsTypes(), ",") + "\"");
            out.println("/>");
        }
        License[] licenses = md.getLicenses();
        for (License license : licenses) {
            out.print("\t\t<license ");
            if (license.getName() != null) {
                out.print("name=\"" + XMLHelper.escape(license.getName()) + "\" ");
            }
            if (license.getUrl() != null) {
                out.print("url=\"" + XMLHelper.escape(license.getUrl()) + "\" ");
            }
            out.println("/>");
        }
        if (md.getHomePage() != null || md.getDescription() != null) {
            out.print("\t\t<description");
            if (md.getHomePage() != null) {
                out.print(" homepage=\"" + XMLHelper.escape(md.getHomePage()) + "\"");
            }
            if (isNullOrEmpty(md.getDescription())) {
                out.println(" />");
            } else {
                out.println(">");
                out.println("\t\t" + XMLHelper.escape(md.getDescription()));
                out.println("\t\t</description>");
            }
        }
        for (ExtraInfoHolder extraInfo : md.getExtraInfos()) {
            printExtraInfoElement(out, extraInfo, 2);
        }
        out.println("\t</info>");
    } else {
        out.println("\t/>");
    }

}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:78,代码来源:XmlModuleDescriptorWriter.java

示例6: requireInnerInfoElement

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private static boolean requireInnerInfoElement(ModuleDescriptor md) {
    return md.getExtraInfos().size() > 0 || md.getHomePage() != null
            || !isNullOrEmpty(md.getDescription())
            || md.getLicenses().length > 0 || md.getInheritedDescriptors().length > 0;
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:6,代码来源:XmlModuleDescriptorWriter.java

示例7: outputRevision

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private void outputRevision(ConfigurationResolveReport report, PrintWriter out,
                            List<ModuleRevisionId> dependencies, IvyNode dep) {
    Map<String, String> extraAttributes;
    ModuleDescriptor md = null;
    if (dep.getModuleRevision() != null) {
        md = dep.getModuleRevision().getDescriptor();
    }
    StringBuilder details = new StringBuilder();
    if (dep.isLoaded()) {
        details.append(" status=\"");
        details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
        details.append("\" pubdate=\"");
        details.append(DateUtil.format(new Date(dep.getPublication())));
        details.append("\" resolver=\"");
        details.append(XMLHelper.escape(dep.getModuleRevision().getResolver().getName()));
        details.append("\" artresolver=\"");
        details.append(XMLHelper
                .escape(dep.getModuleRevision().getArtifactResolver().getName()));
        details.append("\"");
    }
    if (dep.isEvicted(report.getConfiguration())) {
        EvictionData ed = dep.getEvictedData(report.getConfiguration());
        if (ed.getConflictManager() != null) {
            details.append(" evicted=\"")
                    .append(XMLHelper.escape(ed.getConflictManager().toString())).append("\"");
        } else {
            details.append(" evicted=\"transitive\"");
        }
        details.append(" evicted-reason=\"")
                .append(XMLHelper.escape(ed.getDetail() == null ? "" : ed.getDetail()))
                .append("\"");
    }
    if (dep.hasProblem()) {
        details.append(" error=\"").append(XMLHelper.escape(dep.getProblem().getMessage()))
                .append("\"");
    }
    if (md != null && md.getHomePage() != null) {
        details.append(" homepage=\"").append(XMLHelper.escape(md.getHomePage())).append("\"");
    }
    extraAttributes = (md != null) ? md.getExtraAttributes() : dep.getResolvedId()
            .getExtraAttributes();
    details.append(extraToString(extraAttributes, SEPARATOR));
    out.println(String.format("\t\t\t<revision name=\"%s\"%s%s downloaded=\"%s\" searched=\"%s\"%s conf=\"%s\" position=\"%d\">",
            XMLHelper.escape(dep.getResolvedId().getRevision()),
            (dep.getResolvedId().getBranch() == null) ? "" : " branch=\""
            + XMLHelper.escape(dep.getResolvedId().getBranch()) + "\"",
            details, dep.isDownloaded(), dep.isSearched(),
            (dep.getDescriptor() == null) ? "" : " default=\""
            + dep.getDescriptor().isDefault() + "\"",
            XMLHelper.escape(joinArray(dep.getConfigurations(report.getConfiguration()), ", ")),
            dependencies.indexOf(dep.getResolvedId())));
    if (md != null) {
        License[] licenses = md.getLicenses();
        for (License license : licenses) {
            out.println(String.format("\t\t\t\t<license name=\"%s\"%s/>",
                    XMLHelper.escape(license.getName()),
                    license.getUrl() == null ? "" : " url=\"" + XMLHelper.escape(license.getUrl()) + "\""));
        }
    }
    outputMetadataArtifact(out, dep);
    outputEvictionInformation(report, out, dep);
    outputCallers(report, out, dep);
    outputArtifacts(report, out, dep);
    out.println("\t\t\t</revision>");
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:66,代码来源:XmlReportWriter.java

示例8: createWorkspaceMd

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
protected WorkspaceModuleDescriptor createWorkspaceMd(ModuleDescriptor md) {
    DefaultWorkspaceModuleDescriptor newMd = new DefaultWorkspaceModuleDescriptor(
            md.getModuleRevisionId(), "release", null, true);
    newMd.addConfiguration(new Configuration(ModuleDescriptor.DEFAULT_CONFIGURATION));
    newMd.setLastModified(System.currentTimeMillis());

    newMd.setDescription(md.getDescription());
    newMd.setHomePage(md.getHomePage());
    newMd.setLastModified(md.getLastModified());
    newMd.setPublicationDate(md.getPublicationDate());
    newMd.setResolvedPublicationDate(md.getResolvedPublicationDate());
    newMd.setStatus(md.getStatus());

    Configuration[] allConfs = md.getConfigurations();
    for (Artifact af : createWorkspaceArtifacts(md)) {
        if (allConfs.length == 0) {
            newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
        } else {
            for (Configuration conf : allConfs) {
                newMd.addConfiguration(conf);
                newMd.addArtifact(conf.getName(), af);
            }
        }
    }

    for (DependencyDescriptor dependency : md.getDependencies()) {
        newMd.addDependency(dependency);
    }

    for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
        newMd.addExcludeRule(excludeRule);
    }

    newMd.getExtraInfos().addAll(md.getExtraInfos());

    for (License license : md.getLicenses()) {
        newMd.addLicense(license);
    }

    return newMd;
}
 
开发者ID:apache,项目名称:ant-ivy,代码行数:42,代码来源:AbstractWorkspaceResolver.java

示例9: ouputRevision

import org.apache.ivy.core.module.descriptor.ModuleDescriptor; //导入方法依赖的package包/类
private void ouputRevision(ConfigurationResolveReport report, PrintWriter out, List<?> dependencies, IvyNode dep) {
    Map<?, ?> extraAttributes;
    ModuleDescriptor md = null;
    if (dep.getModuleRevision() != null) {
        md = dep.getModuleRevision().getDescriptor();
    }
    StringBuilder details = new StringBuilder();
    if (dep.isLoaded()) {
        details.append(" status=\"");
        details.append(XMLHelper.escape(dep.getDescriptor().getStatus()));
        details.append("\" pubdate=\"");
        details.append(DateUtil.format(new Date(dep.getPublication())));
        details.append("\" resolver=\"");
        details.append(XMLHelper.escape(dep.getModuleRevision().getResolver().getName()));
        details.append("\" artresolver=\"");
        details.append(XMLHelper.escape(dep.getModuleRevision().getArtifactResolver().getName()));
        details.append("\"");
    }
    if (dep.isEvicted(report.getConfiguration())) {
        EvictionData ed = dep.getEvictedData(report.getConfiguration());
        if (ed.getConflictManager() != null) {
            details.append(" evicted=\"").append(XMLHelper.escape(ed.getConflictManager().toString())).append("\"");
        } else {
            details.append(" evicted=\"transitive\"");
        }
        details.append(" evicted-reason=\"").append(XMLHelper.escape(ed.getDetail() == null ? "" : ed.getDetail()))
                .append("\"");
    }
    if (dep.hasProblem()) {
        details.append(" error=\"").append(XMLHelper.escape(dep.getProblem().getMessage())).append("\"");
    }
    if (md != null && md.getHomePage() != null) {
        details.append(" homepage=\"").append(XMLHelper.escape(md.getHomePage())).append("\"");
    }
    extraAttributes = md != null ? md.getExtraAttributes() : dep.getResolvedId().getExtraAttributes();
    for (Entry<?, ?> entry1 : extraAttributes.entrySet()) {
        Entry<String, Object> entry = (Entry<String, Object>) entry1;
        details.append(" extra-").append(entry.getKey()).append("=\"")
                .append(XMLHelper.escape(entry.getValue().toString())).append("\"");
    }
    String defaultValue = dep.getDescriptor() != null ? " default=\"" + dep.getDescriptor().isDefault() + "\"" : "";
    int position = dependencies.indexOf(dep.getResolvedId());
    out.println("\t\t\t<revision name=\""
            + XMLHelper.escape(dep.getResolvedId().getRevision())
            + "\""
            + (dep.getResolvedId().getBranch() == null ? "" : " branch=\""
            + XMLHelper.escape(dep.getResolvedId().getBranch()) + "\"") + details + " downloaded=\""
            + dep.isDownloaded() + "\"" + " searched=\"" + dep.isSearched() + "\"" + defaultValue + " conf=\""
            + toString(dep.getConfigurations(report.getConfiguration())) + "\"" + " position=\"" + position + "\">");
    if (md != null) {
        License[] licenses = md.getLicenses();
        for (License license : licenses) {
            String lurl;
            if (license.getUrl() != null) {
                lurl = " url=\"" + XMLHelper.escape(license.getUrl()) + "\"";
            } else {
                lurl = "";
            }
            out.println("\t\t\t\t<license name=\"" + XMLHelper.escape(license.getName()) + "\"" + lurl + "/>");
        }
    }
    outputMetadataArtifact(out, dep);
    outputEvictionInformation(report, out, dep);
    outputCallers(report, out, dep);
    outputArtifacts(report, out, dep);
    out.println("\t\t\t</revision>");
}
 
开发者ID:apache,项目名称:ant-easyant-core,代码行数:68,代码来源:XMLEasyAntReportWriter.java


注:本文中的org.apache.ivy.core.module.descriptor.ModuleDescriptor.getLicenses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。