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

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


        Map jarModulesMap = new HashMap();
        Map mds = new HashMap();

        for (int i = 0; i < modules.length; i++) {
            jarModulesMap.put(modules[i].getJar().getAbsolutePath(), modules[i]);
            DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(
                modules[i].getMrid(), new Date(modules[i].getJar().lastModified()));
            mds.put(modules[i].getMrid(), md);
            jarjarCmd.append("\"").append(modules[i].getJar().getAbsolutePath()).append("\"");
            if (i + 1 < modules.length) {
                jarjarCmd.append(File.pathSeparator);
            }
        }

        Message.verbose("jarjar command: " + jarjarCmd);

        try {
            Process p = Runtime.getRuntime().exec(jarjarCmd.toString());
            BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while ((line = r.readLine()) != null) {
                String[] deps = line.split(" -> ");
                JarModule module = (JarModule) jarModulesMap.get(deps[0]);
                JarModule dependency = (JarModule) jarModulesMap.get(deps[1]);

                if (module.getMrid().getModuleId().equals(dependency.getMrid().getModuleId())) {
                    continue;
                }
                Message.verbose(module.getMrid() + " depends on " + dependency.getMrid());

                DefaultModuleDescriptor md = (DefaultModuleDescriptor) mds.get(module.getMrid());

                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
                        dependency.getMrid(), false, false, true);
                dd.addDependencyConfiguration(ModuleDescriptor.DEFAULT_CONFIGURATION,
                    ModuleDescriptor.DEFAULT_CONFIGURATION);
                md.addDependency(dd);
            }
        } catch (IOException e) {
            Message.debug(e);
        }
        return (ModuleDescriptor[]) mds.values().toArray(new ModuleDescriptor[mds.values().size()]);
View Full Code Here


         *            a given parent module decriptor
         */
        protected void mergeInfo(ModuleDescriptor parent) {
            ModuleRevisionId parentMrid = parent.getModuleRevisionId();

            DefaultModuleDescriptor descriptor = getMd();
            ModuleRevisionId currentMrid = descriptor.getModuleRevisionId();

            ModuleRevisionId mergedMrid = ModuleRevisionId.newInstance(
                mergeValue(parentMrid.getOrganisation(), currentMrid.getOrganisation()),
                currentMrid.getName(),
                mergeValue(parentMrid.getBranch(), currentMrid.getBranch()),
                mergeRevisionValue(parentMrid.getRevision(), currentMrid.getRevision()),
                mergeValues(parentMrid.getQualifiedExtraAttributes(),
                    currentMrid.getQualifiedExtraAttributes()));

            descriptor.setModuleRevisionId(mergedMrid);
            descriptor.setResolvedModuleRevisionId(mergedMrid);

            descriptor.setStatus(mergeValue(parent.getStatus(), descriptor.getStatus()));
            if (descriptor.getNamespace() == null && parent instanceof DefaultModuleDescriptor) {
                Namespace parentNamespace = ((DefaultModuleDescriptor) parent).getNamespace();
                descriptor.setNamespace(parentNamespace);
            }
        }
View Full Code Here

         *
         * @param dependencies
         *            array of dependencies to inherit
         */
        protected void mergeDependencies(DependencyDescriptor[] dependencies) {
            DefaultModuleDescriptor md = getMd();
            for (int i = 0; i < dependencies.length; i++) {
                DependencyDescriptor dependencyDescriptor = dependencies[i];
                Message.debug("Merging dependency with: "
                        + dependencyDescriptor.getDependencyRevisionId().toString());
                md.addDependency(dependencyDescriptor);
            }
        }
View Full Code Here

            // create a new temporary parser to read the configurations from
            // the specified file.
            Parser parser = new Parser(getModuleDescriptorParser(), settings);
            parser.setInput(url);
            parser.setMd(new DefaultModuleDescriptor(getModuleDescriptorParser(), new URLResource(
                    url)));
            XMLHelper.parse(url, null, parser);

            // add the configurations from this temporary parser to this module descriptor
            Configuration[] configs = parser.getModuleDescriptor().getConfigurations();
View Full Code Here

                            workspaceArtifacts.put(artifact, af);
                        }
                        IvyContext.pushContext(currentContext);
                    }

                    DefaultModuleDescriptor workspaceMd = cloneMd(md, af);

                    MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(af);
                    madr.setDownloadStatus(DownloadStatus.SUCCESSFUL);
                    madr.setSearched(true);
View Full Code Here

        return null;
    }

    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 (int k = 0; k < allConfs.length; k++) {
                newMd.addConfiguration(allConfs[k]);
                newMd.addArtifact(allConfs[k].getName(), af);
            }
        }

        DependencyDescriptor[] dependencies = md.getDependencies();
        for (int k = 0; k < dependencies.length; k++) {
            newMd.addDependency(dependencies[k]);
        }

        ExcludeRule[] allExcludeRules = md.getAllExcludeRules();
        for (int k = 0; k < allExcludeRules.length; k++) {
            newMd.addExcludeRule(allExcludeRules[k]);
        }

        Map extraInfo = md.getExtraInfo();
        Iterator it = extraInfo.entrySet().iterator();
        while (it.hasNext()) {
            Entry entry = (Entry) it.next();
            newMd.addExtraInfo((String) entry.getKey(), (String) entry.getValue());
        }

        License[] licenses = md.getLicenses();
        for (int k = 0; k < licenses.length; k++) {
            newMd.addLicense(licenses[k]);
        }

        return newMd;
    }
