private boolean isMappedToIdeaScope(final Configuration configuration, IdeaModule ideaModule) { Iterable<IdeaScopeMappingRule> rules = Iterables.concat(scopeMappings.values()); boolean matchesRule = Iterables.any(rules, new Predicate<IdeaScopeMappingRule>() { @Override public boolean apply(IdeaScopeMappingRule ideaScopeMappingRule) { return ideaScopeMappingRule.configurationNames.contains(configuration.getName()); } }); if (matchesRule) { return true; } for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) { Iterable<Configuration> configurations = Iterables.concat(scopeMap.values()); if (Iterables.any(configurations, Predicates.equalTo(configuration))) { return true; } } return false; }
/** * Gets unresolved IDE repository file dependencies. * * @param configuration Configuration * @return Unresolved IDE repositoru file dependencies */ public List<UnresolvedIdeRepoFileDependency> getUnresolvedIdeRepoFileDependencies(Configuration configuration) { ResolutionResult result = getIncomingResolutionResult(configuration); List<UnresolvedDependencyResult> unresolvedDependencies = findAllUnresolvedDependencyResults(result.getRoot().getDependencies()); List<UnresolvedIdeRepoFileDependency> unresolvedIdeRepoFileDependencies = new ArrayList<UnresolvedIdeRepoFileDependency>(); for (UnresolvedDependencyResult unresolvedDependencyResult : unresolvedDependencies) { Throwable failure = unresolvedDependencyResult.getFailure(); ComponentSelector componentSelector = unresolvedDependencyResult.getAttempted(); String displayName = componentSelector.getDisplayName(); File file = new File(unresolvedFileName(componentSelector)); unresolvedIdeRepoFileDependencies.add(new UnresolvedIdeRepoFileDependency(file, failure, displayName)); } return unresolvedIdeRepoFileDependencies; }
/** * 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; }
/** * Gets IDE repository file dependencies. * * @param configuration Configuration * @return IDE repository file dependencies */ public List<IdeExtendedRepoFileDependency> getIdeRepoFileDependencies(Configuration configuration) { ResolutionResult result = getIncomingResolutionResult(configuration); final Set<ResolvedComponentResult> resolvedRepoFileComponents = CollectionUtils.filter(result.getAllComponents(), new Spec<ResolvedComponentResult>() { @Override public boolean isSatisfiedBy(ResolvedComponentResult element) { return element.getId() instanceof ModuleComponentIdentifier; } }); Set<ModuleVersionIdentifier> mappedResolvedDependencies = mapResolvedDependencies(resolvedRepoFileComponents); Set<ResolvedArtifact> artifacts = getExternalArtifacts(configuration); List<IdeExtendedRepoFileDependency> externalDependencies = new ArrayList<IdeExtendedRepoFileDependency>(); for (ResolvedArtifact artifact : artifacts) { if (mappedResolvedDependencies.contains(artifact.getModuleVersion().getId())) { IdeExtendedRepoFileDependency ideRepoFileDependency = new IdeExtendedRepoFileDependency(artifact.getFile()); ideRepoFileDependency.setId(artifact.getModuleVersion().getId()); externalDependencies.add(ideRepoFileDependency); } } return externalDependencies; }
private File getBaseApFile(Project project, TBuildType tBuildType) { File apBaseFile; File buildTypeBaseApFile = tBuildType.getBaseApFile(); if (null != buildTypeBaseApFile && buildTypeBaseApFile.exists()) { apBaseFile = buildTypeBaseApFile; } else if (!isNullOrEmpty(tBuildType.getBaseApDependency())) { String apDependency = tBuildType.getBaseApDependency(); // Preconditions.checkNotNull(apDependency, // "You have to specify the baseApFile property or the baseApDependency // dependency"); Dependency dependency = project.getDependencies().create(apDependency); Configuration configuration = project.getConfigurations().detachedConfiguration(dependency); configuration.setTransitive(false); apBaseFile = Iterables.getOnlyElement(Collections2.filter(configuration.getFiles(), new Predicate<File>() { @Override public boolean apply(@Nullable File file) { return file.getName().endsWith(".ap"); } })); } else { throw new IllegalStateException("AP is missing"); } return apBaseFile; }
private Iterable<Configuration> ideaConfigurations(final IdeaModule ideaModule) { Set<Configuration> configurations = Sets.newLinkedHashSet(ideaModule.getProject().getConfigurations()); for (Map<String, Collection<Configuration>> scopeMap : ideaModule.getScopes().values()) { for (Configuration cfg : Iterables.concat(scopeMap.values())) { configurations.add(cfg); } } return Iterables.filter( configurations, new Predicate<Configuration>() { @Override public boolean apply(Configuration input) { return isMappedToIdeaScope(input, ideaModule); } }); }
@Override public void triggerWhenEmptyActionsIfNecessary() { if (!defaultDependencyActions.isEmpty()) { for (Action<? super DependencySet> action : defaultDependencyActions) { if (!dependencies.isEmpty()) { break; } action.execute(dependencies); } } // Discard actions defaultDependencyActions.clear(); for (Configuration superConfig : extendsFrom) { ((ConfigurationInternal) superConfig).triggerWhenEmptyActionsIfNecessary(); } }
private void defineConfigurationsForSourceSet(SourceSet sourceSet, ConfigurationContainer configurations) { Configuration compileConfiguration = configurations.maybeCreate(sourceSet.getCompileConfigurationName()); compileConfiguration.setVisible(false); compileConfiguration.setDescription("Dependencies for " + sourceSet + "."); Configuration runtimeConfiguration = configurations.maybeCreate(sourceSet.getRuntimeConfigurationName()); runtimeConfiguration.setVisible(false); runtimeConfiguration.extendsFrom(compileConfiguration); runtimeConfiguration.setDescription("Runtime dependencies for " + sourceSet + "."); Configuration compileOnlyConfiguration = configurations.maybeCreate(sourceSet.getCompileOnlyConfigurationName()); compileOnlyConfiguration.setVisible(false); compileOnlyConfiguration.extendsFrom(compileConfiguration); compileOnlyConfiguration.setDescription("Compile dependencies for " + sourceSet + "."); Configuration compileClasspathConfiguration = configurations.maybeCreate(sourceSet.getCompileClasspathConfigurationName()); compileClasspathConfiguration.setVisible(false); compileClasspathConfiguration.extendsFrom(compileOnlyConfiguration); compileClasspathConfiguration.setDescription("Compile classpath for " + sourceSet + "."); sourceSet.setCompileClasspath(compileClasspathConfiguration); sourceSet.setRuntimeClasspath(sourceSet.getOutput().plus(runtimeConfiguration)); }
private static void addStandardJavaTestDependencies(Project project) { Configuration testConfiguration = project.getPlugins().hasPlugin(JavaLibraryPlugin.class) ? project .getConfigurations() .getByName(JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME) : project.getConfigurations().getByName(JavaPlugin.TEST_COMPILE_CONFIGURATION_NAME); DependencyHandler dependencies = project.getDependencies(); dependencies.add(JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME, "com.google.code.findbugs:jsr305"); dependencies.add(testConfiguration.getName(), "org.curioswitch.curiostack:curio-testing-framework"); dependencies.add(testConfiguration.getName(), "org.assertj:assertj-core"); dependencies.add(testConfiguration.getName(), "org.awaitility:awaitility"); dependencies.add(testConfiguration.getName(), "junit:junit"); dependencies.add(testConfiguration.getName(), "org.mockito:mockito-core"); dependencies.add(testConfiguration.getName(), "info.solidsoft.mockito:mockito-java8"); }
private Set<String> getBundleDependencies(Configuration compileClasspath, Set<? extends DependencyResult> bundleDependencies) { Set<String> bundleSets = new HashSet<>(); for (DependencyResult dependencyResult : bundleDependencies) { bundleSets.add(dependencyResult.toString()); } for (Dependency dependency : compileClasspath.getAllDependencies()) { if (dependency instanceof DefaultExternalModuleDependency) { DefaultExternalModuleDependency externalModuleDependency = (DefaultExternalModuleDependency)dependency; if (!((DefaultExternalModuleDependency)dependency).getArtifacts().isEmpty()) { if (StringUtils.equalsIgnoreCase("awb", ((DefaultExternalModuleDependency)dependency).getArtifacts() .iterator().next().getType())) { bundleSets.add( dependency.getGroup() + ":" + dependency.getName() + ":" + dependency.getVersion()); } } } } return bundleSets; }
private List createInsightDependencyChildren(RenderableDependency dependency, final Set<Object> visited, final Configuration configuration) { Iterable<? extends RenderableDependency> children = dependency.getChildren(); return CollectionUtils.collect(children, new Transformer<Object, RenderableDependency>() { @Override public Object transform(RenderableDependency childDependency) { boolean alreadyVisited = !visited.add(childDependency.getId()); boolean leaf = childDependency.getChildren().isEmpty(); boolean alreadyRendered = alreadyVisited && !leaf; String childName = replaceArrow(childDependency.getName()); boolean hasConflict = !childName.equals(childDependency.getName()); String name = leaf ? configuration.getName() : childName; LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>(6); map.put("name", name); map.put("resolvable", childDependency.getResolutionState()); map.put("hasConflict", hasConflict); map.put("alreadyRendered", alreadyRendered); map.put("isLeaf", leaf); map.put("children", Collections.emptyList()); if (!alreadyRendered) { map.put("children", createInsightDependencyChildren(childDependency, visited, configuration)); } return map; } }); }
@TaskAction public void generate() { ProjectReportGenerator projectReportGenerator = new ProjectReportGenerator() { @Override public void generateReport(Project project) throws IOException { Configuration configuration = getProject().getBuildscript().getConfigurations().getByName(ScriptHandler.CLASSPATH_CONFIGURATION); renderer.startConfiguration(configuration); renderer.render(configuration); renderer.completeConfiguration(configuration); } }; ReportGenerator reportGenerator = new ReportGenerator(renderer, getClientMetaData(), null, getTextOutputFactory(), projectReportGenerator); reportGenerator.generateReport(Collections.singleton(getProject())); }
private void collectArtifacts(Configuration configuration, Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts) { Set<ResolvedArtifact> allArtifacts; if (!extraModelInfo.getMode().equals(STANDARD)) { allArtifacts = configuration.getResolvedConfiguration().getLenientConfiguration().getArtifacts( Specs.satisfyAll()); } else { allArtifacts = configuration.getResolvedConfiguration().getResolvedArtifacts(); } for (ResolvedArtifact artifact : allArtifacts) { ModuleVersionIdentifier id = artifact.getModuleVersion().getId(); List<ResolvedArtifact> moduleArtifacts = artifacts.get(id); if (moduleArtifacts == null) { moduleArtifacts = Lists.newArrayList(); artifacts.put(id, moduleArtifacts); } if (!moduleArtifacts.contains(artifact)) { moduleArtifacts.add(artifact); } } }
public void apply(String taskName) { if (taskName.startsWith(PREFIX)) { for (Configuration configuration : project.getConfigurations()) { if (taskName.equals(configuration.getUploadTaskName())) { createUploadTask(configuration.getUploadTaskName(), configuration, project); } } } }
private void configureArchivesAndComponent(final Project project, final JavaPluginConvention pluginConvention) { Jar jar = project.getTasks().create(JAR_TASK_NAME, Jar.class); jar.setDescription("Assembles a jar archive containing the main classes."); jar.setGroup(BasePlugin.BUILD_GROUP); jar.from(pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME).getOutput()); ArchivePublishArtifact jarArtifact = new ArchivePublishArtifact(jar); Configuration runtimeConfiguration = project.getConfigurations().getByName(RUNTIME_CONFIGURATION_NAME); runtimeConfiguration.getArtifacts().add(jarArtifact); project.getExtensions().getByType(DefaultArtifactPublicationSet.class).addCandidate(jarArtifact); project.getComponents().add(new JavaLibrary(jarArtifact, runtimeConfiguration.getAllDependencies())); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { dependencies.add(project.getDependencies().create("jdepend:jdepend:" + extension.getToolVersion())); dependencies.add(project.getDependencies().create("org.apache.ant:ant-jdepend:1.9.6")); } }); }
@Override protected void configureTaskDefaults(Pmd task, String baseName) { Configuration configuration = project.getConfigurations().getAt("pmd"); configureDefaultDependencies(configuration); configureTaskConventionMapping(configuration, task); configureReportsConventionMapping(task, baseName); }
private void configureDefaultDependencies(Configuration configuration) { configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet dependencies) { VersionNumber version = VersionNumber.parse(extension.getToolVersion()); String dependency = calculateDefaultDependencyNotation(version); dependencies.add(project.getDependencies().create(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; }
@Override protected void configureTaskDefaults(Checkstyle task, final String baseName) { Configuration configuration = project.getConfigurations().getAt("checkstyle"); configureDefaultDependencies(configuration); configureTaskConventionMapping(configuration, task); configureReportsConventionMapping(task, baseName); }
protected void createConfigurations() { Configuration configuration = project.getConfigurations().create(getConfigurationName()); configuration.setVisible(false); configuration.setTransitive(true); configuration.setDescription("The " + getToolName() + " libraries to be used for this project."); // Don't need these things, they're provided by the runtime configuration.exclude(excludeProperties("ant", "ant")); configuration.exclude(excludeProperties("org.apache.ant", "ant")); configuration.exclude(excludeProperties("org.apache.ant", "ant-launcher")); configuration.exclude(excludeProperties("org.slf4j", "slf4j-api")); configuration.exclude(excludeProperties("org.slf4j", "jcl-over-slf4j")); configuration.exclude(excludeProperties("org.slf4j", "log4j-over-slf4j")); configuration.exclude(excludeProperties("commons-logging", "commons-logging")); configuration.exclude(excludeProperties("log4j", "log4j")); }
@Override protected void configureTaskDefaults(CodeNarc task, String baseName) { Configuration configuration = project.getConfigurations().getAt("codenarc"); configureDefaultDependencies(configuration); configureTaskConventionMapping(configuration, task); configureReportsConventionMapping(task, baseName); }
private Set<Configuration> configOrEmptySet(Set<Configuration> configuration) { if (configuration == null) { return Sets.newHashSet(); } else { return configuration; } }
public WtpClasspathAttributeSupport(Project project, EclipseModel model) { isUtilityProject = !project.getPlugins().hasPlugin(WarPlugin.class) && !project.getPlugins().hasPlugin(EarPlugin.class); EclipseWtp eclipseWtp = model.getWtp(); EclipseWtpComponent wtpComponent = eclipseWtp.getComponent(); libDirName = wtpComponent.getLibDeployPath(); Set<Configuration> rootConfigs = wtpComponent.getRootConfigurations(); Set<Configuration> libConfigs = wtpComponent.getLibConfigurations(); Set<Configuration> minusConfigs = wtpComponent.getMinusConfigurations(); rootConfigFiles = collectFilesFromConfigs(rootConfigs, minusConfigs); libConfigFiles = collectFilesFromConfigs(libConfigs, minusConfigs); }
private Set<Conf2ScopeMapping> getMappingsWithHighestPriority(Collection<Configuration> configurations) { Integer lastPriority = null; Set<Conf2ScopeMapping> result = new HashSet<Conf2ScopeMapping>(); for (Conf2ScopeMapping conf2ScopeMapping : getMappingsForConfigurations(configurations)) { Integer thisPriority = conf2ScopeMapping.getPriority(); if (lastPriority != null && lastPriority.equals(thisPriority)) { result.add(conf2ScopeMapping); } else if (lastPriority == null || (thisPriority != null && lastPriority < thisPriority)) { lastPriority = thisPriority; result = WrapUtil.toSet(conf2ScopeMapping); } } return result; }
private List<Conf2ScopeMapping> getMappingsForConfigurations(Collection<Configuration> configurations) { List<Conf2ScopeMapping> existingMappings = new ArrayList<Conf2ScopeMapping>(); for (Configuration configuration : configurations) { if (mappings.get(configuration) != null) { existingMappings.add(mappings.get(configuration)); } else { existingMappings.add(new Conf2ScopeMapping(null, configuration, null)); } } return existingMappings; }
private Dependency doAdd(Configuration configuration, Object dependencyNotation, Closure configureClosure) { if (dependencyNotation instanceof Configuration) { Configuration other = (Configuration) dependencyNotation; if (!configurationContainer.contains(other)) { throw new UnsupportedOperationException("Currently you can only declare dependencies on configurations from the same project."); } configuration.extendsFrom(other); return null; } Dependency dependency = create(dependencyNotation, configureClosure); configuration.getDependencies().add(dependency); return dependency; }
private void configureInstall(Project project) { Upload installUpload = project.getTasks().create(INSTALL_TASK_NAME, Upload.class); Configuration configuration = project.getConfigurations().getByName(Dependency.ARCHIVES_CONFIGURATION); installUpload.setConfiguration(configuration); MavenRepositoryHandlerConvention repositories = new DslObject(installUpload.getRepositories()).getConvention().getPlugin(MavenRepositoryHandlerConvention.class); repositories.mavenInstaller(); installUpload.setDescription("Installs the 'archives' artifacts into the local Maven repository."); }
private void configureConfigurations(final Project project) { ConfigurationContainer configurations = project.getConfigurations(); Configuration moduleConfiguration = configurations.create(DEPLOY_CONFIGURATION_NAME).setVisible(false) .setTransitive(false).setDescription("Classpath for deployable modules, not transitive."); Configuration earlibConfiguration = configurations.create(EARLIB_CONFIGURATION_NAME).setVisible(false) .setDescription("Classpath for module dependencies."); configurations.getByName(Dependency.DEFAULT_CONFIGURATION) .extendsFrom(moduleConfiguration, earlibConfiguration); }
/** * Creates signing tasks that sign {@link Configuration#getAllArtifacts() all of the artifacts} of the given configurations. * * <p>The created tasks will be named "sign<i><configuration name capitalized></i>". That is, given a configuration with the name "archives" the created task will be named "signArchives". * * The signature artifact for the created task is added to the {@link #getConfiguration() for this settings object}. * * @param configurations The configurations whose archives are to be signed * @return the created tasks. */ public List<Sign> sign(Configuration... configurations) { List<Sign> result = new ArrayList<Sign>(configurations.length); for (final Configuration configurationToSign : configurations) { result.add( createSignTaskFor(configurationToSign.getName(), new Action<Sign>() { public void execute(Sign task) { task.sign(configurationToSign); } }) ); } return result; }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final JsHintExtension extension) { Configuration configuration = configurations.create(JsHintExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = JsHintExtension.DEFAULT_DEPENDENCY_GROUP + ":" + JsHintExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
public Collection<IdeExtendedRepoFileDependency> extractRepoFileDependencies(DependencyHandler dependencyHandler, Collection<Configuration> plusConfigurations, Collection<Configuration> minusConfigurations, boolean downloadSources, boolean downloadJavadoc) { // can have multiple IDE dependencies with same component identifier (see GRADLE-1622) Multimap<ComponentIdentifier, IdeExtendedRepoFileDependency> resolvedDependenciesComponentMap = LinkedHashMultimap.create(); for (IdeExtendedRepoFileDependency dep : resolvedExternalDependencies(plusConfigurations, minusConfigurations)) { resolvedDependenciesComponentMap.put(toComponentIdentifier(dep.getId()), dep); } List<Class<? extends Artifact>> artifactTypes = new ArrayList<Class<? extends Artifact>>(2); if (downloadSources) { artifactTypes.add(SourcesArtifact.class); } if (downloadJavadoc) { artifactTypes.add(JavadocArtifact.class); } downloadAuxiliaryArtifacts(dependencyHandler, resolvedDependenciesComponentMap, artifactTypes); Collection<UnresolvedIdeRepoFileDependency> unresolvedDependencies = unresolvedExternalDependencies(plusConfigurations, minusConfigurations); Collection<IdeExtendedRepoFileDependency> resolvedDependencies = resolvedDependenciesComponentMap.values(); Collection<IdeExtendedRepoFileDependency> resolvedAndUnresolved = new ArrayList<IdeExtendedRepoFileDependency>(unresolvedDependencies.size() + resolvedDependencies.size()); resolvedAndUnresolved.addAll(resolvedDependencies); resolvedAndUnresolved.addAll(unresolvedDependencies); return resolvedAndUnresolved; }
public Configuration addConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final EnvJsExtension extension) { Configuration configuration = configurations.create(EnvJsExtension.CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = EnvJsExtension.DEFAULT_DEPENDENCY_GROUP + ":" + EnvJsExtension.DEFAULT_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
private Configuration addJsConfiguration(ConfigurationContainer configurations, final DependencyHandler dependencies, final CoffeeScriptExtension extension) { Configuration configuration = configurations.create(CoffeeScriptExtension.JS_CONFIGURATION_NAME); configuration.defaultDependencies(new Action<DependencySet>() { @Override public void execute(DependencySet configDependencies) { String notation = CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_GROUP + ":" + CoffeeScriptExtension.DEFAULT_JS_DEPENDENCY_MODULE + ":" + extension.getVersion() + "@js"; Dependency dependency = dependencies.create(notation); configDependencies.add(dependency); } }); return configuration; }
@Override public Configuration findProjectConfiguration() { ConfigurationContainer dependencyConfigurations = getDependencyProject().getConfigurations(); String declaredConfiguration = getTargetConfiguration(); Configuration selectedConfiguration = dependencyConfigurations.getByName(GUtil.elvis(declaredConfiguration, Dependency.DEFAULT_CONFIGURATION)); if (!selectedConfiguration.isCanBeConsumed()) { throw new ConfigurationNotConsumableException(dependencyProject.getDisplayName(), selectedConfiguration.getName()); } return selectedConfiguration; }
private boolean exists(PluginRequest request) { // This works because the corresponding BackedByArtifactRepository PluginRepository sets // registers an ArtifactRepository in the DependencyResolutionServices instance which is // exclusively used by this ArtifactRepositoryPluginResolver. If the plugin marker // doesn't exist in that isolated ArtifactRepository, this resolver won't look anywhere else. Dependency dependency = resolution.getDependencyHandler().create(getMarkerCoordinates(request)); ConfigurationContainer configurations = resolution.getConfigurationContainer(); Configuration configuration = configurations.detachedConfiguration(dependency); configuration.setTransitive(false); return !configuration.getResolvedConfiguration().hasError(); }
public Object methodMissing(String name, Object arg) { Object[] args = (Object[]) arg; Configuration configuration = configurationContainer.findByName(name); if (configuration == null) { throw new MissingMethodException(name, this.getClass(), args); } List<Object> normalizedArgs = GUtil.flatten(Arrays.asList(args), false); if (normalizedArgs.size() == 2 && normalizedArgs.get(1) instanceof Closure) { return pushArtifact(configuration, normalizedArgs.get(0), (Closure) normalizedArgs.get(1)); } for (Object notation : args) { pushArtifact(configuration, notation, Actions.doNothing()); } return null; }
@Override protected Configuration doCreate(String name) { DefaultResolutionStrategy resolutionStrategy = instantiator.newInstance(DefaultResolutionStrategy.class, globalDependencySubstitutionRules, componentIdentifierFactory); return instantiator.newInstance(DefaultConfiguration.class, context.identityPath(name), context.projectPath(name), name, this, resolver, listenerManager, dependencyMetaDataProvider, resolutionStrategy, projectAccessListener, projectFinder, configurationComponentMetaDataBuilder, fileCollectionFactory, componentIdentifierFactory, buildOperationExecutor, instantiator, artifactNotationParser); }
public Collection<UnresolvedIdeRepoFileDependency> getUnresolvedDependencies(IdeaModule ideaModule) { Set<UnresolvedIdeRepoFileDependency> usedUnresolvedDependencies = Sets.newTreeSet(new Comparator<UnresolvedIdeRepoFileDependency>() { @Override public int compare(UnresolvedIdeRepoFileDependency left, UnresolvedIdeRepoFileDependency right) { return left.getDisplayName().compareTo(right.getDisplayName()); } }); for (GeneratedIdeaScope scope : GeneratedIdeaScope.values()) { Map<String, Collection<Configuration>> plusMinusConfigurations = ideaModule.getScopes().get(scope.name()); if (plusMinusConfigurations == null) { if (shouldProcessScope(scope, ideaModule.getScopes())) { plusMinusConfigurations = Collections.emptyMap(); } else { continue; } } List<Configuration> plusConfigurations = plusMinusConfigurations.containsKey("plus") ? Lists.newArrayList(plusMinusConfigurations.get("plus")) : Lists.<Configuration>newArrayList(); List<Configuration> minusConfigurations = plusMinusConfigurations.containsKey("minus") ? Lists.newArrayList(plusMinusConfigurations.get("minus")) : Lists.<Configuration>newArrayList(); for (IdeaScopeMappingRule scopeMappingRule : scopeMappings.get(scope)) { for(Configuration configuration: ideaModule.getProject().getConfigurations()) { if (scopeMappingRule.configurationNames.contains(configuration.getName())) { plusConfigurations.add(configuration); } } } usedUnresolvedDependencies.addAll(dependenciesExtractor.unresolvedExternalDependencies(plusConfigurations, minusConfigurations)); } return usedUnresolvedDependencies; }
private static boolean doesConfigurationDependOnProject(Configuration configuration, Project project) { Set<ProjectDependency> projectDependencies = configuration.getAllDependencies().withType(ProjectDependency.class); for (ProjectDependency projectDependency : projectDependencies) { if (projectDependency.getDependencyProject().equals(project)) { return true; } } return false; }