org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier Java Examples
The following examples show how to use
org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier.
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: BasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty(); if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion()); publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId)); } }); }
Example #2
Source File: MavenPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
Example #3
Source File: DependencyResolverIvyPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultIvyModulePublishMetaData publishMetaData = new DefaultIvyModulePublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #4
Source File: ProjectDependencyPublicationResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #5
Source File: BasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty(); if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion()); publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId)); } }); }
Example #6
Source File: CachingModuleComponentRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void listModuleVersionsFromCache(DependencyMetaData dependency, BuildableModuleComponentVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = getCacheKey(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { result.listed(versionList); // When age == 0, verified since the start of this build, assume listing hasn't changed result.setAuthoritative(cachedModuleVersionList.getAgeMillis() == 0); } } }
Example #7
Source File: ProjectDependencyPublicationResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #8
Source File: CachingModuleVersionRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void localListModuleVersions(DependencyMetaData dependency, BuildableModuleVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = moduleExtractor.transform(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { if (cachedModuleVersionList.getAgeMillis() == 0) { // Verified since the start of this build, assume still missing result.listed(versionList); } else { // Was missing last time we checked result.probablyListed(versionList); } } } }
Example #9
Source File: CachingModuleVersionRepository.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void getDependency(DependencyMetaData dependency, BuildableModuleVersionMetaDataResolveResult result) { DependencyMetaData forced = dependency.withChanging(); delegate.getDependency(forced, result); switch (result.getState()) { case Missing: ModuleRevisionId dependencyRevisionId = dependency.getDescriptor().getDependencyRevisionId(); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(dependencyRevisionId); moduleMetaDataCache.cacheMissing(delegate, moduleVersionIdentifier); break; case Resolved: MutableModuleVersionMetaData metaData = result.getMetaData(); ModuleSource moduleSource = result.getModuleSource(); ModuleMetaDataCache.CachedMetaData cachedMetaData = moduleMetaDataCache.cacheMetaData(delegate, metaData, moduleSource); metadataProcessor.process(metaData); result.setModuleSource(new CachingModuleSource(cachedMetaData.getDescriptorHash(), dependency.isChanging() || metaData.isChanging(), moduleSource)); break; case Failed: break; default: throw new IllegalStateException("Unexpected resolve state: " + result.getState()); } }
Example #10
Source File: ExternalResourceResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
protected MutableModuleVersionMetaData findMetaDataArtifact(DependencyMetaData dependency, ArtifactResolver artifactResolver) { ModuleVersionArtifactMetaData artifact = getMetaDataArtifactFor(dependency); if (artifact == null) { return null; } ExternalResource metaDataResource = artifactResolver.resolveMetaDataArtifact(artifact); if (metaDataResource == null) { return null; } MutableModuleVersionMetaData moduleVersionMetaData = getArtifactMetadata(artifact, metaDataResource); if (isCheckconsistency()) { ModuleVersionSelector requested = dependency.getRequested(); ModuleVersionIdentifier requestedId = DefaultModuleVersionIdentifier.newId(requested.getGroup(), requested.getName(), requested.getVersion()); checkMetadataConsistency(requestedId, moduleVersionMetaData); } return moduleVersionMetaData; }
Example #11
Source File: MavenResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private TimestampedModuleSource findUniqueSnapshotVersion(ModuleRevisionId moduleRevisionId) { ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); ModuleVersionArtifactIdentifier artifactId = new DefaultModuleVersionArtifactIdentifier(moduleVersionIdentifier, moduleVersionIdentifier.getName(), "pom", "pom"); DefaultModuleVersionArtifactMetaData pomArtifact = new DefaultModuleVersionArtifactMetaData(artifactId); String metadataLocation = toResourcePattern(getWholePattern()).toModuleVersionPath(pomArtifact) + "/maven-metadata.xml"; MavenMetadata mavenMetadata = parseMavenMetadata(metadataLocation); if (mavenMetadata.timestamp != null) { // we have found a timestamp, so this is a snapshot unique version String rev = moduleRevisionId.getRevision(); rev = rev.substring(0, rev.length() - "SNAPSHOT".length()); rev = rev + mavenMetadata.timestamp + "-" + mavenMetadata.buildNumber; return new TimestampedModuleSource(rev); } return null; }
Example #12
Source File: DependencyResolverIvyPublisher.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultModuleVersionPublishMetaData publishMetaData = new DefaultModuleVersionPublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #13
Source File: BasePlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty(); if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion()); publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId)); } }); }
Example #14
Source File: BasePlugin.java From javaide with GNU General Public License v3.0 | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty(); if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); Module module = configuration.getModule(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion()); publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId)); } }); }
Example #15
Source File: MavenPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
Example #16
Source File: ProjectDependencyPublicationResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #17
Source File: CachingModuleComponentRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void listModuleVersionsFromCache(DependencyMetaData dependency, BuildableModuleComponentVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = getCacheKey(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { result.listed(versionList); // When age == 0, verified since the start of this build, assume listing hasn't changed result.setAuthoritative(cachedModuleVersionList.getAgeMillis() == 0); } } }
Example #18
Source File: DependencyResolverIvyPublisher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultIvyModulePublishMetaData publishMetaData = new DefaultIvyModulePublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #19
Source File: BasePlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } boolean hasIvyRepo = !uploadArchives.getRepositories().withType(IvyArtifactRepository.class).isEmpty(); if (!hasIvyRepo) { return; } // Maven repos are handled by MavenPlugin ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier(module.getGroup(), module.getName(), module.getVersion()); publicationRegistry.registerPublication(module.getProjectPath(), new DefaultProjectPublication(publicationId)); } }); }
Example #20
Source File: MavenPlugin.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
Example #21
Source File: ProjectDependencyPublicationResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #22
Source File: CachingModuleVersionRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void localListModuleVersions(DependencyMetaData dependency, BuildableModuleVersionSelectionResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); final ModuleIdentifier moduleId = moduleExtractor.transform(requested); ModuleVersionsCache.CachedModuleVersionList cachedModuleVersionList = moduleVersionsCache.getCachedModuleResolution(delegate, moduleId); if (cachedModuleVersionList != null) { ModuleVersionListing versionList = cachedModuleVersionList.getModuleVersions(); Set<ModuleVersionIdentifier> versions = CollectionUtils.collect(versionList.getVersions(), new Transformer<ModuleVersionIdentifier, Versioned>() { public ModuleVersionIdentifier transform(Versioned original) { return new DefaultModuleVersionIdentifier(moduleId, original.getVersion()); } }); if (cachePolicy.mustRefreshVersionList(moduleId, versions, cachedModuleVersionList.getAgeMillis())) { LOGGER.debug("Version listing in dynamic revision cache is expired: will perform fresh resolve of '{}' in '{}'", requested, delegate.getName()); } else { if (cachedModuleVersionList.getAgeMillis() == 0) { // Verified since the start of this build, assume still missing result.listed(versionList); } else { // Was missing last time we checked result.probablyListed(versionList); } } } }
Example #23
Source File: CachingModuleVersionRepository.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void getDependency(DependencyMetaData dependency, BuildableModuleVersionMetaDataResolveResult result) { DependencyMetaData forced = dependency.withChanging(); delegate.getDependency(forced, result); switch (result.getState()) { case Missing: ModuleRevisionId dependencyRevisionId = dependency.getDescriptor().getDependencyRevisionId(); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(dependencyRevisionId); moduleMetaDataCache.cacheMissing(delegate, moduleVersionIdentifier); break; case Resolved: MutableModuleVersionMetaData metaData = result.getMetaData(); ModuleSource moduleSource = result.getModuleSource(); ModuleMetaDataCache.CachedMetaData cachedMetaData = moduleMetaDataCache.cacheMetaData(delegate, metaData, moduleSource); metadataProcessor.process(metaData); result.setModuleSource(new CachingModuleSource(cachedMetaData.getDescriptorHash(), dependency.isChanging() || metaData.isChanging(), moduleSource)); break; case Failed: break; default: throw new IllegalStateException("Unexpected resolve state: " + result.getState()); } }
Example #24
Source File: ExternalResourceResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
protected MutableModuleVersionMetaData findMetaDataArtifact(DependencyMetaData dependency, ArtifactResolver artifactResolver) { ModuleVersionArtifactMetaData artifact = getMetaDataArtifactFor(dependency); if (artifact == null) { return null; } ExternalResource metaDataResource = artifactResolver.resolveMetaDataArtifact(artifact); if (metaDataResource == null) { return null; } MutableModuleVersionMetaData moduleVersionMetaData = getArtifactMetadata(artifact, metaDataResource); if (isCheckconsistency()) { ModuleVersionSelector requested = dependency.getRequested(); ModuleVersionIdentifier requestedId = DefaultModuleVersionIdentifier.newId(requested.getGroup(), requested.getName(), requested.getVersion()); checkMetadataConsistency(requestedId, moduleVersionMetaData); } return moduleVersionMetaData; }
Example #25
Source File: MavenResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
private TimestampedModuleSource findUniqueSnapshotVersion(ModuleRevisionId moduleRevisionId) { ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); ModuleVersionArtifactIdentifier artifactId = new DefaultModuleVersionArtifactIdentifier(moduleVersionIdentifier, moduleVersionIdentifier.getName(), "pom", "pom"); DefaultModuleVersionArtifactMetaData pomArtifact = new DefaultModuleVersionArtifactMetaData(artifactId); String metadataLocation = toResourcePattern(getWholePattern()).toModuleVersionPath(pomArtifact) + "/maven-metadata.xml"; MavenMetadata mavenMetadata = parseMavenMetadata(metadataLocation); if (mavenMetadata.timestamp != null) { // we have found a timestamp, so this is a snapshot unique version String rev = moduleRevisionId.getRevision(); rev = rev.substring(0, rev.length() - "SNAPSHOT".length()); rev = rev + mavenMetadata.timestamp + "-" + mavenMetadata.buildNumber; return new TimestampedModuleSource(rev); } return null; }
Example #26
Source File: DependencyResolverIvyPublisher.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void publish(IvyNormalizedPublication publication, PublicationAwareRepository repository) { ModuleVersionPublisher publisher = repository.createPublisher(); IvyPublicationIdentity projectIdentity = publication.getProjectIdentity(); ModuleRevisionId moduleRevisionId = IvyUtil.createModuleRevisionId(projectIdentity.getOrganisation(), projectIdentity.getModule(), projectIdentity.getRevision()); ModuleVersionIdentifier moduleVersionIdentifier = DefaultModuleVersionIdentifier.newId(moduleRevisionId); DefaultModuleVersionPublishMetaData publishMetaData = new DefaultModuleVersionPublishMetaData(moduleVersionIdentifier); try { for (IvyArtifact publishArtifact : publication.getArtifacts()) { Artifact ivyArtifact = createIvyArtifact(publishArtifact, moduleRevisionId); publishMetaData.addArtifact(ivyArtifact, publishArtifact.getFile()); } Artifact artifact = DefaultArtifact.newIvyArtifact(moduleRevisionId, null); publishMetaData.addArtifact(artifact, publication.getDescriptorFile()); publisher.publish(publishMetaData); } catch (IOException e) { throw new UncheckedIOException(e); } }
Example #27
Source File: MavenPlugin.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
private void configureUploadArchivesTask() { configurationActionContainer.add(new Action<Project>() { public void execute(Project project) { Upload uploadArchives = project.getTasks().withType(Upload.class).findByName(BasePlugin.UPLOAD_ARCHIVES_TASK_NAME); if (uploadArchives == null) { return; } ConfigurationInternal configuration = (ConfigurationInternal) uploadArchives.getConfiguration(); ModuleInternal module = configuration.getModule(); for (MavenResolver resolver : uploadArchives.getRepositories().withType(MavenResolver.class)) { MavenPom pom = resolver.getPom(); ModuleVersionIdentifier publicationId = new DefaultModuleVersionIdentifier( pom.getGroupId().equals(MavenProject.EMPTY_PROJECT_GROUP_ID) ? module.getGroup() : pom.getGroupId(), pom.getArtifactId().equals(MavenProject.EMPTY_PROJECT_ARTIFACT_ID) ? module.getName() : pom.getArtifactId(), pom.getVersion().equals(MavenProject.EMPTY_PROJECT_VERSION) ? module.getVersion() : pom.getVersion() ); publicationRegistry.registerPublication(project.getPath(), new DefaultProjectPublication(publicationId)); } } }); }
Example #28
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(ConfigurationInternal configuration, List<? extends ResolutionAwareRepository> repositories, GlobalDependencyResolutionRules metadataHandler, ResolverResults results) throws ResolveException { if (configuration.getAllDependencies().isEmpty()) { ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule()); ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule()); ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete(); results.resolved(new EmptyResolvedConfiguration(), emptyResult); } else { dependencyResolver.resolve(configuration, repositories, metadataHandler, results); } }
Example #29
Source File: RepositoryChainAdapter.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(DependencyMetaData dependency, BuildableComponentIdResolveResult result) { ModuleVersionSelector requested = dependency.getRequested(); if (versionMatcher.isDynamic(requested.getVersion())) { dynamicRevisionResolver.resolve(dependency, result); } else { DefaultModuleComponentIdentifier id = new DefaultModuleComponentIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); DefaultModuleVersionIdentifier mvId = new DefaultModuleVersionIdentifier(requested.getGroup(), requested.getName(), requested.getVersion()); result.resolved(id, mvId); } }
Example #30
Source File: ShortcircuitEmptyConfigsArtifactDependencyResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void resolve(ConfigurationInternal configuration, List<? extends ResolutionAwareRepository> repositories, ModuleMetadataProcessor metadataProcessor, ResolverResults results) throws ResolveException { if (configuration.getAllDependencies().isEmpty()) { ModuleVersionIdentifier id = DefaultModuleVersionIdentifier.newId(configuration.getModule()); ComponentIdentifier componentIdentifier = componentIdentifierFactory.createComponentIdentifier(configuration.getModule()); ResolutionResult emptyResult = new DefaultResolutionResultBuilder().start(id, componentIdentifier).complete(); results.resolved(new EmptyResolvedConfiguration(), emptyResult); } else { dependencyResolver.resolve(configuration, repositories, metadataProcessor, results); } }