Package org.apache.ivy

Examples of org.apache.ivy.Ivy


        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", "b", "2.0")));
        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("test", "c", "3.0")));
    }

    public void testIVY1333() throws Exception {
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/IVY-1333/ivysettings.xml"));
        ivy.getSettings().setDefaultCache(cache);

        ResolveReport rr = ivy.resolve(new File("test/repositories/IVY-1333/ivy.xml"),
            getResolveOptions(new String[] {"*"}));
        ConfigurationResolveReport crr = rr.getConfigurationReport("default");
        Set modRevIds = crr.getModuleRevisionIds();
        assertEquals(3, modRevIds.size());
        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "dep1", "1.0")));
View Full Code Here


        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("org", "badArtifact",
            "1.0.0.m4", extra)));
    }

    public void testIVY1347() throws Exception {
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/IVY-1347/ivysettings.xml"));
        ivy.getSettings().setDefaultCache(cache);

        ResolveReport rr = ivy.resolve(new File(
                "test/repositories/IVY-1347/childone/childtwo/ivy.xml"),
            getResolveOptions(new String[] {"*"}));
        ModuleDescriptor md = rr.getModuleDescriptor();
        assertNotNull(md);

View Full Code Here

        ModuleRevisionId parent = parents[0].getParentRevisionId();
        assertEquals(ModuleRevisionId.newInstance("foo", "parent", "1.0"), parent);
    }

    public void testIVY999() throws Exception {
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/IVY-999/ivysettings.xml"));
        ivy.getSettings().setDefaultCache(cache);

        ResolveReport rr = ivy.resolve(ResolveTest.class.getResource("ivy-999.xml"),
            getResolveOptions(new String[] {"*"}));
        ConfigurationResolveReport crr = rr.getConfigurationReport("default");
        Set modRevIds = crr.getModuleRevisionIds();

        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "4.4")));
View Full Code Here

        assertTrue(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "4.4")));
        assertFalse(modRevIds.contains(ModuleRevisionId.newInstance("junit", "junit", "3.8")));
    }

    public void testIVY1366() throws Exception {
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/IVY-1366/ivysettings.xml"));

        ResolveReport report = ivy.resolve(new File("test/repositories/IVY-1366/ivy.xml"),
            new ResolveOptions().setConfs(new String[] {"runtime"}));
        assertFalse(report.hasError());

        List artifacts = report.getArtifacts();
        assertEquals(3, artifacts.size());
View Full Code Here

        assertEquals("test#c;1!c.jar", artifacts.get(1).toString());
        assertEquals("test#b;1!b.jar", artifacts.get(2).toString());
    }

    public void testBadFiles() throws Exception {
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/badfile/ivysettings.xml"));

        ResolveReport report = ivy.resolve(
            new File("test/repositories/badfile/ivys/ivy-badorg.xml"),
            getResolveOptions(new String[] {"*"}));
        assertTrue("bad org should have raised an error in report", report.hasError());
        assertTrue(StringUtils.join(report.getAllProblemMessages().toArray(), "\n").indexOf(
            "'badorg'") != -1);

        report = ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badmodule.xml"),
            getResolveOptions(new String[] {"*"}));
        assertTrue("bad module should have raised an error in report", report.hasError());
        assertTrue(StringUtils.join(report.getAllProblemMessages().toArray(), "\n").indexOf(
            "'badmodule'") != -1);

        report = ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badbranch.xml"),
            getResolveOptions(new String[] {"*"}));
        assertTrue("bad branch should have raised an error in report", report.hasError());
        assertTrue(StringUtils.join(report.getAllProblemMessages().toArray(), "\n").indexOf(
            "'badbranch'") != -1);

        report = ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badrevision.xml"),
            getResolveOptions(new String[] {"*"}));
        assertTrue("bad revision should have raised an error in report", report.hasError());
        assertTrue(StringUtils.join(report.getAllProblemMessages().toArray(), "\n").indexOf(
            "'badrevision'") != -1);

        report = ivy.resolve(new File("test/repositories/badfile/ivys/ivy-badxml.xml"),
            getResolveOptions(new String[] {"*"}));
        assertTrue("bad xml should have raised an error in report", report.hasError());
        assertTrue(StringUtils.join(report.getAllProblemMessages().toArray(), "\n").indexOf(
            "badatt") != -1);
    }
