ResolvedArtifactResult (ResolvedArtifact artifact, ComponentArtifactsResult componentArtifacts, Class<? extends Artifact> artifactType) { String baseName = Files.getNameWithoutExtension(artifact.getFile().getName()); Set<ArtifactResult> artifactResults = componentArtifacts.getArtifacts(artifactType); if (artifactResults.size() == 1) { ArtifactResult artifactResult = artifactResults.iterator().next(); return artifactResult instanceof ResolvedArtifactResult ? (ResolvedArtifactResult)artifactResult : null; } for (ArtifactResult result : artifactResults) { if (result instanceof ResolvedArtifactResult && ((ResolvedArtifactResult)result).getFile().getName().startsWith(baseName)) { return (ResolvedArtifactResult)result; } } return null; }