org.apache.ivy.core.IvyPatternHelper Java Examples

The following examples show how to use org.apache.ivy.core.IvyPatternHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public String[] listRevisions(String org, String module) {
    Set<String> entries = new HashSet<>();

    Map<String, Object> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);
    tokenValues.put(IvyPatternHelper.MODULE_KEY, module);

    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] revisions = resolver.listTokenValues(
            new String[] {IvyPatternHelper.REVISION_KEY}, tokenValues);
        for (Map<String, String> revision : revisions) {
            entries.add(revision.get(IvyPatternHelper.REVISION_KEY));
        }
    }

    return entries.toArray(new String[entries.size()]);
}
 
Example #2
Source File: IvyRetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testInline() {
    // we first resolve another ivy file
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml"));
    resolve.execute();

    assertTrue(getArchiveFileInCache("org1", "mod1.2", "2.2", "mod1.2", "jar", "jar").exists());

    // then we resolve a dependency directly
    retrieve.setOrganisation("org1");
    retrieve.setModule("mod1.2");
    retrieve.setRevision("2.0");
    retrieve.setInline(true);
    retrieve.execute();
    assertTrue(new File(IvyPatternHelper.substitute(RETRIEVE_PATTERN, "org1", "mod1.2", "2.0",
        "mod1.2", "jar", "jar")).exists());
}
 
Example #3
Source File: Match.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public Matcher getPatternMatcher(ModuleRevisionId askedMrid) {
    String revision = askedMrid.getRevision();

    List<String> args = split(getArgs());
    List<String> argValues = getRevisionArgs(revision);

    if (args.size() != argValues.size()) {
        return new NoMatchMatcher();
    }

    Map<String, String> variables = new HashMap<>();
    for (String arg : args) {
        variables.put(arg, argValues.get(args.indexOf(arg)));
    }

    String pattern = getPattern();
    pattern = IvyPatternHelper.substituteVariables(pattern, variables);

    PatternMatcher pMatcher = IvyContext.getContext().getSettings().getMatcher(matcher);
    return pMatcher.getMatcher(pattern);
}
 
Example #4
Source File: SearchEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public ModuleEntry[] listModuleEntries(OrganisationEntry org) {
    Set<ModuleEntry> entries = new HashSet<>();

    Map<String, Object> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());

    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] modules = resolver.listTokenValues(
            new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
        for (Map<String, String> me : modules) {
            String module = me.get(IvyPatternHelper.MODULE_KEY);
            entries.add(new ModuleEntry(org, module));
        }
    }

    return entries.toArray(new ModuleEntry[entries.size()]);
}
 
Example #5
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveOverwrite() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";

    // we create a fake old file to see if it is overwritten
    File file = new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0",
        "mod1.2", "jar", "jar", "default")).getCanonicalFile();
    file.getParentFile().mkdirs();
    file.createNewFile();
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setOverwriteMode("always").setDestArtifactPattern(pattern));
    assertEquals(new File("test/repositories/1/org1/mod1.2/jars/mod1.2-2.0.jar").lastModified(),
        file.lastModified());
}
 
Example #6
Source File: SearchEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
/**
 * List module ids of the module accessible through the current resolvers matching the given mid
 * criteria according to the given matcher.
 * <p>
 * ModuleId are returned in the system namespace.
 * </p>
 *
 * @param moduleCrit ModuleId
 * @param matcher PatternMatcher
 * @return ModuleId[]
 */
public ModuleId[] listModules(ModuleId moduleCrit, PatternMatcher matcher) {
    List<ModuleId> ret = new ArrayList<>();

    Map<String, Object> criteria = new HashMap<>();
    addMatcher(matcher, moduleCrit.getOrganisation(), criteria,
        IvyPatternHelper.ORGANISATION_KEY);
    addMatcher(matcher, moduleCrit.getName(), criteria, IvyPatternHelper.MODULE_KEY);

    String[] tokensToList = new String[] {IvyPatternHelper.ORGANISATION_KEY,
            IvyPatternHelper.MODULE_KEY};

    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] moduleIdAsMap = resolver.listTokenValues(tokensToList, criteria);
        for (Map<String, String> moduleId : moduleIdAsMap) {
            String org = moduleId.get(IvyPatternHelper.ORGANISATION_KEY);
            String name = moduleId.get(IvyPatternHelper.MODULE_KEY);
            ModuleId modId = ModuleId.newInstance(org, name);
            ret.add(NameSpaceHelper.transform(modId, resolver.getNamespace()
                    .getToSystemTransformer()));
        }
    }

    return ret.toArray(new ModuleId[ret.size()]);
}
 
