Java Code Examples for org.apache.ivy.plugins.matcher.PatternMatcher#ANY_EXPRESSION

The following examples show how to use org.apache.ivy.plugins.matcher.PatternMatcher#ANY_EXPRESSION . 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: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addArtifact(String groupId, String artifactId, String version) throws Exception {

		artifacts.add(groupId+":"+artifactId+":"+version);

		String[] dep = null;
		dep = new String[] { groupId, artifactId, version };
		if (md == null) {
			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);
		md.addDependency(dd);
		ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"),
				PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
				ExactPatternMatcher.INSTANCE, null);
		dd.addExcludeRule(null, er);
	}
 
Example 2
Source File: IvyConfigurationProvider.java    From walkmod-core with GNU Lesser General Public License v3.0 6 votes vote down vote up
public void addArtifact(String groupId, String artifactId, String version) throws Exception {

		artifacts.add(groupId+":"+artifactId+":"+version);

		String[] dep = null;
		dep = new String[] { groupId, artifactId, version };
		if (md == null) {
			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);
		md.addDependency(dd);
		ExcludeRule er = new DefaultExcludeRule(new ArtifactId(new ModuleId("org.walkmod", "walkmod-core"),
				PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
				ExactPatternMatcher.INSTANCE, null);
		dd.addExcludeRule(null, er);
	}
 
Example 3
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
protected void mediationOverrideStarted(Attributes attributes) {
    String org = settings.substitute(attributes.getValue("org"));
    if (org == null) {
        org = PatternMatcher.ANY_EXPRESSION;
    }
    String mod = settings.substitute(attributes.getValue("module"));
    if (mod == null) {
        mod = PatternMatcher.ANY_EXPRESSION;
    }
    String rev = settings.substitute(attributes.getValue("rev"));
    String branch = settings.substitute(attributes.getValue("branch"));
    String matcherName = settings.substitute(attributes.getValue("matcher"));
    PatternMatcher matcher = (matcherName == null) ? defaultMatcher
            : settings.getMatcher(matcherName);
    if (matcher == null) {
        addError("unknown matcher: " + matcherName);
        return;
    }
    getMd().addDependencyDescriptorMediator(new ModuleId(org, mod), matcher,
        new OverrideDependencyDescriptorMediator(branch, rev));
}
 
Example 4
Source File: IvyTranslations.java    From jeka with Apache License 2.0 6 votes vote down vote up
private static DefaultExcludeRule toExcludeRule(JkDepExclude depExclude, Iterable<String> allRootConfs) {
    final String type = depExclude.getType() == null ? PatternMatcher.ANY_EXPRESSION : depExclude
            .getType();
    final String ext = depExclude.getExt() == null ? PatternMatcher.ANY_EXPRESSION : depExclude
            .getExt();
    final ArtifactId artifactId = new ArtifactId(toModuleId(depExclude.getModuleId()), "*", type,
            ext);
    final DefaultExcludeRule result = new DefaultExcludeRule(artifactId,
            ExactPatternMatcher.INSTANCE, null);
    for (final JkScope scope : depExclude.getScopes()) {
        result.addConfiguration(scope.getName());
    }
    if (depExclude.getScopes().isEmpty()) {
        for (final String conf : allRootConfs) {
            result.addConfiguration(conf);
        }

    }
    return result;
}
 
Example 5
Source File: IvyConflict.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
void addConflict(DefaultModuleDescriptor md, IvySettings settings) {
    String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
    String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
    String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
    ConflictManager cm = null;
    if (rev != null) {
        cm = new FixedConflictManager(splitToArray(rev));
    } else if (manager != null) {
        cm = settings.getConflictManager(manager);
    }
    md.addConflictManager(new ModuleId(orgPattern, modulePattern),
        settings.getMatcher(matcherName), cm);
}
 
Example 6
Source File: XmlModuleDescriptorParser.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
protected void managerStarted(Attributes attributes, String managerAtt) {
    String org = settings.substitute(attributes.getValue("org"));
    if (org == null) {
        org = PatternMatcher.ANY_EXPRESSION;
    }
    String mod = settings.substitute(attributes.getValue("module"));
    if (mod == null) {
        mod = PatternMatcher.ANY_EXPRESSION;
    }
    ConflictManager cm;
    String name = settings.substitute(attributes.getValue(managerAtt));
    String rev = settings.substitute(attributes.getValue("rev"));
    if (rev != null) {
        cm = new FixedConflictManager(splitToArray(rev));
    } else if (name != null) {
        cm = settings.getConflictManager(name);
        if (cm == null) {
            addError("unknown conflict manager: " + name);
            return;
        }
    } else {
        addError("bad conflict manager: no manager nor rev");
        return;
    }
    String matcherName = settings.substitute(attributes.getValue("matcher"));
    PatternMatcher matcher = (matcherName == null) ? defaultMatcher
            : settings.getMatcher(matcherName);
    if (matcher == null) {
        addError("unknown matcher: " + matcherName);
        return;
    }
    getMd().addConflictManager(new ModuleId(org, mod), matcher, cm);
}
 
Example 7
Source File: IvyNodeUsage.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
private static IncludeRule includeAllArtifacts() {
    final ArtifactId aid = new ArtifactId(
            new ModuleId(PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION),
            PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION);
    return new DefaultIncludeRule(aid, ExactPatternMatcher.INSTANCE, null);
}
 
Example 8
Source File: IvyDependencyArtifact.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
void addArtifact(DefaultDependencyDescriptor dd, String masterConf) {
    String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
    String extPattern = ext == null ? typePattern : ext;
    URL u;
    try {
        u = url == null ? null : new URL(url);
    } catch (MalformedURLException e) {
        throw new BuildException("Malformed url in the artifact: " + e.getMessage(), e);
    }
    DefaultDependencyArtifactDescriptor dad = new DefaultDependencyArtifactDescriptor(dd, name,
            typePattern, extPattern, u, null);
    dd.addDependencyArtifact(masterConf, dad);
}
 
Example 9
Source File: IvyExclude.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
DefaultExcludeRule asRule(IvySettings settings) {
    String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
    String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
    String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
    String artifactPattern = (artifact == null) ? PatternMatcher.ANY_EXPRESSION : artifact;
    String typePattern = (type == null) ? PatternMatcher.ANY_EXPRESSION : type;
    String extPattern = (ext == null) ? typePattern : ext;
    ArtifactId aid = new ArtifactId(new ModuleId(orgPattern, modulePattern), artifactPattern,
            typePattern, extPattern);
    return new DefaultExcludeRule(aid, settings.getMatcher(matcherName), null);
}
 
Example 10
Source File: DefaultExcludeRuleConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultExcludeRule createExcludeRule(String configurationName, ExcludeRule excludeRule) {
    String org = GUtil.elvis(excludeRule.getGroup(), PatternMatcher.ANY_EXPRESSION);
    String module = GUtil.elvis(excludeRule.getModule(), PatternMatcher.ANY_EXPRESSION);
    DefaultExcludeRule ivyExcludeRule = new DefaultExcludeRule(new ArtifactId(
            IvyUtil.createModuleId(org, module), PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION),
            ExactPatternMatcher.INSTANCE, null);
    ivyExcludeRule.addConfiguration(configurationName);
    return ivyExcludeRule;
}
 
Example 11
Source File: IvyDependencyInclude.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
DefaultIncludeRule asRule(IvySettings settings) {
    String matcherName = matcher == null ? PatternMatcher.EXACT : matcher;
    String namePattern = name == null ? PatternMatcher.ANY_EXPRESSION : name;
    String typePattern = type == null ? PatternMatcher.ANY_EXPRESSION : type;
    String extPattern = ext == null ? typePattern : ext;
    ArtifactId aid = new ArtifactId(new ModuleId(PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION), namePattern, typePattern, extPattern);
    return new DefaultIncludeRule(aid, settings.getMatcher(matcherName), null);
}
 
Example 12
Source File: IvyDependencyExclude.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
DefaultExcludeRule asRule(IvySettings settings) {
    String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
    String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
    String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
    String namePattern = (name == null) ? PatternMatcher.ANY_EXPRESSION : name;
    String typePattern = (type == null) ? PatternMatcher.ANY_EXPRESSION : type;
    String extPattern = (ext == null) ? typePattern : ext;
    ArtifactId aid = new ArtifactId(new ModuleId(orgPattern, modulePattern), namePattern,
            typePattern, extPattern);
    return new DefaultExcludeRule(aid, settings.getMatcher(matcherName), null);
}
 
Example 13
Source File: IvyOverride.java    From ant-ivy with Apache License 2.0 5 votes vote down vote up
void addOverride(DefaultModuleDescriptor md, IvySettings settings) {
    String matcherName = (matcher == null) ? PatternMatcher.EXACT : matcher;
    String orgPattern = (org == null) ? PatternMatcher.ANY_EXPRESSION : org;
    String modulePattern = (module == null) ? PatternMatcher.ANY_EXPRESSION : module;
    md.addDependencyDescriptorMediator(new ModuleId(orgPattern, modulePattern),
        settings.getMatcher(matcherName), new OverrideDependencyDescriptorMediator(branch, rev));
}
 
Example 14
Source File: DefaultExcludeRuleConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultExcludeRule createExcludeRule(String configurationName, ExcludeRule excludeRule) {
    String org = GUtil.elvis(excludeRule.getGroup(), PatternMatcher.ANY_EXPRESSION);
    String module = GUtil.elvis(excludeRule.getModule(), PatternMatcher.ANY_EXPRESSION);
    DefaultExcludeRule ivyExcludeRule = new DefaultExcludeRule(new ArtifactId(
            IvyUtil.createModuleId(org, module), PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION),
            ExactPatternMatcher.INSTANCE, null);
    ivyExcludeRule.addConfiguration(configurationName);
    return ivyExcludeRule;
}
 
Example 15
Source File: DefaultExcludeRuleConverter.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultExcludeRule createExcludeRule(String configurationName, ExcludeRule excludeRule) {
    String org = GUtil.elvis(excludeRule.getGroup(), PatternMatcher.ANY_EXPRESSION);
    String module = GUtil.elvis(excludeRule.getModule(), PatternMatcher.ANY_EXPRESSION);
    DefaultExcludeRule ivyExcludeRule = new DefaultExcludeRule(new ArtifactId(
            IvyUtil.createModuleId(org, module), PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION),
            ExactPatternMatcher.INSTANCE, null);
    ivyExcludeRule.addConfiguration(configurationName);
    return ivyExcludeRule;
}
 
Example 16
Source File: DefaultExcludeRuleConverter.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultExcludeRule createExcludeRule(String configurationName, ExcludeRule excludeRule) {
    String org = GUtil.elvis(excludeRule.getGroup(), PatternMatcher.ANY_EXPRESSION);
    String module = GUtil.elvis(excludeRule.getModule(), PatternMatcher.ANY_EXPRESSION);
    DefaultExcludeRule ivyExcludeRule = new DefaultExcludeRule(new ArtifactId(
            IvyUtil.createModuleId(org, module), PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION,
            PatternMatcher.ANY_EXPRESSION),
            ExactPatternMatcher.INSTANCE, null);
    ivyExcludeRule.addConfiguration(configurationName);
    return ivyExcludeRule;
}
 
Example 17
Source File: IvyInstall.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void doExecute() throws BuildException {
    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    if (organisation == null) {
        throw new BuildException("no organisation provided for ivy publish task: "
                + "It can either be set explicitly via the attribute 'organisation' "
                + "or via 'ivy.organisation' property or a prior call to <resolve/>");
    }
    if (module == null) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            throw new BuildException("no module name provided for ivy publish task: "
                    + "It can either be set explicitly via the attribute 'module' "
                    + "or via 'ivy.module' property or a prior call to <resolve/>");
        }
        module = PatternMatcher.ANY_EXPRESSION;
    }
    if (revision == null) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            throw new BuildException("no module revision provided for ivy publish task: "
                    + "It can either be set explicitly via the attribute 'revision' "
                    + "or via 'ivy.revision' property or a prior call to <resolve/>");
        }
        revision = PatternMatcher.ANY_EXPRESSION;
    }
    if (branch == null) {
        if (PatternMatcher.EXACT.equals(matcher)) {
            branch = settings.getDefaultBranch(ModuleId.newInstance(organisation, module));
        } else {
            branch = PatternMatcher.ANY_EXPRESSION;
        }
    }
    if (from == null) {
        throw new BuildException(
                "no from resolver name: please provide it through parameter 'from'");
    }
    if (to == null) {
        throw new BuildException(
                "no to resolver name: please provide it through parameter 'to'");
    }
    ModuleRevisionId mrid = ModuleRevisionId
            .newInstance(organisation, module, branch, revision);

    ResolveReport report;
    try {
        report = ivy.install(
            mrid,
            from,
            to,
            new InstallOptions().setTransitive(transitive).setValidate(doValidate(settings))
                    .setOverwrite(overwrite).setConfs(conf.split(","))
                    .setArtifactFilter(FilterHelper.getArtifactTypeFilter(type))
                    .setMatcherName(matcher)
                    .setInstallOriginalMetadata(installOriginalMetadata));
    } catch (Exception e) {
        throw new BuildException("impossible to install " + mrid + ": " + e, e);
    }

    if (report.hasError() && isHaltonfailure()) {
        throw new BuildException(
                "Problem happened while installing modules - see output for details");
    }
}
 
