public static ResolvedArtifact getArtifactWithName(final String name, final Set<ResolvedArtifact> artifacts) { for (ResolvedArtifact artifact : artifacts) { if (artifact.getName().equals(name)) { return artifact; } } throw new IllegalStateException("Could not find a dependency with name " + name); }
@Override public Set<ArtifactSpec> resolveAll(final Set<ArtifactSpec> specs) throws Exception { if (specs.isEmpty()) { return specs; } final Set<ArtifactSpec> resolvedSpecs = new HashSet<>(); doResolve(specs).forEach(dep -> dep.getAllModuleArtifacts() .forEach(artifact -> resolvedSpecs .add(new ArtifactSpec(dep.getConfiguration(), dep.getModuleGroup(), artifact.getName(), dep.getModuleVersion(), artifact.getExtension(), artifact.getClassifier(), artifact.getFile())))); return resolvedSpecs.stream() .filter(a -> !"system".equals(a.scope)) .collect(Collectors.toSet()); }
private ResolvedArtifact prepareArtifact( String name, String group, String filePath, String version) { ModuleVersionIdentifier moduleId = mock(ModuleVersionIdentifier.class); when(moduleId.getGroup()).thenReturn(group); when(moduleId.getVersion()).thenReturn(version); ResolvedModuleVersion moduleVersion = mock(ResolvedModuleVersion.class); when(moduleVersion.getId()).thenReturn(moduleId); File artifactFile = mock(File.class); when(artifactFile.getAbsolutePath()).thenReturn(filePath); ResolvedArtifact artifact = mock(ResolvedArtifact.class); when(artifact.getName()).thenReturn(name); when(artifact.getFile()).thenReturn(artifactFile); when(artifact.getModuleVersion()).thenReturn(moduleVersion); return artifact; } }
Optional<ProjectElement<ResolvedArtifact>> resolutionInfo = Projects.findResolvedArtifact( getProject().getAllprojects(), c -> c.getName().equals(JavaConfigPlugin.ANNOTATIONS_CONFIGURATION), a -> Objects.equals(a.getName(), annotationsProjectName) && Strings.isNullOrEmpty(a.getClassifier()) && Objects.equals(a.getType(), "jar"));
Optional<ProjectElement<ResolvedArtifact>> resolutionInfo = Projects.findResolvedArtifact( getProject().getAllprojects(), c -> c.getName().equals(JavaConfigPlugin.ANNOTATIONS_CONFIGURATION), a -> Objects.equals(a.getName(), annotationsProjectName) && Strings.isNullOrEmpty(a.getClassifier()) && Objects.equals(a.getType(), "jar"));
a.getElement().getName() + "-annotations"); });
a.getElement().getName() + "-annotations"); });