/** * Resolve all dependencies of all configurations of this project and it's subprojects. * * @return All resolved dependencies. */ protected List<DependencyIdentifier> resolveDependencies() { return getProject().getAllprojects().stream() // all projects .flatMap(project -> project.getConfigurations().stream()) // get all configurations .filter(Configuration::isCanBeResolved) // only if the configuration can be resolved .flatMap(configuration -> configuration.getResolvedConfiguration().getResolvedArtifacts().stream()) // get all artifacts .filter(resolvedArtifact -> !(resolvedArtifact.getId().getComponentIdentifier() instanceof DefaultProjectComponentIdentifier)) .map(resolvedArtifact -> resolvedArtifact.getModuleVersion().getId()) // map to ModuleVersionIdentifier .map(DependencyIdentifier::new) // .distinct() // .filter(this::filterIgnoredDependencies) // .sorted(new DependencyIdentifierComparator()) // .collect(Collectors.toList()); }
@Override public InputStream getInputStream() throws Exception { // create a temporary configuration to resolve the file Configuration conf = project.getConfigurations().detachedConfiguration( project.getDependencies().create(dependencyNotation)); ResolvedArtifact artifactId = conf.getResolvedConfiguration().getResolvedArtifacts().iterator().next(); logger.info("Selected recommendation source " + artifactId.getId() + ", you requested " + dependencyNotation); return new FileInputStream(artifactId.getFile()); } };
/** * Create Eclipse annotations tasks * * @param tasks Task container * @param configurations Container to access configurations * @param buildDir Build directory */ @Mutate public void createEclipseAnnotationsTasks(ModelMap<Task> tasks, ConfigurationContainer configurations, @Path("buildDir") File buildDir) { tasks.create("eclipseAnnotations", EclipseAnnotationsTask.class, t -> { t.setDescription("Generates external nullability annotations for dependencies."); t.setGroup("IDE"); ConventionMapping parameters = t.getConventionMapping(); parameters.map("jars", () -> { Set<File> jars = configurations.stream() .filter(c -> c.isCanBeResolved() && !c.getName().equals(JavaConfigPlugin.ANNOTATIONS_CONFIGURATION)) .map(c -> c.getResolvedConfiguration().getLenientConfiguration()) .flatMap(c -> c.getArtifacts().stream() .filter(a -> !(a.getId() .getComponentIdentifier() instanceof ProjectComponentIdentifier) && a.getType().equals("jar")) .map(a -> a.getFile())) .collect(Collectors.toSet()); return jars; }); }); }
/** * Create Eclipse annotations tasks * * @param tasks Task container * @param configurations Container to access configurations * @param buildDir Build directory */ @Mutate public void createEclipseAnnotationsTasks(ModelMap<Task> tasks, ConfigurationContainer configurations, @Path("buildDir") File buildDir) { tasks.create("eclipseAnnotations", EclipseAnnotationsTask.class, t -> { t.setDescription("Generates external nullability annotations for dependencies."); t.setGroup("IDE"); ConventionMapping parameters = t.getConventionMapping(); parameters.map("jars", () -> { Set<File> jars = configurations.stream() .filter(c -> c.isCanBeResolved() && !c.getName().equals(JavaConfigPlugin.ANNOTATIONS_CONFIGURATION)) .map(c -> c.getResolvedConfiguration().getLenientConfiguration()) .flatMap(c -> c.getArtifacts().stream() .filter(a -> !(a.getId() .getComponentIdentifier() instanceof ProjectComponentIdentifier) && a.getType().equals("jar")) .map(a -> a.getFile())) .collect(Collectors.toSet()); return jars; }); }); }
getLogger().debug("Resolved classpath to artifact '{}'", a.getElement().getId());
getLogger().debug("Resolved classpath to artifact '{}'", a.getElement().getId());
idMap.put(artifact.getId().getComponentIdentifier(), module);