View Full Code Here

    private ModuleDescriptor md3 = null;

    private ModuleDescriptor md4 = null;

    public void setUp() throws Exception {
        md = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo", "bar", "1.0"),
                "integration", new Date());
        md2 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo2", "bar", "1.0"),
                "integration", new Date());
        md3 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo3", "baz", "1.0"),
                "integration", new Date());
        md4 = new DefaultModuleDescriptor(ModuleRevisionId.newInstance("foo", "baz", "1.0"),
                "integration", new Date());
    }
View Full Code Here

            new SortOptions().setNonMatchingVersionReporter(nonMatchingVersionReporter));
    }

    private DefaultModuleDescriptor createModuleDescriptorToSort(String moduleName, String revision) {
        ModuleRevisionId mrid = ModuleRevisionId.newInstance("org", moduleName, revision);
        return new DefaultModuleDescriptor(mrid, "integration", new Date());
    }
View Full Code Here

   
    private class MockedDependencyResolver extends MockResolver {       
        public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
                throws ParseException {
            //TODO make it a real mock and check that dd and data are the one that are expected
            DefaultModuleDescriptor moduleDesc = DefaultModuleDescriptor.newDefaultInstance(
                                                                    dd.getDependencyRevisionId());
            ResolvedModuleRevision r = new ResolvedModuleRevision(this,this,moduleDesc,null);
            return r;
        }
View Full Code Here

            File ivyfile;
            if (line.hasOption("dependency")) {
                String[] dep = line.getOptionValues("dependency");
                ivyfile = File.createTempFile("ivy", ".xml");
                ivyfile.deleteOnExit();
                DefaultModuleDescriptor md = DefaultModuleDescriptor
                        .newDefaultInstance(ModuleRevisionId.newInstance(dep[0],
                            dep[1] + "-caller", "working"));
                DefaultDependencyDescriptor dd = new DefaultDependencyDescriptor(md,
                        ModuleRevisionId.newInstance(dep[0], dep[1], dep[2]), false, false, true);
                for (int i = 0; i < confs.length; i++) {
                    dd.addDependencyConfiguration("default", confs[i]);
                }
                md.addDependency(dd);
                XmlModuleDescriptorWriter.write(md, ivyfile);
                confs = new String[] {"default"};
            } else {
                ivyfile = new File(settings.substitute(line.getOptionValue("ivy", "ivy.xml")));
                if (!ivyfile.exists()) {
                    error("ivy file not found: " + ivyfile);
                } else if (ivyfile.isDirectory()) {
                    error("ivy file is not a file: " + ivyfile);
                }
            }

            if (line.hasOption("useOrigin")) {
                ivy.getSettings().useDeprecatedUseOrigin();
            }
            ResolveOptions resolveOptions = new ResolveOptions().setConfs(confs)
                .setValidate(validate);
            if (line.hasOption("refresh")) {
                resolveOptions.setRefresh(true);
            }
            ResolveReport report = ivy.resolve(ivyfile.toURI().toURL(), resolveOptions);
            if (report.hasError()) {
                System.exit(1);
            }
            ModuleDescriptor md = report.getModuleDescriptor();

            if (confs.length == 1 && "*".equals(confs[0])) {
                confs = md.getConfigurationsNames();
            }
            if (line.hasOption("retrieve")) {
                String retrievePattern = settings.substitute(line.getOptionValue("retrieve"));
                if (retrievePattern.indexOf("[") == -1) {
                    retrievePattern = retrievePattern + "/lib/[conf]/[artifact].[ext]";
                }
                ivy.retrieve(md.getModuleRevisionId(), retrievePattern, new RetrieveOptions()
                        .setConfs(confs).setSync(line.hasOption("sync"))
                        .setUseOrigin(line.hasOption("useOrigin")));
            }
            if (line.hasOption("cachepath")) {
                outputCachePath(ivy, cache, md, confs, line.getOptionValue("cachepath",
                    "ivycachepath.txt"));
            }

            if (line.hasOption("revision")) {
                ivy.deliver(md.getResolvedModuleRevisionId(), settings.substitute(line
                        .getOptionValue("revision")), settings.substitute(line.getOptionValue(
                    "deliverto", "ivy-[revision].xml")), DeliverOptions.newInstance(settings)
                        .setStatus(settings.substitute(line.getOptionValue("status", "release")))
                        .setValidate(validate));
                if (line.hasOption("publish")) {
                    ivy.publish(md.getResolvedModuleRevisionId(), Collections.singleton(settings
                            .substitute(line.getOptionValue("publishpattern",
                                "distrib/[type]s/[artifact]-[revision].[ext]"))), line
                            .getOptionValue("publish"), new PublishOptions()
                            .setPubrevision(settings.substitute(line.getOptionValue("revision")))
                            .setValidate(validate).setSrcIvyPattern(
View Full Code Here

TOP

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

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.