Example #7
Source File: SearchEngine.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public String[] listModules(String org) {
    Set<String> entries = new HashSet<>();

    Map<String, Object> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org);

    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] modules = resolver.listTokenValues(
            new String[] {IvyPatternHelper.MODULE_KEY}, tokenValues);
        for (Map<String, String> module : modules) {
            entries.add(module.get(IvyPatternHelper.MODULE_KEY));
        }
    }

    return entries.toArray(new String[entries.size()]);
}
 
Example #8
Source File: ModuleRevisionId.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private ModuleRevisionId(ModuleId moduleId, String branch, String revision,
        Map<String, String> extraAttributes, boolean replaceNullBranchWithDefault) {
    super(null, extraAttributes);
    this.moduleId = moduleId;
    IvyContext context = IvyContext.getContext();
    this.branch = (replaceNullBranchWithDefault && branch == null)
    // we test if there's already an Ivy instance loaded, to avoid loading a default one
    // just to get the default branch
    ? (context.peekIvy() == null ? null : context.getSettings().getDefaultBranch(moduleId))
            : branch;
    this.revision = revision == null ? Ivy.getWorkingRevision() : normalizeRevision(revision);
    setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, this.moduleId.getOrganisation());
    setStandardAttribute(IvyPatternHelper.MODULE_KEY, this.moduleId.getName());
    setStandardAttribute(IvyPatternHelper.BRANCH_KEY, this.branch);
    setStandardAttribute(IvyPatternHelper.REVISION_KEY, this.revision);
}
 
Example #9
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveSimple() throws Exception {
    // mod1.1 depends on mod1.2
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/retrieve/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());

    pattern = "build/test/retrieve/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());
}
 
Example #10
Source File: IvyRetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testWithAPreviousResolveAndResolveId() {
    // first we do a resolve in another project
    Project project = TestHelper.newProject();
    project.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml");
    project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-simple.xml");
    IvyResolve resolve = new IvyResolve();
    resolve.setProject(project);
    resolve.setResolveId("testWithAPreviousResolveAndResolveId");
    resolve.execute();

    // then we do a retrieve with the correct module information
    retrieve.setOrganisation("apache");
    retrieve.setModule("resolve-simple");
    retrieve.setConf("default");
    retrieve.setResolveId("testWithAPreviousResolveAndResolveId");
    retrieve.execute();

    assertTrue(new File(IvyPatternHelper.substitute(RETRIEVE_PATTERN, "org1", "mod1.2", "2.0",
        "mod1.2", "jar", "jar")).exists());
}
 
Example #11
Source File: JarModuleFinder.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public JarModule[] findJarModules() {
    List<JarModule> ret = new ArrayList<>();
    URLLister lister = new FileURLLister();
    try {
        for (String org : ResolverHelper.listTokenValues(lister, pattern, "organisation")) {
            String orgPattern = IvyPatternHelper.substituteToken(pattern,
                    IvyPatternHelper.ORGANISATION_KEY, org);
            for (String module : ResolverHelper.listTokenValues(lister, orgPattern, "module")) {
                String modPattern = IvyPatternHelper.substituteToken(orgPattern,
                        IvyPatternHelper.MODULE_KEY, module);
                for (String rev : ResolverHelper.listTokenValues(lister, modPattern, "revision")) {
                    File jar = new File(IvyPatternHelper.substitute(filePattern, org,
                            module, rev, module, "jar", "jar"));
                    if (jar.exists()) {
                        ret.add(new JarModule(ModuleRevisionId.newInstance(org, module, rev), jar));
                    }
                }
            }
        }

    } catch (Exception e) {
        Message.debug(e);
        // TODO: handle exception
    }
    return ret.toArray(new JarModule[ret.size()]);
}
 
