private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) { Dependency mavenDependency = new Dependency(); mavenDependency.setGroupId(dependency.getGroupId()); mavenDependency.setArtifactId(artifactId); mavenDependency.setVersion(mapToMavenSyntax(dependency.getVersion())); mavenDependency.setType(type); mavenDependency.setScope(scope); mavenDependency.setClassifier(classifier); for (ExcludeRule excludeRule : dependency.getExcludeRules()) { Exclusion exclusion = new Exclusion(); exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*")); exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*")); mavenDependency.addExclusion(exclusion); } getModel().addDependency(mavenDependency); }
private void writeDependencies(OptionalAttributeXmlWriter xmlWriter) throws IOException { xmlWriter.startElement("dependencies"); for (IvyDependencyInternal dependency : dependencies) { xmlWriter.startElement("dependency") .attribute("org", dependency.getOrganisation()) .attribute("name", dependency.getModule()) .attribute("rev", dependency.getRevision()) .attribute("conf", dependency.getConfMapping()); if (!dependency.isTransitive()) { xmlWriter.attribute("transitive", "false"); } for (DependencyArtifact dependencyArtifact : dependency.getArtifacts()) { printDependencyArtifact(dependencyArtifact, xmlWriter); } for(ExcludeRule excludeRule : dependency.getExcludeRules()) { writeDependencyExclude(excludeRule, xmlWriter); } xmlWriter.endElement(); } xmlWriter.endElement(); }
private void addDependency(MavenDependencyInternal dependency, String artifactId, String scope, String type, String classifier) { Dependency mavenDependency = new Dependency(); mavenDependency.setGroupId(dependency.getGroupId()); mavenDependency.setArtifactId(artifactId); mavenDependency.setVersion(dependency.getVersion()); mavenDependency.setType(type); mavenDependency.setScope(scope); mavenDependency.setClassifier(classifier); for (ExcludeRule excludeRule : dependency.getExcludeRules()) { Exclusion exclusion = new Exclusion(); exclusion.setGroupId(GUtil.elvis(excludeRule.getGroup(), "*")); exclusion.setArtifactId(GUtil.elvis(excludeRule.getModule(), "*")); mavenDependency.addExclusion(exclusion); } getModel().addDependency(mavenDependency); }
public Exclusion convert(ExcludeRule excludeRule) { if (isConvertable(excludeRule)) { Exclusion exclusion = new Exclusion(); exclusion.setGroupId(determineExclusionExpression(excludeRule.getGroup())); exclusion.setArtifactId(determineExclusionExpression(excludeRule.getModule())); return exclusion; } return null; }
protected List<Exclude> convertExcludeRules(final String configuration, Set<ExcludeRule> excludeRules) { return CollectionUtils.collect((Iterable<ExcludeRule>) excludeRules, new Transformer<Exclude, ExcludeRule>() { @Override public Exclude transform(ExcludeRule excludeRule) { return excludeRuleConverter.convertExcludeRule(configuration, excludeRule); } }); }
protected ExcludeRule parseMap(@MapKey(ExcludeRule.GROUP_KEY) @Optional String group, @MapKey(ExcludeRule.MODULE_KEY) @Optional String module) { if (group == null && module == null) { throw new InvalidUserDataException("Dependency exclude rule requires 'group' and/or 'module' specified. For example: [group: 'com.google.collections']"); } return new DefaultExcludeRule(group, module); }
public Exclusion convert(ExcludeRule excludeRule) { if (isConvertable(excludeRule)) { Exclusion exclusion = new Exclusion(); exclusion.setGroupId(excludeRule.getGroup()); exclusion.setArtifactId(excludeRule.getModule()); return exclusion; } return null; }
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; }
private void addExcludes(String configuration, Set<ExcludeRule> excludeRules, DefaultDependencyDescriptor dependencyDescriptor) { for (ExcludeRule excludeRule : excludeRules) { dependencyDescriptor.addExcludeRule(configuration, excludeRuleConverter.createExcludeRule(configuration, excludeRule)); } }
private void addExcludeRules(MutableLocalComponentMetaData metaData, Collection<? extends Configuration> configurations) { for (Configuration configuration : configurations) { for (ExcludeRule excludeRule : configuration.getExcludeRules()) { org.apache.ivy.core.module.descriptor.ExcludeRule rule = excludeRuleConverter.createExcludeRule( configuration.getName(), excludeRule); metaData.addExcludeRule(rule); } } }
private void addExcludeRules(DefaultModuleDescriptor moduleDescriptor, Collection<? extends Configuration> configurations) { for (Configuration configuration : configurations) { for (ExcludeRule excludeRule : configuration.getExcludeRules()) { org.apache.ivy.core.module.descriptor.ExcludeRule rule = excludeRuleConverter.createExcludeRule( configuration.getName(), excludeRule); moduleDescriptor.addExcludeRule(rule); } } }
public Map<String, String> getExcludeArgs() { DeprecationLogger.nagUserOfDeprecated("The getExcludeArgs method", "Please use the getGroup() method or the getModule() method instead"); Map excludeArgsAsMap = new HashMap(); excludeArgsAsMap.put(ExcludeRule.GROUP_KEY, group); excludeArgsAsMap.put(ExcludeRule.MODULE_KEY, module); return excludeArgsAsMap; }
protected ExcludeRule parseMap(@MapKey(ExcludeRule.GROUP_KEY) @Optional String group, @MapKey(ExcludeRule.MODULE_KEY) @Optional String module) { if (group == null && module == null) { throw new InvalidUserDataException("Either a group or module must be specified. For example: [group:'org.gradle']"); } DefaultExcludeRule excluderule = new DefaultExcludeRule(); excluderule.setGroup(group); excluderule.setModule(module); return excluderule; }
private boolean isConvertable(ExcludeRule excludeRule) { return excludeRule.getGroup()!= null || excludeRule.getModule()!= null; }
public DefaultMavenDependency(String groupId, String artifactId, String version, Collection<DependencyArtifact> artifacts, Collection<ExcludeRule> excludeRules) { this(groupId, artifactId, version, artifacts); this.excludeRules.addAll(excludeRules); }
public Collection<ExcludeRule> getExcludeRules() { return excludeRules; }
private void addExcludeRules(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) { for (ExcludeRule excludeRule : configuration.getExcludeRules()) { metaData.addExclude(excludeRuleConverter.convertExcludeRule(configuration.getName(), excludeRule)); } }
public DefaultExclude convertExcludeRule(String configurationName, ExcludeRule excludeRule) { String org = GUtil.elvis(excludeRule.getGroup(), PatternMatchers.ANY_EXPRESSION); String module = GUtil.elvis(excludeRule.getModule(), PatternMatchers.ANY_EXPRESSION); return new DefaultExclude(org, module, new String[] {configurationName}, PatternMatchers.EXACT); }
public Set<ExcludeRule> getExcludeRules() { return Collections.unmodifiableSet(excludeRules); }
public void setExcludeRules(Set<ExcludeRule> excludeRules) { validateMutation(MutationType.DEPENDENCIES); this.excludeRules = excludeRules; }
private DefaultConfiguration createCopy(Set<Dependency> dependencies, boolean recursive) { DetachedConfigurationsProvider configurationsProvider = new DetachedConfigurationsProvider(); String newName = name + "Copy"; Path newIdentityPath = identityPath.getParent().child(newName); Path newPath = path.getParent().child(newName); DefaultConfiguration copiedConfiguration = instantiator.newInstance(DefaultConfiguration.class, newIdentityPath, newPath, newName, configurationsProvider, resolver, listenerManager, metaDataProvider, resolutionStrategy.copy(), projectAccessListener, projectFinder, configurationComponentMetaDataBuilder, fileCollectionFactory, componentIdentifierFactory, buildOperationExecutor, instantiator, artifactNotationParser); configurationsProvider.setTheOnlyConfiguration(copiedConfiguration); // state, cachedResolvedConfiguration, and extendsFrom intentionally not copied - must re-resolve copy // copying extendsFrom could mess up dependencies when copy was re-resolved copiedConfiguration.visible = visible; copiedConfiguration.transitive = transitive; copiedConfiguration.description = description; copiedConfiguration.defaultDependencyActions.addAll(defaultDependencyActions); copiedConfiguration.canBeConsumed = canBeConsumed; copiedConfiguration.canBeResolved = canBeResolved; copiedConfiguration.getArtifacts().addAll(getAllArtifacts()); if (hasAttributes()) { for (Attribute<?> attribute : configurationAttributes.keySet()) { Object value = configurationAttributes.getAttribute(attribute); copiedConfiguration.attribute(Cast.<Attribute<Object>>uncheckedCast(attribute), value); } } // todo An ExcludeRule is a value object but we don't enforce immutability for DefaultExcludeRule as strong as we // should (we expose the Map). We should provide a better API for ExcludeRule (I don't want to use unmodifiable Map). // As soon as DefaultExcludeRule is truly immutable, we don't need to create a new instance of DefaultExcludeRule. Set<Configuration> excludeRuleSources = new LinkedHashSet<Configuration>(); excludeRuleSources.add(this); if (recursive) { excludeRuleSources.addAll(getHierarchy()); } for (Configuration excludeRuleSource : excludeRuleSources) { for (ExcludeRule excludeRule : excludeRuleSource.getExcludeRules()) { copiedConfiguration.excludeRules.add(new DefaultExcludeRule(excludeRule.getGroup(), excludeRule.getModule())); } } DomainObjectSet<Dependency> copiedDependencies = copiedConfiguration.getDependencies(); for (Dependency dependency : dependencies) { copiedDependencies.add(dependency.copy()); } return copiedConfiguration; }
private void writeDependencyExclude(ExcludeRule excludeRule, OptionalAttributeXmlWriter xmlWriter) throws IOException { xmlWriter.startElement("exclude") .attribute("org", excludeRule.getGroup()) .attribute("module", excludeRule.getModule()) .endElement(); }
public DefaultIvyDependency(String organisation, String module, String revision, String confMapping, boolean transitive, Collection<DependencyArtifact> artifacts, Collection<ExcludeRule> excludeRules) { this(organisation, module, revision, confMapping, transitive, artifacts); this.excludeRules.addAll(excludeRules); }
public Iterable<ExcludeRule> getExcludeRules() { return excludeRules; }
public DefaultExcludeRuleContainer(Set<ExcludeRule> addedRules) { this.addedRules = new HashSet<ExcludeRule>(addedRules); }
public void add(Map<String, String> args) { if (addedRules == null) { addedRules = new HashSet<ExcludeRule>(); } addedRules.add(ExcludeRuleNotationConverter.parser().parseNotation(args)); }
public Set<ExcludeRule> getRules() { return addedRules == null ? Collections.<ExcludeRule>emptySet() : addedRules; }
public Set<ExcludeRule> getExcludeRules() { return excludeRuleContainer.getRules(); }
public static NotationParser<Object, ExcludeRule> parser() { return PARSER; }
private boolean isConvertable(ExcludeRule excludeRule) { return excludeRule.getGroup()!=null && excludeRule.getModule()!=null; }
public Set<ExcludeRule> getRules() { return addedRules; }