private SelfResolvingDependency maybeCreateUnderLock(DependencyFactory.ClassPathNotation notation) { SelfResolvingDependency dependency = internCache.get(notation); if (dependency == null) { Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles(); boolean runningFromInstallation = currentGradleInstallation.getInstallation() != null; FileCollectionInternal files; if (runningFromInstallation && notation.equals(GRADLE_API)) { files = gradleApiFileCollection(classpath); } else if (runningFromInstallation && notation.equals(GRADLE_TEST_KIT)) { files = gradleTestKitFileCollection(classpath); } else { files = fileResolver.resolveFiles(classpath); } dependency = instantiator.newInstance(DefaultSelfResolvingDependency.class, new OpaqueComponentIdentifier(notation.displayName), files); internCache.put(notation, dependency); } return dependency; }
/** * Gets IDE local file dependencies. * * @param configuration Configuration * @return IDE local file dependencies */ public List<IdeLocalFileDependency> getIdeLocalFileDependencies(Configuration configuration) { List<SelfResolvingDependency> externalDependencies = new ArrayList<SelfResolvingDependency>(); findAllExternalDependencies(externalDependencies, new ArrayList<Dependency>(), configuration); List<IdeLocalFileDependency> ideLocalFileDependencies = new ArrayList<IdeLocalFileDependency>(); for (SelfResolvingDependency externalDependency : externalDependencies) { Set<File> resolvedFiles = externalDependency.resolve(); for (File resolvedFile : resolvedFiles) { IdeLocalFileDependency ideLocalFileDependency = new IdeLocalFileDependency(resolvedFile); ideLocalFileDependencies.add(ideLocalFileDependency); } } return ideLocalFileDependencies; }
public void convert(DependencyFactory.ClassPathNotation notation, NotationConvertResult<? super SelfResolvingDependency> result) throws TypeConversionException { SelfResolvingDependency dependency = internCache.get(notation); if (dependency == null) { internCacheWriteLock.lock(); try { dependency = maybeCreateUnderLock(notation); } finally { internCacheWriteLock.unlock(); } } result.converted(dependency); }
/** * Finds all external dependencies. * * @param configuration Configuration * @return External dependencies */ private List<SelfResolvingDependency> findAllExternalDependencies(List<SelfResolvingDependency> externalDependencies, List<Dependency> visited, Configuration configuration) { for (Dependency dependency : configuration.getAllDependencies()) { if(!visited.contains(dependency)){ visited.add(dependency); if(dependency instanceof ProjectDependency) { findAllExternalDependencies(externalDependencies, visited, getTargetConfiguration((ProjectDependency) dependency)); } else if (dependency instanceof SelfResolvingDependency) { externalDependencies.add((SelfResolvingDependency) dependency); } } } return externalDependencies; }
/** * Format a dependency for printing * * @param dependency Dependency to format * @return Dependency information for printing */ private String formatDependency(Dependency dependency) { @NonNull String info; if (dependency instanceof SelfResolvingDependency) { SelfResolvingDependency selfResolvingDependency = (SelfResolvingDependency) dependency; info = Validate.notNull(Joiner.on(", ").join(selfResolvingDependency.resolve())); } else { info = dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion(); } return info; }
public void convert(FileCollection notation, NotationConvertResult<? super SelfResolvingDependency> result) throws TypeConversionException { result.converted(instantiator.newInstance(DefaultSelfResolvingDependency.class, notation)); }
public void convert(DependencyFactory.ClassPathNotation notation, NotationConvertResult<? super SelfResolvingDependency> result) throws TypeConversionException { Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles(); FileCollection files = fileResolver.resolveFiles(classpath); result.converted(instantiator.newInstance(DefaultSelfResolvingDependency.class, files)); }
public void resolve(TaskDependencyResolveContext context) { for (SelfResolvingDependency dependency : DefaultDependencySet.this.withType(SelfResolvingDependency.class)) { context.add(dependency); } }
public SelfResolvingDependency copy() { return new DefaultSelfResolvingDependency(source); }
public SelfResolvingDependency parseType(FileCollection notation) { return instantiator.newInstance(DefaultSelfResolvingDependency.class, notation); }
public SelfResolvingDependency parseType(DependencyFactory.ClassPathNotation notation) { Collection<File> classpath = classPathRegistry.getClassPath(notation.name()).getAsFiles(); FileCollection files = fileResolver.resolveFiles(classpath); return instantiator.newInstance(DefaultSelfResolvingDependency.class, files); }