Package org.apache.ivy.core.module.descriptor

Examples of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor


        String rev = (String) md.getExtraInfo().get(
            BundleInfoAdapter.EXTRA_INFO_EXPORT_PREFIX + name);
        ModuleRevisionId capabilityRev = ModuleRevisionId.newInstance(org, name, rev,
            Collections.singletonMap(CAPABILITY_EXTRA_ATTR, md.getModuleRevisionId().toString()));

        DefaultModuleDescriptor capabilityMd = new DefaultModuleDescriptor(capabilityRev,
                getSettings().getStatusManager().getDefaultStatus(), new Date());

        String useConf = BundleInfoAdapter.CONF_USE_PREFIX + dd.getDependencyRevisionId().getName();

        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_DEFAULT);
        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_OPTIONAL);
        capabilityMd.addConfiguration(BundleInfoAdapter.CONF_TRANSITIVE_OPTIONAL);
        capabilityMd.addConfiguration(new Configuration(useConf));

        DefaultDependencyDescriptor capabilityDD = new DefaultDependencyDescriptor(
                md.getModuleRevisionId(), false);
        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_DEFAULT,
            BundleInfoAdapter.CONF_NAME_DEFAULT);
        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_OPTIONAL,
            BundleInfoAdapter.CONF_NAME_OPTIONAL);
        capabilityDD.addDependencyConfiguration(BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL,
            BundleInfoAdapter.CONF_NAME_TRANSITIVE_OPTIONAL);
        capabilityDD.addDependencyConfiguration(useConf, useConf);
        capabilityMd.addDependency(capabilityDD);

        MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
        report.setDownloadStatus(DownloadStatus.NO);
        report.setSearched(true);
        ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, capabilityMd, report);
        return new MDResolvedResource(null, capabilityMd.getRevision(), rmr);
    }
View Full Code Here


        Pattern oneDependencyPattern = Pattern.compile("(" + mridPattern.pattern() + ")\\s*->\\s*("
                + mridPattern.pattern() + ")");
        m = oneDependencyPattern.matcher(microIvy);
        if (m.matches()) {
            DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(
                ModuleRevisionId.parse(m.group(1)), new Date());
            md.addDependency(new DefaultDependencyDescriptor(ModuleRevisionId.parse(m.group(2)),
                    false));
            return md;
        }

        String p = "(" + mridPattern.pattern() + ")\\s*->\\s*\\{\\s*((?:" + mridPattern.pattern()
                + ",?\\s+)*" + mridPattern.pattern() + ")?\\s*\\}";
        Pattern multipleDependenciesPattern = Pattern.compile(p);
        m = multipleDependenciesPattern.matcher(microIvy);
        if (m.matches()) {
            DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(
                ModuleRevisionId.parse(m.group(1)), new Date());
            String mrids = m.group(2);
            if (mrids != null) {
                Collection depMrids = parseMrids(mrids);
                for (Iterator iter = depMrids.iterator(); iter.hasNext();) {
                    ModuleRevisionId dep = (ModuleRevisionId) iter.next();
                    md.addDependency(new DefaultDependencyDescriptor(dep, false));
                }
            }
            return md;
        }
        throw new IllegalArgumentException("invalid micro ivy format: " + microIvy);