View Full Code Here

                throw new BuildException("specify only one of 'resolver' or 'baseDir'");
            }
            if (cacheName != null) {
                throw new BuildException("specify only one of 'resolver' or 'cache'");
            }
            Ivy ivy = getIvyInstance();
            IvySettings settings = ivy.getSettings();
            DependencyResolver resolver = settings.getResolver(resolverName);
            if (resolver == null) {
                throw new BuildException("the resolver '" + resolverName + "' was not found");
            }
            if (!(resolver instanceof BasicResolver)) {
                throw new BuildException("the type of resolver '" + resolver.getClass().getName()
                        + "' is not supported.");
            }
            it = new ResolverManifestIterable((BasicResolver) resolver);
        } else if (baseDir != null) {
            if (cacheName != null) {
                throw new BuildException("specify only one of 'baseDir' or 'cache'");
            }
            if (!baseDir.isDirectory()) {
                throw new BuildException(baseDir + " is not a directory");
            }
            it = new FSManifestIterable(baseDir);
        } else if (cacheName != null) {
            Ivy ivy = getIvyInstance();
            RepositoryCacheManager cacheManager = ivy.getSettings().getRepositoryCacheManager(
                cacheName);
            if (!(cacheManager instanceof DefaultRepositoryCacheManager)) {
                throw new BuildException("the type of cache '" + cacheManager.getClass().getName()
                        + "' is not supported.");
            }
View Full Code Here

        }
        if (value == null) {
            throw new BuildException("no value provided for ivy listmodules task");
        }

        Ivy ivy = getIvyInstance();
        IvySettings settings = ivy.getSettings();

        SearchEngine searcher = new SearchEngine(settings);
        PatternMatcher patternMatcher = settings.getMatcher(matcher);

        ModuleRevisionId[] mrids;
