org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency Java Examples
The following examples show how to use
org.gradle.api.internal.artifacts.dependencies.DefaultProjectDependency.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AtlasDepTreeParser.java From atlas with Apache License 2.0 | 6 votes |
private void prepareProject(ProjectDependency projectDependency,Configuration configuration) { if (projectDependency.getTargetConfiguration() == null || projectDependency.getTargetConfiguration().equals("default")){ projectDependency.setTargetConfiguration(AtlasConfigurationHelper.COMPILE_PROJECT_CONFIGURATION_NAME); } ((ProjectInternal)((DefaultProjectDependency) projectDependency).getDependencyProject()).evaluate(); String name = configuration.getName(); Configuration config = projectDependency.getDependencyProject().getConfigurations().findByName(name); if (config == null) { config = projectDependency.getDependencyProject().getConfigurations().findByName(newName(name)); } if (config!= null && config.getAllDependencies()!= null) { ensureConfigured(config,projectDependency.getDependencyProject()); } }
Example #2
Source File: GradleArtifactResolvingHelper.java From wildfly-swarm with Apache License 2.0 | 6 votes |
private Set<ResolvedDependency> doResolve(final Collection<ArtifactSpec> deps) { final Configuration config = this.project.getConfigurations().detachedConfiguration(); final DependencySet dependencySet = config.getDependencies(); deps.stream() .forEach(spec -> { if (projects.containsKey(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version())) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projects.get(spec.groupId() + ":" + spec.artifactId() + ":" + spec.version()), new DefaultProjectAccessListener(), false)); } else { final DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(spec.groupId(), spec.artifactId(), spec.version()); final DefaultDependencyArtifact da = new DefaultDependencyArtifact(spec.artifactId(), spec.type(), spec.type(), spec.classifier(), null); d.addArtifact(da); d.getExcludeRules().add(new DefaultExcludeRule()); dependencySet.add(d); } }); return config.getResolvedConfiguration().getFirstLevelModuleDependencies(); }
Example #3
Source File: UpdatePomTask.java From atlas with Apache License 2.0 | 5 votes |
private Map<String, DependencyExtraInfo> getExtraMap() { Map<String, DependencyExtraInfo> dependencyExtraInfoMap = new HashMap<>(); DependencySet dependencies = project.getConfigurations().getByName("compile").getDependencies(); dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { String group = dependency.getGroup(); String name = dependency.getName(); String scope = "compile"; String type = ""; if (dependency instanceof DefaultProjectDependency) { DefaultProjectDependency projectDependency = (DefaultProjectDependency)dependency; if (projectDependency.getDependencyProject().getPlugins().hasPlugin(LibraryPlugin.class)) { type = "aar"; } } dependencyExtraInfoMap.put(group + ":" + name, new DependencyExtraInfo(type, scope)); } }); return dependencyExtraInfoMap; }
Example #4
Source File: DefaultProjectDependencyFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(ProjectInternal project, String configuration) { return instantiator.newInstance(DefaultProjectDependency.class, project, configuration, projectAccessListener, buildProjectDependencies); }
Example #5
Source File: DefaultProjectDependencyFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(Project project) { return instantiator.newInstance(DefaultProjectDependency.class, project, projectAccessListener, buildProjectDependencies); }
Example #6
Source File: DefaultProjectDependencyFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(ProjectInternal project, String configuration) { return instantiator.newInstance(DefaultProjectDependency.class, project, configuration, projectAccessListener, buildProjectDependencies); }
Example #7
Source File: DefaultProjectDependencyFactory.java From pushfish-android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(Project project) { return instantiator.newInstance(DefaultProjectDependency.class, project, projectAccessListener, buildProjectDependencies); }
Example #8
Source File: GradleProjectTest.java From jig with Apache License 2.0 | 4 votes |
private static DefaultProjectDependency dependencyOf(ProjectInternal nonJavaChild) { return new DefaultProjectDependency(nonJavaChild, new ConfigurationOnDemandProjectAccessListener(), true); }
Example #9
Source File: DependencyGroup.java From atlas with Apache License 2.0 | 4 votes |
private Map<String, Set<DependencyResult>>getProjectBundleCompile(Configuration configuration, Set<String> bundleAddedSets){ Map<String,Set<DependencyResult>>bundleMap = new HashMap<>(); configuration.getAllDependencies().forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { if (dependency instanceof DefaultProjectDependency) { DefaultProjectDependency projectDependency = (DefaultProjectDependency)dependency; String key = "project " + ":" + projectDependency.getName(); if (!bundleAddedSets.contains(key)){ return; } Set<DependencyResult> compileSets = new HashSet<>(); try { Set<ResolvedArtifact> resolvedArtifacts = projectDependency.getDependencyProject().getConfigurations().getByName("compile").getResolvedConfiguration().getResolvedArtifacts(); projectDependency.getDependencyProject().getConfigurations().getByName("compile").getIncoming().getResolutionResult().getRoot().getDependencies().forEach(new Consumer<DependencyResult>() { @Override public void accept(DependencyResult dependencyResult) { if (!mainDexs.contains(dependencyResult.toString())){ compileSets.add(dependencyResult); if (dependencyResult instanceof DefaultResolvedDependencyResult){ ModuleVersionIdentifier moduleVersionIdentifier = ((DefaultResolvedDependencyResult) dependencyResult).getSelected().getModuleVersion(); for (ResolvedArtifact resolvedArtifact:resolvedArtifacts) { if (resolvedArtifact.getModuleVersion().getId().equals(moduleVersionIdentifier)) { bundleCompileId.put(moduleVersionIdentifier, resolvedArtifact); } } } } } }); } catch (UnknownConfigurationException e) { } bundleMap.put(projectDependency.getGroup()+":"+projectDependency.getName(), compileSets); } } }); return bundleMap; }
Example #10
Source File: GradleDependencyResolutionHelper.java From thorntail with Apache License 2.0 | 4 votes |
/** * Resolve the given artifact specifications. * * @param project the Gradle project reference. * @param specs the specifications that need to be resolved. * @param transitive should the artifacts be resolved transitively? * @param excludeDefaults should we skip resolving artifacts that belong to the Thorntail group? * @return collection of resolved artifact specifications. */ public static Set<ArtifactSpec> resolveArtifacts(Project project, Collection<ArtifactSpec> specs, boolean transitive, boolean excludeDefaults) { if (project == null) { throw new IllegalArgumentException("Gradle project reference cannot be null."); } if (specs == null) { project.getLogger().warn("Artifact specification collection is null."); return Collections.emptySet(); } // Early return if there is nothing to resolve. if (specs.isEmpty()) { return Collections.emptySet(); } final Configuration config = project.getConfigurations().detachedConfiguration().setTransitive(transitive); final DependencySet dependencySet = config.getDependencies(); final Map<String, Project> projectGAVCoordinates = getAllProjects(project); final ProjectAccessListener listener = new DefaultProjectAccessListener(); Set<ArtifactSpec> result = new HashSet<>(); specs.forEach(s -> { // 1. Do we need to resolve this entry? final String specGAV = String.format(GROUP_ARTIFACT_VERSION_FORMAT, s.groupId(), s.artifactId(), s.version()); boolean resolved = s.file != null; boolean projectEntry = projectGAVCoordinates.containsKey(specGAV); // 2. Should we skip this spec? if (excludeDefaults && FractionDescriptor.THORNTAIL_GROUP_ID.equals(s.groupId()) && !projectEntry) { return; } // 3. Should this entry be resolved? if (!resolved || transitive) { // a.) Does this entry represent a project dependency? if (projectGAVCoordinates.containsKey(specGAV)) { dependencySet.add(new DefaultProjectDependency((ProjectInternal) projectGAVCoordinates.get(specGAV), listener, false)); } else { DefaultExternalModuleDependency d = new DefaultExternalModuleDependency(s.groupId(), s.artifactId(), s.version()); DefaultDependencyArtifact da = new DefaultDependencyArtifact(s.artifactId(), s.type(), s.type(), s.classifier(), null); d.addArtifact(da); dependencySet.add(d); } } else { // 4. Nothing else to do, just add the spec to the result. result.add(s); } }); // 5. Are there any specs that need resolution? if (!dependencySet.isEmpty()) { config.getResolvedConfiguration().getResolvedArtifacts().stream() .map(ra -> asDescriptor("compile", ra).toArtifactSpec()) .forEach(result::add); } return result; }
Example #11
Source File: DefaultProjectDependencyFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(ProjectInternal project, String configuration) { return instantiator.newInstance(DefaultProjectDependency.class, project, configuration, projectAccessListener, buildProjectDependencies); }
Example #12
Source File: DefaultProjectDependencyFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(Project project) { return instantiator.newInstance(DefaultProjectDependency.class, project, projectAccessListener, buildProjectDependencies); }
Example #13
Source File: DefaultProjectDependencyFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(ProjectInternal project, String configuration) { return instantiator.newInstance(DefaultProjectDependency.class, project, configuration, projectAccessListener, buildProjectDependencies); }
Example #14
Source File: DefaultProjectDependencyFactory.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency create(Project project) { return instantiator.newInstance(DefaultProjectDependency.class, project, projectAccessListener, buildProjectDependencies); }
Example #15
Source File: AtlasProjectDependencyManager.java From atlas with Apache License 2.0 | 3 votes |
public static void addProjectDependency(Project project, String variantName) { Task task = project.getTasks().findByName("prepare" + variantName + "Dependencies"); if (null == task){ return; } DependencySet dependencies = project.getConfigurations().getByName( AtlasPlugin.BUNDLE_COMPILE).getDependencies(); if (null == dependencies){ return; } dependencies.forEach(new Consumer<Dependency>() { @Override public void accept(Dependency dependency) { if (dependency instanceof DefaultProjectDependency){ Project subProject = ((DefaultProjectDependency)dependency).getDependencyProject(); Task assembleTask = subProject.getTasks().findByName("assembleRelease"); task.dependsOn(assembleTask); } } }); }