View Full Code Here

            int deps = minDependencies + r.nextInt(varDeps + 1);
            int versions = minVersions + r.nextInt(varVersions + 1);

            int prevCurDep = curDep;
            for (int ver = 0; ver < versions; ver++) {
                DefaultModuleDescriptor md = new DefaultModuleDescriptor(
                        ModuleRevisionId.newInstance("apache", "mod" + nb, "1." + ver),
                        "integration", new Date());

                curDep = prevCurDep;
                for (int i = 0; i < deps && curDep < nbModules; i++) {
                    int d;
                    if (i % 2 == 1) {
                        d = nb + i;
                        if (d >= prevCurDep) {
                            d = curDep;
                            curDep++;
                        }
                    } else {
                        d = curDep;
                        curDep++;
                    }
                    DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(
                            md,
                            ModuleRevisionId.newInstance("apache", "mod" + d, "latest.integration"),
                            false, false, true);
                    dd.addDependencyConfiguration("default", "default");
                    md.addDependency(dd);
                }
                XmlModuleDescriptorWriter.write(md, new File("build/test/perf/mod" + nb + "/ivy-1."
                        + ver + ".xml"));
                FileUtil.copy(new File("test/repositories/1/org1/mod1.1/jars/mod1.1-1.0.jar"),
                    new File("build/test/perf/mod" + nb + "/mod" + nb + "-1." + ver + ".jar"), null);
View Full Code Here

    public void testAtomicity() throws Exception {
        IvySettings settings = new IvySettings();
        final PublishEngine engine = new PublishEngine(settings, new EventManager());
        final int[] counter = new int[] {0};

        final DefaultModuleDescriptor md = DefaultModuleDescriptor
                .newDefaultInstance(ModuleRevisionId.parse("#A;1.0"));
        final FileSystemResolver resolver = new FileSystemResolver() {
            public void publish(Artifact artifact, File src, boolean overwrite) throws IOException {
                super.publish(artifact, src, overwrite);
                synchronized (PublishEngineTest.this) {
View Full Code Here

        }
        return false;
    }

    public ModuleDescriptor toFixedModuleDescriptor(IvySettings settings, List<ModuleId> midToKeep) {
        DefaultModuleDescriptor fixedmd = new DefaultModuleDescriptor(md.getModuleRevisionId(),
                md.getStatus(), new Date());

        // copy configurations
        List<String> resolvedConfs = Arrays.asList(getConfigurations());
        for (String conf : resolvedConfs) {
            fixedmd.addConfiguration(new Configuration(conf));
        }

        if (midToKeep != null && !midToKeep.isEmpty()) {
            // add dependency we want to keep from the original module descriptor
            DependencyDescriptor[] deps = md.getDependencies();
            for (int i = 0; i < deps.length; i++) {
                if (midToKeep.contains(deps[i].getDependencyId())) {
                    DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
                            deps[i].getDependencyRevisionId(), true, false, false);
                    List<String> confs = Arrays.asList(deps[i].getModuleConfigurations());
                    if (confs.size() == 1 && confs.get(0).equals("*")) {
                        confs = resolvedConfs;
                    }
                    for (String conf : confs) {
                        String[] extendedConfs = getExtendingConfs(conf);
                        String[] depConfs = deps[i].getDependencyConfigurations(conf);
                        for (String extendedConf : extendedConfs) {
                            if (resolvedConfs.contains(extendedConf)) {
                                for (String depConf : depConfs) {
                                    dep.addDependencyConfiguration(extendedConf, depConf);
                                }
                            }
                        }
                    }
                    fixedmd.addDependency(dep);
                }
            }
        }

        // add resolved dependencies
        for (int i = 0; i < dependencies.size(); i++) {
            IvyNode node = (IvyNode) dependencies.get(i);
            if (midToKeep != null && midToKeep.contains(node.getModuleId())) {
                continue;
            }
            String[] rootConfs = node.getRootModuleConfigurations();
            for (int j = 0; j < rootConfs.length; j++) {
                if (node.isEvicted(rootConfs[j])) {
                    continue;
                }
                if (node.getAllArtifacts().length == 0) {
                    // no artifact: it was probably useful transitively, hence it is useless here
                    break;
                }
                DefaultDependencyDescriptor dep = new DefaultDependencyDescriptor(fixedmd,
                        node.getResolvedId(), true, false, false);
                String[] targetConfs = node.getConfigurations(rootConfs[j]);
                for (int k = 0; k < targetConfs.length; k++) {
                    dep.addDependencyConfiguration(rootConfs[j], targetConfs[k]);
                }
                fixedmd.addDependency(dep);
            }
        }

        return fixedmd;
    }
View Full Code Here

    public void toIvyFile(InputStream is, Resource res, File destFile, ModuleDescriptor md)
            throws IOException, ParseException {
        try {
            Namespace ns = null;
            if (md instanceof DefaultModuleDescriptor) {
                DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
                ns = dmd.getNamespace();
            }
            XmlModuleDescriptorUpdater.update(
                is,
                res,
                destFile,
View Full Code Here

                    if (isCheckconsistency()) {
                        checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
                        checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
                    } else {
                        if (systemMd instanceof DefaultModuleDescriptor) {
                            DefaultModuleDescriptor defaultMd = (DefaultModuleDescriptor) systemMd;
                            ModuleRevisionId revision = getRevision(ivyRef, systemMrid, systemMd);
                            defaultMd.setModuleRevisionId(revision);
                            defaultMd.setResolvedModuleRevisionId(revision);
                        } else {
                            Message.warn("consistency disabled with instance of non DefaultModuleDescriptor..."
                                    + " module info can't be updated, so consistency check will be done");
                            checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
                            checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
View Full Code Here

    private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef,
            ResolveData data) {
        if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE) && !systemMd.isDefault()
                && data.getSettings().logNotConvertedExclusionRule()
                && systemMd instanceof DefaultModuleDescriptor) {
            DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd;
            if (dmd.isNamespaceUseful()) {
                Message.warn("the module descriptor " + ivyRef.getResource()
                        + " has information which can't be converted into "
                        + "the system namespace. "
                        + "It will require the availability of the namespace '"
                        + getNamespace().getName() + "' to be fully usable.");
View Full Code Here

    }

    protected ResourceMDParser getDefaultRMDParser(final ModuleId mid) {
        return new ResourceMDParser() {
            public MDResolvedResource parse(Resource resource, String rev) {
                DefaultModuleDescriptor md = DefaultModuleDescriptor
                        .newDefaultInstance(new ModuleRevisionId(mid, rev));
                MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
                        md.getMetadataArtifact());
                madr.setDownloadStatus(DownloadStatus.NO);
                madr.setSearched(true);
                return new MDResolvedResource(resource, rev, new ResolvedModuleRevision(
                        BasicResolver.this, BasicResolver.this, md, madr, isForce()));
            }
View Full Code Here

        boolean log = settings.logNotConvertedExclusionRule();
        try {
            settings.setLogNotConvertedExclusionRule(true);
            resolveEngine.setDictatorResolver(fromResolver);

            DefaultModuleDescriptor md = new DefaultModuleDescriptor(ModuleRevisionId.newInstance(
                "apache", "ivy-install", "1.0"), settings.getStatusManager().getDefaultStatus(),
                    new Date());
            String resolveId = ResolveOptions.getDefaultResolveId(md);
            md.addConfiguration(new Configuration("default"));
            md.addConflictManager(new ModuleId(ExactPatternMatcher.ANY_EXPRESSION,
                    ExactPatternMatcher.ANY_EXPRESSION), ExactPatternMatcher.INSTANCE,
                new NoConflictManager());

            for (int c = 0; c < options.getConfs().length; c++) {
                final String[] depConfs = options.getConfs();

                for (int j = 0; j < depConfs.length; j++) {
                    final String depConf = depConfs[j].trim();

                    if (MatcherHelper.isExact(matcher, mrid)) {
                        DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md, mrid,
                                false, false, options.isTransitive());
                        dd.addDependencyConfiguration("default", depConf);
                        md.addDependency(dd);
                    } else {
                        ModuleRevisionId[] mrids = searchEngine.listModules(fromResolver, mrid,
                            matcher);

                        for (int i = 0; i < mrids.length; i++) {
                            Message.info("\tfound " + mrids[i] + " to install: adding to the list");
                            DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
                                    mrids[i], false, false, options.isTransitive());
                            dd.addDependencyConfiguration("default", depConf);
                            md.addDependency(dd);
                        }
                    }
                }
            }
View Full Code Here

TOP

Related Classes of org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.