Example #12
Source File: RepositoryAnalyser.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public void analyse(String pattern, DependencyAnalyser depAnalyser) {
    JarModuleFinder finder = new JarModuleFinder(pattern);
    ModuleDescriptor[] mds = depAnalyser.analyze(finder.findJarModules());
    Message.info("found " + mds.length + " modules");
    for (ModuleDescriptor md : mds) {
        File ivyFile = new File(IvyPatternHelper.substitute(
                pattern,
                DefaultArtifact.newIvyArtifact(md.getModuleRevisionId(),
                        md.getPublicationDate())));
        try {
            Message.info("generating " + ivyFile);
            XmlModuleDescriptorWriter.write(md, ivyFile);
        } catch (IOException e) {
            Message.debug(e);
        }
    }
}
 
Example #13
Source File: IvyArtifactProperty.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public void doExecute() throws BuildException {
    prepareAndCheck();

    try {
        ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
        String resolveId = getResolveId();
        if (resolveId == null) {
            resolveId = ResolveOptions.getDefaultResolveId(getResolvedModuleId());
        }
        XmlReportParser parser = new XmlReportParser();
        for (String conf : splitToArray(getConf())) {
            File report = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf);
            parser.parse(report);

            for (Artifact artifact : parser.getArtifacts()) {
                String name = IvyPatternHelper.substitute(getSettings().substitute(getName()),
                        artifact, conf);
                String value = IvyPatternHelper.substitute(
                        getSettings().substitute(getValue()), artifact, conf);
                setProperty(name, value);
            }
        }
    } catch (Exception ex) {
        throw new BuildException("impossible to add artifact properties: " + ex, ex);
    }
}
 
Example #14
Source File: IvyReport.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
private String getOutputPattern(String conf, String ext) {
    if (mRevId == null) {
        ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();

        XmlReportParser parser = new XmlReportParser();
        File reportFile = cacheMgr.getConfigurationResolveReportInCache(resolveId, conf);

        try {
            parser.parse(reportFile);
        } catch (ParseException e) {
            throw new BuildException("Error occurred while parsing reportfile '"
                    + reportFile.getAbsolutePath() + "'", e);
        }

        // get the resolve module
        mRevId = parser.getResolvedModule();
    }

    return IvyPatternHelper.substitute(outputpattern, mRevId.getOrganisation(),
        mRevId.getName(), mRevId.getRevision(), "", "", ext, conf,
        mRevId.getQualifiedExtraAttributes(), null);
}
 
Example #15
Source File: RetrieveTest.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
@Test
public void testRetrieveWithVariable() throws Exception {
    // mod1.1 depends on mod1.2
    ivy.setVariable("retrieve.dir", "retrieve");
    ResolveReport report = ivy.resolve(new File(
            "test/repositories/1/org1/mod1.1/ivys/ivy-1.0.xml").toURI().toURL(),
        getResolveOptions(new String[] {"*"}));
    assertNotNull(report);
    ModuleDescriptor md = report.getModuleDescriptor();
    assertNotNull(md);

    String pattern = "build/test/${retrieve.dir}/[module]/[conf]/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve");
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());

    pattern = "build/test/${retrieve.dir}/[module]/[conf]/[type]s/[artifact]-[revision].[ext]";
    ivy.retrieve(md.getModuleRevisionId(),
        getRetrieveOptions().setDestArtifactPattern(pattern));
    pattern = IvyPatternHelper.substituteVariable(pattern, "retrieve.dir", "retrieve");
    assertTrue(new File(IvyPatternHelper.substitute(pattern, "org1", "mod1.2", "2.0", "mod1.2",
        "jar", "jar", "default")).exists());
}
 
Example #16
Source File: AbstractIncludeExcludeRule.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void initStandardAttributes() {
    setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, id.getModuleId().getOrganisation());
    setStandardAttribute(IvyPatternHelper.MODULE_KEY, id.getModuleId().getName());
    setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, id.getName());
    setStandardAttribute(IvyPatternHelper.TYPE_KEY, id.getType());
    setStandardAttribute(IvyPatternHelper.EXT_KEY, id.getExt());
    setStandardAttribute("matcher", patternMatcher.getName());
}
 
Example #17
Source File: IvyPatternHelperTest.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Test
public void testOptionalSubstitute() {
    Map<String, String> tokens = new HashMap<>();
    tokens.put("token", "");
    tokens.put("othertoken", "myval");
    assertEquals("test-myval",
        IvyPatternHelper.substituteTokens("test(-[token])(-[othertoken])", tokens));
    tokens.put("token", "val");
    assertEquals("test-val-myval",
        IvyPatternHelper.substituteTokens("test(-[token])(-[othertoken])", tokens));
}
 