Example 18
Source File: BundleInfoAdapter.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
/**
 * @param parser ModuleDescriptorParser
 * @param baseUri
 *            uri to help build the absolute url if the bundle info has a relative uri.
 * @param bundle BundleInfo
 * @param manifest Manifest
 * @param profileProvider ExecutionEnvironmentProfileProvider
 * @return DefaultModuleDescriptor ditto
 * @throws ProfileNotFoundException if descriptor is not found
 */
public static DefaultModuleDescriptor toModuleDescriptor(ModuleDescriptorParser parser,
        URI baseUri, BundleInfo bundle, Manifest manifest,
        ExecutionEnvironmentProfileProvider profileProvider) throws ProfileNotFoundException {
    DefaultModuleDescriptor md = new DefaultModuleDescriptor(parser, null);
    md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
    ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE, bundle.getSymbolicName(),
        bundle.getVersion());
    md.setResolvedPublicationDate(new Date());
    md.setModuleRevisionId(mrid);

    md.addConfiguration(CONF_DEFAULT);
    md.addConfiguration(CONF_OPTIONAL);
    md.addConfiguration(CONF_TRANSITIVE_OPTIONAL);

    Set<String> exportedPkgNames = new HashSet<>(bundle.getExports().size());
    for (ExportPackage exportPackage : bundle.getExports()) {
        md.getExtraInfos().add(
            new ExtraInfoHolder(EXTRA_INFO_EXPORT_PREFIX + exportPackage.getName(),
                    exportPackage.getVersion().toString()));
        exportedPkgNames.add(exportPackage.getName());
        String[] confDependencies = new String[exportPackage.getUses().size() + 1];
        int i = 0;
        for (String use : exportPackage.getUses()) {
            confDependencies[i++] = CONF_USE_PREFIX + use;
        }
        confDependencies[i] = CONF_NAME_DEFAULT;
        md.addConfiguration(new Configuration(CONF_USE_PREFIX + exportPackage.getName(),
                PUBLIC, "Exported package " + exportPackage.getName(),
                confDependencies, true, null));
    }

    requirementAsDependency(md, bundle, exportedPkgNames);

    if (baseUri != null) {
        for (BundleArtifact bundleArtifact : bundle.getArtifacts()) {
            String type = "jar";
            String ext = "jar";
            String packaging = null;
            if (bundle.hasInnerClasspath() && !bundleArtifact.isSource()) {
                packaging = "bundle";
            }
            if ("packed".equals(bundleArtifact.getFormat())) {
                ext = "jar.pack.gz";
                if (packaging != null) {
                    packaging += ",pack200";
                } else {
                    packaging = "pack200";
                }
            }
            if (bundleArtifact.isSource()) {
                type = "source";
            }
            URI uri = bundleArtifact.getUri();
            if (uri != null) {
                DefaultArtifact artifact = buildArtifact(mrid, baseUri, uri, type, ext,
                    packaging);
                md.addArtifact(CONF_NAME_DEFAULT, artifact);
            }
        }
    }

    if (profileProvider != null) {
        for (String env : bundle.getExecutionEnvironments()) {
            ExecutionEnvironmentProfile profile = profileProvider.getProfile(env);
            if (profile == null) {
                throw new ProfileNotFoundException("Execution environment profile " + env
                        + " not found");
            }
            for (String pkg : profile.getPkgNames()) {
                ArtifactId id = new ArtifactId(ModuleId.newInstance(BundleInfo.PACKAGE_TYPE,
                    pkg), PatternMatcher.ANY_EXPRESSION, PatternMatcher.ANY_EXPRESSION,
                        PatternMatcher.ANY_EXPRESSION);
                DefaultExcludeRule rule = new DefaultExcludeRule(id,
                        ExactOrRegexpPatternMatcher.INSTANCE, null);
                for (String conf : md.getConfigurationsNames()) {
                    rule.addConfiguration(conf);
                }
                md.addExcludeRule(rule);
            }
        }
    }

    if (manifest != null) {
        for (Map.Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
            md.addExtraInfo(new ExtraInfoHolder(entries.getKey().toString(), entries.getValue()
                    .toString()));
        }
    }

    return md;
}
 
