org.gradle.api.artifacts.component.ModuleComponentIdentifier Java Examples
The following examples show how to use
org.gradle.api.artifacts.component.ModuleComponentIdentifier.
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: ComponentIdentifierSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void write(Encoder encoder, ComponentIdentifier value) throws IOException { if(value == null) { throw new IllegalArgumentException("Provided component identifier may not be null"); } if(value instanceof DefaultModuleComponentIdentifier) { ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier)value; encoder.writeByte(Implementation.MODULE.getId()); encoder.writeString(moduleComponentIdentifier.getGroup()); encoder.writeString(moduleComponentIdentifier.getModule()); encoder.writeString(moduleComponentIdentifier.getVersion()); } else if(value instanceof DefaultProjectComponentIdentifier) { ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier)value; encoder.writeByte(Implementation.BUILD.getId()); encoder.writeString(projectComponentIdentifier.getProjectPath()); } else { throw new IllegalArgumentException("Unsupported component identifier class: " + value.getClass()); } }
Example #2
Source File: ExternalResourceResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected final void resolveStaticDependency(DependencyMetaData dependency, ModuleComponentIdentifier moduleVersionIdentifier, BuildableModuleComponentMetaDataResolveResult result, ExternalResourceArtifactResolver artifactResolver) { MutableModuleComponentResolveMetaData metaDataArtifactMetaData = parseMetaDataFromArtifact(moduleVersionIdentifier, artifactResolver, result); if (metaDataArtifactMetaData != null) { LOGGER.debug("Metadata file found for module '{}' in repository '{}'.", moduleVersionIdentifier, getName()); result.resolved(metaDataArtifactMetaData); return; } MutableModuleComponentResolveMetaData metaDataFromDefaultArtifact = createMetaDataFromDefaultArtifact(moduleVersionIdentifier, dependency, artifactResolver, result); if (metaDataFromDefaultArtifact != null) { LOGGER.debug("Found artifact but no meta-data for module '{}' in repository '{}', using default meta-data.", moduleVersionIdentifier, getName()); result.resolved(metaDataFromDefaultArtifact); return; } LOGGER.debug("No meta-data file or artifact found for module '{}' in repository '{}'.", moduleVersionIdentifier, getName()); result.missing(); }
Example #3
Source File: ComponentIdentifierSerializer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void write(Encoder encoder, ComponentIdentifier value) throws IOException { if(value == null) { throw new IllegalArgumentException("Provided component identifier may not be null"); } if(value instanceof DefaultModuleComponentIdentifier) { ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier)value; encoder.writeByte(Implementation.MODULE.getId()); encoder.writeString(moduleComponentIdentifier.getGroup()); encoder.writeString(moduleComponentIdentifier.getModule()); encoder.writeString(moduleComponentIdentifier.getVersion()); } else if(value instanceof DefaultProjectComponentIdentifier) { ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier)value; encoder.writeByte(Implementation.BUILD.getId()); encoder.writeString(projectComponentIdentifier.getProjectPath()); } else { throw new IllegalArgumentException("Unsupported component identifier class: " + value.getClass()); } }
Example #4
Source File: ComponentIdentifierSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void write(Encoder encoder, ComponentIdentifier value) throws IOException { if(value == null) { throw new IllegalArgumentException("Provided component identifier may not be null"); } if(value instanceof DefaultModuleComponentIdentifier) { ModuleComponentIdentifier moduleComponentIdentifier = (ModuleComponentIdentifier)value; encoder.writeByte(Implementation.MODULE.getId()); encoder.writeString(moduleComponentIdentifier.getGroup()); encoder.writeString(moduleComponentIdentifier.getModule()); encoder.writeString(moduleComponentIdentifier.getVersion()); } else if(value instanceof DefaultProjectComponentIdentifier) { ProjectComponentIdentifier projectComponentIdentifier = (ProjectComponentIdentifier)value; encoder.writeByte(Implementation.BUILD.getId()); encoder.writeString(projectComponentIdentifier.getProjectPath()); } else { throw new IllegalArgumentException("Unsupported component identifier class: " + value.getClass()); } }
Example #5
Source File: DefaultArtifactResolutionQuery.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ArtifactResolutionQueryResult execute() { List<ResolutionAwareRepository> repositories = CollectionUtils.collect(repositoryHandler, Transformers.cast(ResolutionAwareRepository.class)); ConfigurationInternal configuration = configurationContainer.detachedConfiguration(); final RepositoryChain repositoryChain = ivyFactory.create(configuration, repositories, metadataProcessor); final ArtifactResolver artifactResolver = new ErrorHandlingArtifactResolver(repositoryChain.getArtifactResolver()); return lockingManager.useCache("resolve artifacts", new Factory<ArtifactResolutionQueryResult>() { public ArtifactResolutionQueryResult create() { Set<JvmLibrary> jvmLibraries = Sets.newHashSet(); Set<UnresolvedSoftwareComponent> unresolvedComponents = Sets.newHashSet(); for (ComponentIdentifier componentId : componentIds) { if (!(componentId instanceof ModuleComponentIdentifier)) { throw new IllegalArgumentException(String.format("Cannot resolve the artifacts for component %s with unsupported type %s.", componentId.getDisplayName(), componentId.getClass().getName())); } ModuleComponentIdentifier moduleComponentId = (ModuleComponentIdentifier) componentId; BuildableComponentResolveResult moduleResolveResult = new DefaultBuildableComponentResolveResult(); repositoryChain.getDependencyResolver().resolve(new DefaultDependencyMetaData(new DefaultDependencyDescriptor(toModuleRevisionId(moduleComponentId), true)), moduleResolveResult); try { DefaultJvmLibrary jvmLibrary = buildJvmLibrary(moduleResolveResult.getMetaData(), artifactResolver); jvmLibraries.add(jvmLibrary); } catch (Throwable t) { unresolvedComponents.add(new DefaultUnresolvedSoftwareComponent(moduleComponentId, t)); } } return new DefaultArtifactResolutionQueryResult(jvmLibraries, unresolvedComponents); } }); }
Example #6
Source File: DefaultModuleMetaDataCache.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public CachedMetaData getCachedModuleDescriptor(ModuleComponentRepository repository, ModuleComponentIdentifier componentId) { ModuleDescriptorCacheEntry entry = getCache().get(createKey(repository, componentId)); if (entry == null) { return null; } if (entry.isMissing()) { return new DefaultCachedMetaData(entry, entry.createMetaData(null), timeProvider); } ModuleDescriptor descriptor = moduleDescriptorStore.getModuleDescriptor(repository, componentId); if (descriptor == null) { // Descriptor file has been deleted - ignore the entry return null; } return new DefaultCachedMetaData(entry, entry.createMetaData(descriptor), timeProvider); }
Example #7
Source File: ModuleVersionArtifactIdentifierSerializer.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ModuleComponentArtifactIdentifier read(Decoder decoder) throws Exception { ModuleComponentIdentifier componentIdentifier = (ModuleComponentIdentifier) componentIdentifierSerializer.read(decoder); String artifactName = decoder.readString(); String type = decoder.readString(); String extension = decoder.readNullableString(); Map<String, String> attributes = attributesSerializer.read(decoder); return new DefaultModuleComponentArtifactIdentifier(componentIdentifier, artifactName, type, extension, attributes); }
Example #8
Source File: CacheLockReleasingModuleComponentsRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolveComponentMetaData(final DependencyMetaData dependency, final ModuleComponentIdentifier moduleComponentIdentifier, final BuildableModuleComponentMetaDataResolveResult result) { cacheLockingManager.longRunningOperation(String.format("Resolve %s using repository %s", dependency, name), new Runnable() { public void run() { delegate.resolveComponentMetaData(dependency, moduleComponentIdentifier, result); } }); }
Example #9
Source File: ModuleVersionArtifactIdentifierSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ModuleComponentArtifactIdentifier read(Decoder decoder) throws Exception { ModuleComponentIdentifier componentIdentifier = (ModuleComponentIdentifier) componentIdentifierSerializer.read(decoder); String artifactName = decoder.readString(); String type = decoder.readString(); String extension = decoder.readNullableString(); Map<String, String> attributes = attributesSerializer.read(decoder); return new DefaultModuleComponentArtifactIdentifier(componentIdentifier, artifactName, type, extension, attributes); }
Example #10
Source File: InMemoryMetaDataCache.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
boolean supplyMetaData(ModuleComponentIdentifier requested, BuildableModuleComponentMetaDataResolveResult result) { CachedModuleVersionResult fromCache = metaData.get(requested); if (fromCache == null) { return false; } fromCache.supply(result); stats.metadataServed++; return true; }
Example #11
Source File: AbstractResourcePattern.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
protected Map<String, String> toAttributes(ModuleComponentIdentifier componentIdentifier) { HashMap<String, String> attributes = new HashMap<String, String>(); attributes.put(IvyPatternHelper.ORGANISATION_KEY, componentIdentifier.getGroup()); attributes.put(IvyPatternHelper.MODULE_KEY, componentIdentifier.getModule()); attributes.put(IvyPatternHelper.REVISION_KEY, componentIdentifier.getVersion()); return attributes; }
Example #12
Source File: LocalModuleComponentRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolveComponentMetaData(DependencyMetaData dependency, ModuleComponentIdentifier moduleComponentIdentifier, BuildableModuleComponentMetaDataResolveResult result) { delegate.getLocalAccess().resolveComponentMetaData(dependency, moduleComponentIdentifier, result); if (!result.hasResult()) { delegate.getRemoteAccess().resolveComponentMetaData(dependency, moduleComponentIdentifier, result); } if (result.getState() == BuildableModuleComponentMetaDataResolveResult.State.Resolved) { metadataProcessor.processMetadata(result.getMetaData()); } }
Example #13
Source File: CachingModuleComponentRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private void resolveComponentMetaDataFromCache(DependencyMetaData dependency, ModuleComponentIdentifier moduleComponentIdentifier, BuildableModuleComponentMetaDataResolveResult result) { ModuleMetaDataCache.CachedMetaData cachedMetaData = moduleMetaDataCache.getCachedModuleDescriptor(delegate, moduleComponentIdentifier); if (cachedMetaData == null) { return; } if (cachedMetaData.isMissing()) { if (cachePolicy.mustRefreshMissingModule(moduleComponentIdentifier, cachedMetaData.getAgeMillis())) { LOGGER.debug("Cached meta-data for missing module is expired: will perform fresh resolve of '{}' in '{}'", moduleComponentIdentifier, delegate.getName()); return; } LOGGER.debug("Detected non-existence of module '{}' in resolver cache '{}'", moduleComponentIdentifier, delegate.getName()); result.missing(); // When age == 0, verified since the start of this build, assume still missing result.setAuthoritative(cachedMetaData.getAgeMillis() == 0); return; } MutableModuleComponentResolveMetaData metaData = cachedMetaData.getMetaData(); metadataProcessor.processMetadata(metaData); if (dependency.isChanging() || metaData.isChanging()) { if (cachePolicy.mustRefreshChangingModule(moduleComponentIdentifier, cachedMetaData.getModuleVersion(), cachedMetaData.getAgeMillis())) { LOGGER.debug("Cached meta-data for changing module is expired: will perform fresh resolve of '{}' in '{}'", moduleComponentIdentifier, delegate.getName()); return; } LOGGER.debug("Found cached version of changing module '{}' in '{}'", moduleComponentIdentifier, delegate.getName()); } else { if (cachePolicy.mustRefreshModule(moduleComponentIdentifier, cachedMetaData.getModuleVersion(), cachedMetaData.getAgeMillis())) { LOGGER.debug("Cached meta-data for module must be refreshed: will perform fresh resolve of '{}' in '{}'", moduleComponentIdentifier, delegate.getName()); return; } } LOGGER.debug("Using cached module metadata for module '{}' in '{}'", moduleComponentIdentifier, delegate.getName()); metaData.setSource(new CachingModuleSource(cachedMetaData.getDescriptorHash(), metaData.isChanging(), metaData.getSource())); result.resolved(metaData); // When age == 0, verified since the start of this build, assume the meta-data hasn't changed result.setAuthoritative(cachedMetaData.getAgeMillis() == 0); }
Example #14
Source File: RepositoryChainDependencyResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(DependencyMetaData dependency, BuildableComponentResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); LOGGER.debug("Attempting to resolve {} using repositories {}", requested, repositoryNames); ModuleComponentIdentifier moduleComponentIdentifier = new DefaultModuleComponentIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); ModuleVersionIdentifier moduleVersionIdentifier = new DefaultModuleVersionIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); List<Throwable> errors = new ArrayList<Throwable>(); List<ComponentMetaDataResolveState> resolveStates = new ArrayList<ComponentMetaDataResolveState>(); for (ModuleComponentRepository repository : repositories) { resolveStates.add(new ComponentMetaDataResolveState(dependency, moduleComponentIdentifier, repository, componentChooser)); } final RepositoryChainModuleResolution latestResolved = findBestMatch(resolveStates, errors); if (latestResolved != null) { LOGGER.debug("Using {} from {}", latestResolved.module.getId(), latestResolved.repository); for (Throwable error : errors) { LOGGER.debug("Discarding resolve failure.", error); } result.resolved(metaDataFactory.transform(latestResolved)); return; } if (!errors.isEmpty()) { result.failed(new ModuleVersionResolveException(moduleComponentIdentifier, errors)); } else { for (ComponentMetaDataResolveState resolveState : resolveStates) { resolveState.applyTo(result); } result.notFound(moduleVersionIdentifier); } }
Example #15
Source File: ResolveJavadocLinks.java From gradle-plugins with MIT License | 5 votes |
@Override public void execute(Task task) { javadoc = (Javadoc) task; logger = javadoc.getLogger(); addLink(getJavaSeLink()); findConfigurations(javadoc.getClasspath()) .flatMap(files -> files.getResolvedConfiguration().getResolvedArtifacts().stream()) .map(resolvedArtifact -> resolvedArtifact.getId().getComponentIdentifier()) .filter(ModuleComponentIdentifier.class::isInstance) .map(ModuleComponentIdentifier.class::cast) .map(moduleComponentIdentifier -> { String group = moduleComponentIdentifier.getGroup(); String artifact = moduleComponentIdentifier.getModule(); String version = moduleComponentIdentifier.getVersion(); String wellKnownLink = findWellKnownLink(group, artifact, version); if (wellKnownLink != null) { javadoc.getLogger().info("Using well known link '{}' for '{}:{}:{}'", wellKnownLink, group, artifact, version); return wellKnownLink; } else { String javadocIoLink = String.format("https://static.javadoc.io/%s/%s/%s/", group, artifact, version); if (checkLink(javadocIoLink)) { javadoc.getLogger().info("Using javadoc.io link for '{}:{}:{}'", group, artifact, version); return javadocIoLink; } else { return null; } } }) .filter(Objects::nonNull) .forEach(this::addLink); }
Example #16
Source File: DefaultModuleMetaDataCache.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public CachedMetaData getCachedModuleDescriptor(ModuleComponentRepository repository, ModuleComponentIdentifier componentId) { ModuleDescriptorCacheEntry entry = getCache().get(createKey(repository, componentId)); if (entry == null) { return null; } if (entry.isMissing()) { return new DefaultCachedMetaData(entry, entry.createMetaData(null), timeProvider); } ModuleDescriptor descriptor = moduleDescriptorStore.getModuleDescriptor(repository, componentId); if (descriptor == null) { // Descriptor file has been deleted - ignore the entry return null; } return new DefaultCachedMetaData(entry, entry.createMetaData(descriptor), timeProvider); }
Example #17
Source File: M2ResourcePattern.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public ExternalResourceName toModuleVersionPath(ModuleComponentIdentifier componentIdentifier) { String pattern = getBase().getPath(); if (!pattern.endsWith(MavenPattern.M2_PATTERN)) { throw new UnsupportedOperationException("Cannot locate module version for non-maven layout."); } String metaDataPattern = pattern.substring(0, pattern.length() - MavenPattern.M2_PER_MODULE_VERSION_PATTERN.length() - 1); return getBase().getRoot().resolve(substituteTokens(metaDataPattern, toAttributes(componentIdentifier))); }
Example #18
Source File: DynamicVersionResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
private boolean resolveDependency(DependencyMetaData dependency, ModuleComponentRepositoryAccess moduleAccess, BuildableModuleComponentMetaDataResolveResult resolveResult) { ModuleComponentIdentifier componentIdentifier = componentChooser.choose(selectionResult.getVersions(), dependency, moduleAccess); if (componentIdentifier == null) { return false; } dependency = dependency.withRequestedVersion(componentIdentifier.getVersion()); // TODO - reuse meta data if it was fetched to select candidate moduleAccess.resolveComponentMetaData(dependency, componentIdentifier, resolveResult); return true; }
Example #19
Source File: CacheLockReleasingModuleComponentsRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolveComponentMetaData(final DependencyMetaData dependency, final ModuleComponentIdentifier moduleComponentIdentifier, final BuildableModuleComponentMetaDataResolveResult result) { cacheLockingManager.longRunningOperation(String.format("Resolve %s using repository %s", dependency, name), new Runnable() { public void run() { delegate.resolveComponentMetaData(dependency, moduleComponentIdentifier, result); } }); }
Example #20
Source File: ModuleVersionArtifactIdentifierSerializer.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public ModuleVersionArtifactIdentifier read(Decoder decoder) throws Exception { ModuleComponentIdentifier componentIdentifier = (ModuleComponentIdentifier) componentIdentifierSerializer.read(decoder); String artifactName = decoder.readString(); String type = decoder.readString(); String extension = decoder.readNullableString(); Map<String, String> attributes = attributesSerializer.read(decoder); return new DefaultModuleVersionArtifactIdentifier(componentIdentifier, artifactName, type, extension, attributes); }
Example #21
Source File: DefaultModuleVersionArtifactIdentifier.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultModuleVersionArtifactIdentifier(ModuleComponentIdentifier componentIdentifier, String name, String type, @Nullable String extension, Map<String, String> attributes) { this.componentIdentifier = componentIdentifier; this.name = new DefaultIvyArtifactName(name, type, extension, attributes); }
Example #22
Source File: ExternalResourceResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
private ModuleComponentArtifactMetaData getMetaDataArtifactFor(ModuleComponentIdentifier moduleComponentIdentifier) { IvyArtifactName ivyArtifactName = getMetaDataArtifactName(moduleComponentIdentifier.getModule()); return new DefaultModuleComponentArtifactMetaData(moduleComponentIdentifier, ivyArtifactName); }
Example #23
Source File: DefaultModuleComponentArtifactMetaData.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultModuleComponentArtifactMetaData(ModuleComponentIdentifier componentIdentifier, IvyArtifactName artifact) { this(new DefaultModuleComponentArtifactIdentifier(componentIdentifier, artifact)); }
Example #24
Source File: ExternalResourceResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public final void resolveComponentMetaData(DependencyMetaData dependency, ModuleComponentIdentifier moduleComponentIdentifier, BuildableModuleComponentMetaDataResolveResult result) { }
Example #25
Source File: ExternalResourceResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private ModuleComponentArtifactMetaData getMetaDataArtifactFor(ModuleComponentIdentifier moduleComponentIdentifier) { IvyArtifactName ivyArtifactName = getMetaDataArtifactName(moduleComponentIdentifier.getModule()); return new DefaultModuleComponentArtifactMetaData(moduleComponentIdentifier, ivyArtifactName); }
Example #26
Source File: AbstractModuleComponentResolveMetaData.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
private static ModuleComponentIdentifier moduleComponentIdentifier(ModuleDescriptor descriptor) { return DefaultModuleComponentIdentifier.newId(moduleVersionIdentifier(descriptor)); }
Example #27
Source File: DefaultModuleComponentArtifactMetaData.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultModuleComponentArtifactMetaData(ModuleComponentIdentifier componentIdentifier, Artifact artifact) { this(new DefaultModuleComponentArtifactIdentifier(componentIdentifier, artifact)); }
Example #28
Source File: ModuleVersionResolveException.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ModuleVersionResolveException(ModuleComponentIdentifier id, Iterable<? extends Throwable> causes) { this(DefaultModuleVersionSelector.newSelector(id.getGroup(), id.getModule(), id.getVersion()), causes); }
Example #29
Source File: DefaultModuleComponentArtifactMetaData.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultModuleComponentArtifactMetaData(ModuleComponentIdentifier componentIdentifier, IvyArtifactName artifact) { this(new DefaultModuleComponentArtifactIdentifier(componentIdentifier, artifact)); }
Example #30
Source File: ModuleVersionResolveException.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ModuleVersionResolveException(ModuleComponentIdentifier id, Iterable<? extends Throwable> causes) { this(DefaultModuleVersionSelector.newSelector(id.getGroup(), id.getModule(), id.getVersion()), causes); }