Example #18
Source File: PomReader.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private String replaceProps(String val) {
    if (val == null) {
        return null;
    } else {
        return IvyPatternHelper.substituteVariables(val, properties).trim();
    }
}
 
Example #19
Source File: XmlSettingsParser.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private void moduleStarted(Map<String, String> attributes) {
    attributes.put(IvyPatternHelper.MODULE_KEY, attributes.remove("name"));
    String resolver = attributes.remove("resolver");
    String branch = attributes.remove("branch");
    String cm = attributes.remove("conflict-manager");
    String resolveMode = attributes.remove("resolveMode");
    String matcher = attributes.remove("matcher");
    matcher = (matcher == null) ? PatternMatcher.EXACT_OR_REGEXP : matcher;
    ivy.addModuleConfiguration(attributes, ivy.getMatcher(matcher), resolver, branch, cm,
        resolveMode);
}
 
Example #20
Source File: DefaultRepositoryCacheManager.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * A resolver-specific ivydata file, only used for caching dynamic revisions, e.g.
 * integration-repo.
 */
private PropertiesFile getCachedDataFile(String resolverName, ModuleRevisionId mRevId) {
    // we append ".${resolverName} onto the end of the regular ivydata location
    return new PropertiesFile(new File(getRepositoryCacheRoot(),
            IvyPatternHelper.substitute(getDataFilePattern(), mRevId) + "." + resolverName),
            "ivy cached data file for " + mRevId);
}
 
Example #21
Source File: SearchEngine.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public String[] listOrganisations() {
    Set<String> entries = new HashSet<>();

    for (DependencyResolver resolver : settings.getResolvers()) {
        Map<String, String>[] orgs = resolver.listTokenValues(
            new String[] {IvyPatternHelper.ORGANISATION_KEY}, new HashMap<String, Object>());
        for (Map<String, String> org : orgs) {
            entries.add(org.get(IvyPatternHelper.ORGANISATION_KEY));
        }
    }

    return entries.toArray(new String[entries.size()]);
}
 
Example #22
Source File: IBiblioResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public String[] listTokenValues(String token, Map<String, String> otherTokenValues) {
    if (IvyPatternHelper.ORGANISATION_KEY.equals(token)) {
        return new String[0];
    }
    if (IvyPatternHelper.MODULE_KEY.equals(token) && !isM2compatible()) {
        return new String[0];
    }
    ensureConfigured(getSettings());
    return super.listTokenValues(token, otherTokenValues);
}
 
Example #23
Source File: PackagerCacheEntry.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private String getResourceURL() {
    String baseURL = IvyPatternHelper.substitute(resourceURL, mr.getOrganisation(),
        mr.getName(), mr.getRevision(), null, null, null, null,
        mr.getQualifiedExtraAttributes(), null);
    int slash = baseURL.lastIndexOf('/');
    if (slash != -1) {
        baseURL = baseURL.substring(0, slash + 1);
    }
    return baseURL;
}
 
Example #24
Source File: FileSystemResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
protected String getDestination(String pattern, Artifact artifact, ModuleRevisionId mrid) {
    if (supportTransaction() && isTransactionStarted()) {

        String destPattern = fullTransactionPatterns.get(pattern);
        if (destPattern == null) {
            throw new IllegalArgumentException(
                    "unsupported pattern for publish destination pattern: " + pattern
                            + ". supported patterns: " + fullTransactionPatterns.keySet());
        }
        return IvyPatternHelper.substitute(destPattern, mrid, artifact);
    } else {
        return super.getDestination(pattern, artifact, mrid);
    }
}
 
Example #25
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public ModuleEntry[] listModules(OrganisationEntry org) {
    Map<String, String> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
    Collection<String> names = findNames(tokenValues, IvyPatternHelper.MODULE_KEY);
    List<ModuleEntry> ret = new ArrayList<>(names.size());
    for (String name : names) {
        ret.add(new ModuleEntry(org, name));
    }
    return ret.toArray(new ModuleEntry[names.size()]);
}
 