Example 19
Source File: IvyRepositoryReport.java    From ant-ivy with Apache License 2.0 4 votes vote down vote up
public void doExecute() throws BuildException {
    Ivy ivy = getIvyInstance();
    IvySettings settings = ivy.getSettings();
    if (xsl && xslFile == null) {
        throw new BuildException("xsl file is mandatory when using xsl generation");
    }
    if (module == null && PatternMatcher.EXACT.equals(matcher)) {
        throw new BuildException("no module name provided for ivy repository graph task: "
                + "It can either be set explicitly via the attribute 'module' or "
                + "via 'ivy.module' property or a prior call to <resolve/>");
    } else if (module == null && !PatternMatcher.EXACT.equals(matcher)) {
        module = PatternMatcher.ANY_EXPRESSION;
    }
    ModuleRevisionId moduleRevisionId = ModuleRevisionId.newInstance(organisation, module, revision);

    try {
        ModuleRevisionId criteria = (revision == null) || settings.getVersionMatcher().isDynamic(moduleRevisionId)
                ? new ModuleRevisionId(new ModuleId(organisation, module), branch, "*")
                : new ModuleRevisionId(new ModuleId(organisation, module), branch, revision);

        ModuleRevisionId[] mrids = ivy.listModules(criteria, settings.getMatcher(matcher));

        // replace all found revisions with the original requested revision
        Set<ModuleRevisionId> modules = new HashSet<>();
        for (ModuleRevisionId mrid : mrids) {
            modules.add(ModuleRevisionId.newInstance(mrid, revision));
        }

        mrids = modules.toArray(new ModuleRevisionId[modules.size()]);
        ModuleDescriptor md = DefaultModuleDescriptor.newCallerInstance(mrids, true, false);
        String resolveId = ResolveOptions.getDefaultResolveId(md);
        ResolveReport report = ivy.resolve(md, new ResolveOptions().setResolveId(resolveId)
                .setValidate(doValidate(settings)));

        ResolutionCacheManager cacheMgr = getIvyInstance().getResolutionCacheManager();
        new XmlReportOutputter().output(report, cacheMgr, new ResolveOptions());
        if (graph) {
            gengraph(cacheMgr, md.getModuleRevisionId().getOrganisation(),
                    md.getModuleRevisionId().getName());
        }
        if (dot) {
            gendot(cacheMgr, md.getModuleRevisionId().getOrganisation(),
                    md.getModuleRevisionId().getName());
        }
        if (xml) {
            FileUtil.copy(cacheMgr.getConfigurationResolveReportInCache(resolveId, "default"),
                new File(getTodir(), outputname + ".xml"), null);
        }
        if (xsl) {
            genreport(cacheMgr, md.getModuleRevisionId().getOrganisation(),
                    md.getModuleRevisionId().getName());
        }
    } catch (Exception e) {
        throw new BuildException("impossible to generate graph for " + moduleRevisionId + ": " + e, e);
    }
}