public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) { ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency; projectDependency.beforeResolved(); Module module = getProjectModule(dependency); ModuleVersionSelector requested = new DefaultModuleVersionSelector(module.getGroup(), module.getName(), module.getVersion()); ComponentSelector selector = DefaultProjectComponentSelector.newSelector(projectDependency.getDependencyProject()); LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata( selector, requested, clientConfiguration, clientAttributes, projectDependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), convertExcludeRules(clientConfiguration, dependency.getExcludeRules()), false, false, dependency.isTransitive()); return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency); }
public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer clientAttributes, ModuleDependency dependency) { ExternalModuleDependency externalModuleDependency = (ExternalModuleDependency) dependency; boolean force = externalModuleDependency.isForce(); boolean changing = externalModuleDependency.isChanging(); boolean transitive = externalModuleDependency.isTransitive(); ModuleVersionSelector requested = new DefaultModuleVersionSelector(nullToEmpty(dependency.getGroup()), nullToEmpty(dependency.getName()), nullToEmpty(dependency.getVersion())); ModuleComponentSelector selector = DefaultModuleComponentSelector.newSelector(requested); LocalComponentDependencyMetadata dependencyMetaData = new LocalComponentDependencyMetadata( selector, requested, clientConfiguration, clientAttributes, dependency.getTargetConfiguration(), convertArtifacts(dependency.getArtifacts()), convertExcludeRules(clientConfiguration, dependency.getExcludeRules()), force, changing, transitive); return new DslOriginDependencyMetadataWrapper(dependencyMetaData, dependency); }
protected boolean isKeyEquals(ModuleDependency dependencyRhs) { if (getGroup() != null ? !getGroup().equals(dependencyRhs.getGroup()) : dependencyRhs.getGroup() != null) { return false; } if (!getName().equals(dependencyRhs.getName())) { return false; } if (getTargetConfiguration() != null ? !getTargetConfiguration().equals(dependencyRhs.getTargetConfiguration()) : dependencyRhs.getTargetConfiguration()!=null) { return false; } if (getVersion() != null ? !getVersion().equals(dependencyRhs.getVersion()) : dependencyRhs.getVersion() != null) { return false; } return true; }
protected boolean isCommonContentEquals(ModuleDependency dependencyRhs) { if (!isKeyEquals(dependencyRhs)) { return false; } if (isTransitive() != dependencyRhs.isTransitive()) { return false; } if (getArtifacts() != null ? !getArtifacts().equals(dependencyRhs.getArtifacts()) : dependencyRhs.getArtifacts() != null) { return false; } if (getExcludeRules() != null ? !getExcludeRules().equals(dependencyRhs.getExcludeRules()) : dependencyRhs.getExcludeRules() != null) { return false; } return true; }
/** * Add dependencies to the POM * * Adds all dependencies from the provided configuration with the provided scope to the POM and to the set of * existing dependencies. Dependencies are only added if they are not contained in the set of existing dependencies. * * @param dependencies Element to add dependencies to * @param configuration Configuration whose provides depencencies to add * @param scope Scope to use for added depencencies */ protected void addDependencies(Element dependencies, Configuration configuration, String scope) { for (@NonNull Dependency dependency : configuration.getDependencies()) { if (dependency instanceof ModuleDependency) { ModuleDependency moduleDependency = (ModuleDependency) dependency; if (moduleDependency.getArtifacts().isEmpty()) { addDependency(dependencies, moduleDependency, moduleDependency.getName(), null, "jar", scope); } else { for (DependencyArtifact artifact : moduleDependency.getArtifacts()) { addDependency(dependencies, moduleDependency, artifact.getName(), artifact.getClassifier(), artifact.getType(), scope); } } } } }
@TaskAction protected void deployProject() { Set<PublishArtifact> seenArtifacts = new HashSet<>(); for ( SoftwareComponent component : getProject().getComponents() ) { SoftwareComponentInternal internalComponent = (SoftwareComponentInternal) component; for ( UsageContext usage : internalComponent.getUsages() ) { Set<? extends ModuleDependency> dependencies = usage.getDependencies(); for ( PublishArtifact artifact : usage.getArtifacts() ) { if ( seenArtifacts.add( artifact ) ) { deploy( artifact, dependencies ); } } } } }
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
public void resolve(DependencyMetaData dependency, ComponentIdentifier identifier, BuildableComponentResolveResult result) { resolver.resolve(dependency, identifier, result); if (result.getFailure() != null) { return; } if (dependency instanceof DslOriginDependencyMetaData) { ModuleDependency maybeClientModule = ((DslOriginDependencyMetaData) dependency).getSource(); if (maybeClientModule instanceof ClientModule) { ClientModule clientModule = (ClientModule) maybeClientModule; MutableModuleComponentResolveMetaData clientModuleMetaData = ((MutableModuleComponentResolveMetaData)result.getMetaData()).copy(); addClientModuleDependencies(clientModule, clientModuleMetaData); setClientModuleArtifact(clientModuleMetaData); result.setMetaData(clientModuleMetaData); } } }
public EnhancedDependencyDescriptor createDependencyDescriptor(String configuration, ModuleDependency dependency, ModuleDescriptor parent) { ModuleRevisionId moduleRevisionId = createModuleRevisionId(dependency); ClientModule clientModule = getClientModule(dependency); MutableModuleVersionMetaData moduleVersionMetaData = clientModuleMetaDataFactory.createModuleDescriptor( moduleRevisionId, clientModule.getDependencies()); EnhancedDependencyDescriptor dependencyDescriptor = new ClientModuleDependencyDescriptor( clientModule, parent, moduleVersionMetaData, moduleRevisionId, clientModule.isForce(), false, clientModule.isTransitive()); addExcludesArtifactsAndDependencies(configuration, clientModule, dependencyDescriptor); return dependencyDescriptor; }
private Set<DependencyGraphNodeResult> getFirstLevelNodes(Spec<? super Dependency> dependencySpec) { Set<DependencyGraphNodeResult> matches = new LinkedHashSet<DependencyGraphNodeResult>(); TransientConfigurationResults graphResults = loadTransientGraphResults(selectedArtifacts); for (Map.Entry<ModuleDependency, DependencyGraphNodeResult> entry : graphResults.getFirstLevelDependencies().entrySet()) { if (dependencySpec.isSatisfiedBy(entry.getKey())) { matches.add(entry.getValue()); } } return matches; }
private void addClientModuleDependencies(ClientModule clientModule, MutableModuleComponentResolveMetadata clientModuleMetaData) { List<DependencyMetadata> dependencies = Lists.newArrayList(); for (ModuleDependency moduleDependency : clientModule.getDependencies()) { DependencyMetadata dependencyMetadata = dependencyDescriptorFactory.createDependencyDescriptor(moduleDependency.getTargetConfiguration(), null, moduleDependency); dependencies.add(dependencyMetadata); } clientModuleMetaData.setDependencies(dependencies); }
private IvyDependencyDescriptorFactory findFactoryForDependency(ModuleDependency dependency) { for (IvyDependencyDescriptorFactory ivyDependencyDescriptorFactory : dependencyDescriptorFactories) { if (ivyDependencyDescriptorFactory.canConvert(dependency)) { return ivyDependencyDescriptorFactory; } } throw new InvalidUserDataException("Can't map dependency of type: " + dependency.getClass()); }
private void addDependencies(BuildableLocalComponentMetadata metaData, ConfigurationInternal configuration) { AttributeContainerInternal attributes = configuration.getAttributes().asImmutable(); for (Dependency dependency : configuration.getDependencies()) { if (dependency instanceof ModuleDependency) { ModuleDependency moduleDependency = (ModuleDependency) dependency; metaData.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configuration.getName(), attributes, moduleDependency)); } else if (dependency instanceof FileCollectionDependency) { final FileCollectionDependency fileDependency = (FileCollectionDependency) dependency; metaData.addFiles(configuration.getName(), new DefaultLocalFileDependencyMetadata(fileDependency)); } else { throw new IllegalArgumentException("Cannot convert dependency " + dependency + " to local component dependency metadata."); } } }
@Override public ModuleDependency getModuleDependency(long nodeId) { ModuleDependency m = modulesMap.get(nodeId); if (m == null) { throw new IllegalArgumentException("Unable to find module dependency for id: " + nodeId); } return m; }
public void visitEdge(DependencyGraphNode resolvedConfiguration) { for (DependencyGraphEdge dependency : resolvedConfiguration.getIncomingEdges()) { if (dependency.getFrom() == root) { ModuleDependency moduleDependency = dependency.getModuleDependency(); builder.addFirstLevelDependency(moduleDependency, resolvedConfiguration); } } }
@Override public void addFirstLevelDependency(ModuleDependency moduleDependency, DependencyGraphNode dependency) { builder.firstLevelDependency(dependency.getNodeId()); //we don't serialise the module dependencies at this stage so we need to keep track //of the mapping module dependency <-> resolved dependency modulesMap.put(dependency.getNodeId(), moduleDependency); }
@Override public ModuleDependency getModuleDependency() { if (dependencyMetadata instanceof DslOriginDependencyMetadata) { return ((DslOriginDependencyMetadata) dependencyMetadata).getSource(); } return null; }
private static ClientModule extractClientModule(DependencyMetadata dependencyMetadata) { if (dependencyMetadata instanceof DslOriginDependencyMetadata) { ModuleDependency source = ((DslOriginDependencyMetadata) dependencyMetadata).getSource(); if (source instanceof ClientModule) { return (ClientModule) source; } } return null; }
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; configurations.maybeCreate("default"); for (Usage usage : this.component.getUsages()) { String conf = usage.getName(); configurations.maybeCreate(conf); configurations.getByName("default").extend(conf); for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact).setConf(conf); } for (ModuleDependency dependency : usage.getDependencies()) { // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id. String confMapping = String.format("%s->%s", conf, dependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : dependency.getTargetConfiguration()); if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency, confMapping); } else { addModuleDependency(dependency, confMapping); } } } }
public ClientModule copy() { DefaultClientModule copiedClientModule = new DefaultClientModule(getGroup(), getName(), getVersion(), getTargetConfiguration()); copyTo(copiedClientModule); for (ModuleDependency dependency : dependencies) { copiedClientModule.addDependency(dependency.copy()); } return copiedClientModule; }
private List<Artifact> getExclusionArtifacts( ModuleDependency dependency ) { return dependency.getExcludeRules().stream().map( exclusionRule -> { String groupId = exclusionRule.getGroup(); String artifactId = exclusionRule.getModule(); return new DefaultArtifact( groupId, artifactId ); } ).collect( Collectors.toList() ); }
private void addClientModuleDependencies(ClientModule clientModule, MutableModuleComponentResolveMetaData clientModuleMetaData) { List<DependencyMetaData> dependencies = Lists.newArrayList(); for (ModuleDependency moduleDependency : clientModule.getDependencies()) { DependencyMetaData dependencyMetaData = dependencyDescriptorFactory.createDependencyDescriptor(moduleDependency.getConfiguration(), clientModuleMetaData.getDescriptor(), moduleDependency); dependencies.add(dependencyMetaData); } clientModuleMetaData.setDependencies(dependencies); }
public ProjectDependencyMetaData createDependencyDescriptor(String configuration, ModuleDependency dependency, ModuleDescriptor parent) { ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency; projectDependency.beforeResolved(); ModuleRevisionId moduleRevisionId = createModuleRevisionId(dependency); DefaultDependencyDescriptor dependencyDescriptor = new DefaultDependencyDescriptor(parent, moduleRevisionId, false, false, dependency.isTransitive()); addExcludesArtifactsAndDependencies(configuration, dependency, dependencyDescriptor); return new DefaultProjectDependencyMetaData(dependencyDescriptor, projectDependency); }
public DslOriginDependencyMetaData createDependencyDescriptor(String configuration, ModuleDependency dependency, ModuleDescriptor parent) { ModuleRevisionId moduleRevisionId = createModuleRevisionId(dependency); DefaultDependencyDescriptor dependencyDescriptor = new DefaultDependencyDescriptor( parent, moduleRevisionId, getExternalModuleDependency(dependency).isForce(), getExternalModuleDependency(dependency).isChanging(), getExternalModuleDependency(dependency).isTransitive()); addExcludesArtifactsAndDependencies(configuration, getExternalModuleDependency(dependency), dependencyDescriptor); return new DefaultDslOriginDependencyMetaData(dependencyDescriptor, dependency); }
private void addDependencies(MutableLocalComponentMetaData metaData, Collection<? extends Configuration> configurations) { for (Configuration configuration : configurations) { for (ModuleDependency dependency : configuration.getDependencies().withType(ModuleDependency.class)) { metaData.addDependency(dependencyDescriptorFactory.createDependencyDescriptor(configuration.getName(), metaData.getModuleDescriptor(), dependency)); } } }
private void attachToParents(DependencyGraphBuilder.DependencyEdge dependency, DependencyGraphBuilder.ConfigurationNode childConfiguration, ResolvedConfigurationBuilder oldModelBuilder) { ResolvedConfigurationIdentifier parent = dependency.from.id; ResolvedConfigurationIdentifier child = childConfiguration.id; oldModelBuilder.addChild(parent, child); oldModelBuilder.addParentSpecificArtifacts(child, parent, getArtifacts(dependency, childConfiguration, oldModelBuilder)); if (parent == root.id) { ModuleDependency moduleDependency = dependency.getModuleDependency(); oldModelBuilder.addFirstLevelDependency(moduleDependency, child); } }
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; configurations.maybeCreate("default"); for (Usage usage : this.component.getUsages()) { String conf = usage.getName(); configurations.maybeCreate(conf); configurations.getByName("default").extend(conf); for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact).setConf(conf); } for (ModuleDependency dependency : usage.getDependencies()) { // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id. String confMapping = String.format("%s->%s", conf, dependency.getConfiguration()); if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency, confMapping); } else { addModuleDependency(dependency, confMapping); } } } }
public ClientModule copy() { DefaultClientModule copiedClientModule = new DefaultClientModule(getGroup(), getName(), getVersion(), getConfiguration()); copyTo(copiedClientModule); for (ModuleDependency dependency : dependencies) { copiedClientModule.addDependency(dependency.copy()); } return copiedClientModule; }
public EnhancedDependencyDescriptor createDependencyDescriptor(String configuration, ModuleDependency dependency, ModuleDescriptor parent) { ProjectDependencyInternal projectDependency = (ProjectDependencyInternal) dependency; projectDependency.beforeResolved(); ModuleRevisionId moduleRevisionId = createModuleRevisionId(dependency); ProjectDependencyDescriptor dependencyDescriptor = new ProjectDependencyDescriptor(projectDependency, parent, moduleRevisionId, false, false, dependency.isTransitive()); addExcludesArtifactsAndDependencies(configuration, dependency, dependencyDescriptor); return dependencyDescriptor; }
public EnhancedDependencyDescriptor createDependencyDescriptor(String configuration, ModuleDependency dependency, ModuleDescriptor parent) { ModuleRevisionId moduleRevisionId = createModuleRevisionId(dependency); EnhancedDependencyDescriptor dependencyDescriptor = new EnhancedDependencyDescriptor( dependency, parent, moduleRevisionId, getExternalModuleDependency(dependency).isForce(), getExternalModuleDependency(dependency).isChanging(), getExternalModuleDependency(dependency).isTransitive()); addExcludesArtifactsAndDependencies(configuration, getExternalModuleDependency(dependency), dependencyDescriptor); return dependencyDescriptor; }
private void addDependencies(DefaultModuleDescriptor moduleDescriptor, Collection<? extends Configuration> configurations) { for (Configuration configuration : configurations) { for (ModuleDependency dependency : configuration.getDependencies().withType(ModuleDependency.class)) { dependencyDescriptorFactory.addDependencyDescriptor(configuration.getName(), moduleDescriptor, dependency); } } }
public MutableModuleVersionMetaData createModuleDescriptor(ModuleRevisionId moduleRevisionId, Set<ModuleDependency> dependencies) { DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(moduleRevisionId, "release", null); moduleDescriptor.addConfiguration(new Configuration(Dependency.DEFAULT_CONFIGURATION)); addDependencyDescriptors(moduleDescriptor, dependencies, dependencyDescriptorFactory); moduleDescriptor.addArtifact(Dependency.DEFAULT_CONFIGURATION, new DefaultArtifact(moduleRevisionId, null, moduleRevisionId.getName(), "jar", "jar")); return new ModuleDescriptorAdapter(moduleDescriptor); }
private void addDependencyDescriptors(DefaultModuleDescriptor moduleDescriptor, Set<ModuleDependency> dependencies, DependencyDescriptorFactory dependencyDescriptorFactory) { for (ModuleDependency dependency : dependencies) { dependencyDescriptorFactory.addDependencyDescriptor(Dependency.DEFAULT_CONFIGURATION, moduleDescriptor, dependency); } }
public DslOriginDependencyMetadata createDependencyDescriptor(String clientConfiguration, AttributeContainer attributes, ModuleDependency dependency) { IvyDependencyDescriptorFactory factoryInternal = findFactoryForDependency(dependency); return factoryInternal.createDependencyDescriptor(clientConfiguration, attributes, dependency); }
public boolean canConvert(ModuleDependency dependency) { return dependency instanceof ProjectDependency; }