Example #26
Source File: AntCallTrigger.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
public void progress(IvyEvent event) {
    Project project = (Project) IvyContext.peekInContextStack(IvyTask.ANT_PROJECT_CONTEXT_KEY);
    if (project == null) {
        Message.info("ant call trigger can only be used from an ant build. Ignoring.");
        return;
    }
    if (onlyonce && isTriggered(event)) {
        Message.verbose("call already triggered for this event, skipping: " + event);
    } else {
        CallTarget call = new CallTarget();

        call.setProject(project);
        call.setTaskName("antcall");

        Map<String, String> attributes = event.getAttributes();
        String target = IvyPatternHelper.substituteTokens(getTarget(), attributes);
        call.setTarget(target);

        for (Map.Entry<String, String> entry : attributes.entrySet()) {
            Property p = call.createParam();
            p.setName(prefix == null ? entry.getKey() : prefix + entry.getKey());
            p.setValue(entry.getValue() == null ? "" : entry.getValue());
        }

        Message.verbose("triggering ant call: target=" + target + " for " + event);
        call.execute();
        markTriggered(event);

        Message.debug("triggered ant call finished: target=" + target + " for " + event);
    }
}
 
Example #27
Source File: BasicResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@Override
public RevisionEntry[] listRevisions(ModuleEntry mod) {
    Map<String, String> tokenValues = new HashMap<>();
    tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, mod.getOrganisation());
    tokenValues.put(IvyPatternHelper.MODULE_KEY, mod.getModule());
    Collection<String> names = findNames(tokenValues, IvyPatternHelper.REVISION_KEY);
    List<RevisionEntry> ret = new ArrayList<>(names.size());
    for (String name : names) {
        ret.add(new RevisionEntry(mod, name));
    }
    return ret.toArray(new RevisionEntry[names.size()]);
}
 
Example #28
Source File: AbstractPatternsBasedResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected Collection<String> findIvyNames(Map<String, String> tokenValues, String token) {
    Collection<String> names = new HashSet<>();
    tokenValues = new HashMap<>(tokenValues);
    tokenValues.put(IvyPatternHelper.ARTIFACT_KEY, "ivy");
    tokenValues.put(IvyPatternHelper.TYPE_KEY, "ivy");
    tokenValues.put(IvyPatternHelper.EXT_KEY, "xml");
    if (isM2compatible()) {
        convertM2TokenValuesForResourceSearch(tokenValues);
    }
    findTokenValues(names, getIvyPatterns(), tokenValues, token);
    filterNames(names);
    return names;
}
 
Example #29
Source File: AbstractPatternsBasedResolver.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
    Set<Map<String, String>> result = new LinkedHashSet<>();

    // use ivy patterns
    Map<String, Object> subcriteria = new HashMap<>(criteria);
    subcriteria.put(IvyPatternHelper.TYPE_KEY, "ivy");
    subcriteria.put(IvyPatternHelper.EXT_KEY, getModuleDescriptorExtension());
    if (isM2compatible()) {
        convertM2CriteriaForResourceSearch(subcriteria);
    }
    for (String ivyPattern : getIvyPatterns()) {
        result.addAll(resolveTokenValues(tokens, ivyPattern, subcriteria, false));
    }

    if (isAllownomd()) {
        subcriteria = new HashMap<>(criteria);
        subcriteria.put(IvyPatternHelper.TYPE_KEY, "jar");
        subcriteria.put(IvyPatternHelper.EXT_KEY, "jar");
        if (isM2compatible()) {
            convertM2CriteriaForResourceSearch(subcriteria);
        }
        for (String artifactPattern : getArtifactPatterns()) {
            result.addAll(resolveTokenValues(tokens, artifactPattern, subcriteria, true));
        }
    }

    return result.toArray(new Map[result.size()]);
}
 
Example #30
Source File: ModuleId.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor.
 *
 * @param organisation
 *            The organisation which creates the module.
 * @param name
 *            The name of the module.
 */
public ModuleId(String organisation, String name) {
    if (name == null) {
        throw new IllegalArgumentException("null name not allowed");
    }
    this.organisation = organisation;
    this.name = name;
    attributes.put(IvyPatternHelper.ORGANISATION_KEY, organisation);
    attributes.put(IvyPatternHelper.MODULE_KEY, name);
}