View Full Code Here

        super.prepareTask();
        Message.setShowProgress(showProgress);
    }

    public void doExecute() throws BuildException {
        Ivy ivy = getIvyInstance();
        IvySettings settings = ivy.getSettings();
        try {
            conf = getProperty(conf, settings, "ivy.configurations");
            type = getProperty(type, settings, "ivy.resolve.default.type.filter");
            String[] confs = splitConfs(conf);

            boolean childs = !dependencies.isEmpty() || !excludes.isEmpty() || !conflicts.isEmpty();

            ResolveReport report;
            if (childs) {
                if (isInline()) {
                    throw new BuildException("the inline mode is incompatible with child elements");
                }
                if (organisation != null) {
                    throw new BuildException("'organisation' is not allowed with child elements");
                }
                if (module != null) {
                    throw new BuildException("'module' is not allowed with child elements");
                }
                if (file != null) {
                    throw new BuildException("'file' not allowed with child elements");
                }
                if (!getAllowedLogOptions().contains(log)) {
                    throw new BuildException("invalid option for 'log': " + log
                            + ". Available options are " + getAllowedLogOptions());
                }

                ModuleRevisionId mrid = ModuleRevisionId.newInstance("", "",
                    Ivy.getWorkingRevision());
                DefaultModuleDescriptor md = DefaultModuleDescriptor.newBasicInstance(mrid, null);

                Iterator itDeps = dependencies.iterator();
                while (itDeps.hasNext()) {
                    IvyDependency dep = (IvyDependency) itDeps.next();
                    DependencyDescriptor dd = dep.asDependencyDescriptor(md, "default", settings);
                    md.addDependency(dd);
                }

                Iterator itExcludes = excludes.iterator();
                while (itExcludes.hasNext()) {
                    IvyExclude exclude = (IvyExclude) itExcludes.next();
                    DefaultExcludeRule rule = exclude.asRule(settings);
                    rule.addConfiguration("default");
                    md.addExcludeRule(rule);
                }

                Iterator itConflicts = conflicts.iterator();
                while (itConflicts.hasNext()) {
                    IvyConflict conflict = (IvyConflict) itConflicts.next();
                    conflict.addConflict(md, settings);
                }

                report = ivy
                        .resolve(md, getResolveOptions(ivy, new String[] {"default"}, settings));
            } else if (isInline()) {
                if (organisation == null) {
                    throw new BuildException("'organisation' is required when using inline mode");
                }
                if (module == null) {
                    throw new BuildException("'module' is required when using inline mode");
                }
                if (file != null) {
                    throw new BuildException("'file' not allowed when using inline mode");
                }
                if (!getAllowedLogOptions().contains(log)) {
                    throw new BuildException("invalid option for 'log': " + log
                            + ". Available options are " + getAllowedLogOptions());
                }
                for (int i = 0; i < confs.length; i++) {
                    if ("*".equals(confs[i])) {
                        confs[i] = "*(public)";
                    }
                }
                if (revision == null) {
                    revision = "latest.integration";
                }
                report = ivy.resolve(
                    ModuleRevisionId.newInstance(organisation, module, branch, revision),
                    getResolveOptions(ivy, confs, settings), changing);

            } else {
                if (organisation != null) {
                    throw new BuildException(
                            "'organisation' not allowed when not using 'org' attribute");
                }
                if (module != null) {
                    throw new BuildException("'module' not allowed when not using 'org' attribute");
                }
                if (file == null) {
                    file = getProject().resolveFile(getProperty(settings, "ivy.dep.file"));
                }
                report = ivy.resolve(file.toURI().toURL(), getResolveOptions(ivy, confs, settings));
            }
            if (report.hasError()) {
                if (failureProperty != null) {
                    getProject().setProperty(failureProperty, "true");
                }
View Full Code Here

        }
        if (prefix == null) {
            throw new BuildException("null prefix not allowed");
        }

        Ivy ivy = getIvyInstance();
        IvySettings settings = ivy.getSettings();
        if (branch == null) {
            branch = settings.getDefaultBranch(new ModuleId(organisation, module));
        }
        if (revision == null || revision.length() == 0) {
            revision = "latest.integration";
        } else if (!revision.endsWith("+")) {
            revision = revision + "+";
        }
        if (!prefix.endsWith(".") && prefix.length() > 0) {
            prefix = prefix + ".";
        }

        SearchEngine searcher = new SearchEngine(settings);

        PatternMatcher patternMatcher = new PatternMatcher() {
            private PatternMatcher exact = new ExactPatternMatcher();

            private PatternMatcher regexp = new ExactOrRegexpPatternMatcher();

            public Matcher getMatcher(String expression) {
                if (expression.equals(organisation) || expression.equals(module)
                        || expression.equals(branch)) {
                    return exact.getMatcher(expression);
                }
                return regexp.getMatcher(expression);
            }

            public String getName() {
                return "buildnumber-matcher";
            }
        };
        ModuleRevisionId[] revisions;
        if (resolver == null) {
            revisions = searcher.listModules(
                ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
        } else {
            DependencyResolver depResolver = settings.getResolver(resolver);
            if (depResolver == null) {
                throw new BuildException("Unknown resolver: " + resolver);
            }
            revisions = searcher.listModules(depResolver,
                ModuleRevisionId.newInstance(organisation, module, branch, ".*"), patternMatcher);
        }

        ArtifactInfo[] infos = new ArtifactInfo[revisions.length];
        for (int i = 0; i < revisions.length; i++) {
            infos[i] = new ResolvedModuleRevisionArtifactInfo(revisions[i]);
        }

        VersionMatcher matcher = settings.getVersionMatcher();
        LatestStrategy latestStrategy = settings.getLatestStrategy("latest-revision");
        List sorted = latestStrategy.sort(infos);

        ModuleRevisionId askedMrid = ModuleRevisionId.newInstance(organisation, module, branch,
            revision);

        String foundRevision = null;
        for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
            ResolvedModuleRevisionArtifactInfo info = (ResolvedModuleRevisionArtifactInfo) iter
                    .previous();

            if (!matcher.accept(askedMrid, info.rmr)) {
                continue;
            }

            if (matcher.needModuleDescriptor(askedMrid, info.rmr)) {
                ResolvedModuleRevision rmr = ivy.findModule(info.rmr);
                if (matcher.accept(askedMrid, rmr.getDescriptor())) {
                    foundRevision = info.rmr.getRevision();
                }
            } else {
                foundRevision = info.rmr.getRevision();
View Full Code Here

    public void testResolveMaven2Snapshot2AsLatestIntegration() throws Exception {
        // test case for IVY-1036
        // here we test maven SNAPSHOT versions handling,
        // with m2 snapshotRepository/uniqueVersion set to true
        // but retrieving by latest.integration
        Ivy ivy = new Ivy();
        ivy.configure(new File("test/repositories/m2/ivysettings.xml"));
        ResolveReport report = ivy.resolve(
            ModuleRevisionId.newInstance("org.apache", "test-SNAPSHOT2", "latest.integration"),
            getResolveOptions(new String[] {"*(public)"}), true);
        assertNotNull(report);
        assertFalse(report.hasError());

View Full Code Here

TOP

Related Classes of org.apache.ivy.Ivy

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.