use of org.gradle.api.artifacts.ProjectDependency in project atlas by alibaba.
the class TDependencyManager method gatherDependencies.
@NonNull
private DependencyContainer gatherDependencies(@NonNull Configuration configuration, @NonNull final VariantDependencies variantDeps, @NonNull Multimap<AndroidLibrary, Configuration> reverseLibMap, @NonNull Set<String> currentUnresolvedDependencies, @Nullable String testedProjectPath, @NonNull Set<String> artifactSet, @NonNull ScopeType scopeType) {
// collect the artifacts first.
Map<ModuleVersionIdentifier, List<ResolvedArtifact>> artifacts = Maps.newHashMap();
configuration = collectArtifacts(configuration, artifacts);
// keep a map of modules already processed so that we don't go through sections of the
// graph that have been seen elsewhere.
Map<ModuleVersionIdentifier, List<LibraryDependency>> foundLibraries = Maps.newHashMap();
Map<ModuleVersionIdentifier, List<JarDependency>> foundJars = Maps.newHashMap();
// get the graph for the Android and Jar dependencies. This does not include
// local jars.
List<LibraryDependency> libraryDependencies = Lists.newArrayList();
List<JarDependency> jarDependencies = Lists.newArrayList();
Set<? extends DependencyResult> dependencyResultSet = configuration.getIncoming().getResolutionResult().getRoot().getDependencies();
for (DependencyResult dependencyResult : dependencyResultSet) {
if (dependencyResult instanceof ResolvedDependencyResult) {
addDependency(((ResolvedDependencyResult) dependencyResult).getSelected(), variantDeps, configuration, libraryDependencies, jarDependencies, foundLibraries, foundJars, artifacts, reverseLibMap, currentUnresolvedDependencies, testedProjectPath, Collections.emptyList(), artifactSet, scopeType, false, /*forceProvided*/
0);
} else if (dependencyResult instanceof UnresolvedDependencyResult) {
ComponentSelector attempted = ((UnresolvedDependencyResult) dependencyResult).getAttempted();
if (attempted != null) {
currentUnresolvedDependencies.add(attempted.toString());
}
}
}
// also need to process local jar files, as they are not processed by the
// resolvedConfiguration result. This only includes the local jar files for this project.
List<JarDependency> localJars = Lists.newArrayList();
for (Dependency dependency : configuration.getAllDependencies()) {
if (dependency instanceof SelfResolvingDependency && !(dependency instanceof ProjectDependency)) {
Set<File> files = ((SelfResolvingDependency) dependency).resolve();
for (File localJarFile : files) {
if (DEBUG_DEPENDENCY) {
System.out.println("LOCAL " + configuration.getName() + ": " + localJarFile.getName());
}
// only accept local jar, no other types.
if (!localJarFile.getName().toLowerCase(Locale.getDefault()).endsWith(DOT_JAR)) {
variantDeps.getChecker().handleIssue(localJarFile.getAbsolutePath(), SyncIssue.TYPE_NON_JAR_LOCAL_DEP, SyncIssue.SEVERITY_ERROR, String.format("Project %s: Only Jar-type local dependencies are supported. Cannot handle: %s", project.getName(), localJarFile.getAbsolutePath()));
} else {
JarDependency localJar;
switch(scopeType) {
case PACKAGE:
localJar = new JarDependency(localJarFile);
artifactSet.add(computeVersionLessCoordinateKey(localJar.getResolvedCoordinates()));
break;
case COMPILE:
MavenCoordinates coord = JarDependency.getCoordForLocalJar(localJarFile);
boolean provided = !artifactSet.contains(computeVersionLessCoordinateKey(coord));
localJar = new JarDependency(localJarFile, ImmutableList.of(), coord, null, provided);
break;
case COMPILE_ONLY:
// if we only have the compile scope, ignore computation of the
// provided bits.
localJar = new JarDependency(localJarFile);
break;
default:
throw new RuntimeException("unsupported ProvidedComputationAction");
}
localJars.add(localJar);
}
}
}
}
return new DependencyContainerImpl(libraryDependencies, jarDependencies, localJars);
}
use of org.gradle.api.artifacts.ProjectDependency in project atlas by alibaba.
the class DependencyManager method ensureConfigured.
private void ensureConfigured(Configuration config) {
for (Dependency dependency : config.getAllDependencies()) {
if (dependency instanceof ProjectDependency) {
ProjectDependency projectDependency = (ProjectDependency) dependency;
project.evaluationDependsOn(projectDependency.getDependencyProject().getPath());
try {
ensureConfigured(projectDependency.getProjectConfiguration());
} catch (Throwable e) {
throw new UnknownProjectException(String.format("Cannot evaluate module %s : %s", projectDependency.getName(), e.getMessage()), e);
}
}
}
}
use of org.gradle.api.artifacts.ProjectDependency in project gradle-eta by typelead.
the class DefaultEtaConfiguration method searchForEtaProjectDependencies.
public static List<String> searchForEtaProjectDependencies(final Project project, final Configuration configuration) {
List<String> allMavenDependencies = new ArrayList<String>();
for (Dependency dependency : configuration.getAllDependencies()) {
if (dependency instanceof ProjectDependency) {
final ProjectDependency projectDependency = (ProjectDependency) dependency;
final Project targetProject = projectDependency.getDependencyProject();
final String targetConfiguration = projectDependency.getTargetConfiguration();
List<String> mavenDependencies;
if (targetProject.getPlugins().hasPlugin(EtaBasePlugin.class)) {
mavenDependencies = ConfigurationUtils.getEtaConfiguration(targetProject, targetConfiguration).getAllResolvedDependencies(project);
} else {
mavenDependencies = searchForEtaProjectDependencies(project, ConfigurationUtils.getConfiguration(targetProject, targetConfiguration));
}
allMavenDependencies.addAll(mavenDependencies);
}
}
return allMavenDependencies;
}
use of org.gradle.api.artifacts.ProjectDependency in project gradle-eta by typelead.
the class EtaInjectDependencies method injectProjectDependencies.
private void injectProjectDependencies(final Project project, final DependencyHandler dependencies, Configuration configuration) {
final String configurationName = configuration.getName();
for (Dependency dependency : configuration.getDependencies()) {
if (dependency instanceof ProjectDependency) {
final ProjectDependency projectDependency = (ProjectDependency) dependency;
final Project targetProject = projectDependency.getDependencyProject();
final String targetConfiguration = projectDependency.getTargetConfiguration();
List<String> mavenDependencies;
if (targetProject.getPlugins().hasPlugin(EtaBasePlugin.class)) {
mavenDependencies = ConfigurationUtils.getEtaConfiguration(targetProject, targetConfiguration).getAllResolvedDependencies(project);
} else {
mavenDependencies = DefaultEtaConfiguration.searchForEtaProjectDependencies(project, ConfigurationUtils.getConfiguration(targetProject, targetConfiguration));
}
for (String mavenDependency : mavenDependencies) {
dependencies.add(configurationName, mavenDependency);
}
}
}
for (Configuration parent : configuration.getExtendsFrom()) {
injectProjectDependencies(project, dependencies, parent);
}
}
use of org.gradle.api.artifacts.ProjectDependency in project spring-boot by spring-projects.
the class AbstractBootArchiveTests method addContent.
@SuppressWarnings("unchecked")
void addContent() throws IOException {
this.task.getMainClass().set("com.example.Main");
File classesJavaMain = new File(this.temp, "classes/java/main");
File applicationClass = new File(classesJavaMain, "com/example/Application.class");
applicationClass.getParentFile().mkdirs();
applicationClass.createNewFile();
File resourcesMain = new File(this.temp, "resources/main");
File applicationProperties = new File(resourcesMain, "application.properties");
applicationProperties.getParentFile().mkdirs();
applicationProperties.createNewFile();
File staticResources = new File(resourcesMain, "static");
staticResources.mkdir();
File css = new File(staticResources, "test.css");
css.createNewFile();
this.task.classpath(classesJavaMain, resourcesMain, jarFile("first-library.jar"), jarFile("second-library.jar"), jarFile("third-library-SNAPSHOT.jar"), jarFile("first-project-library.jar"), jarFile("second-project-library-SNAPSHOT.jar"));
Set<ResolvedArtifact> artifacts = new LinkedHashSet<>();
artifacts.add(mockLibraryArtifact("first-library.jar", "com.example", "first-library", "1.0.0"));
artifacts.add(mockLibraryArtifact("second-library.jar", "com.example", "second-library", "1.0.0"));
artifacts.add(mockLibraryArtifact("third-library-SNAPSHOT.jar", "com.example", "third-library", "1.0.0.SNAPSHOT"));
artifacts.add(mockProjectArtifact("first-project-library.jar", "com.example", "first-project-library", "1.0.0"));
artifacts.add(mockProjectArtifact("second-project-library-SNAPSHOT.jar", "com.example", "second-project-library", "1.0.0.SNAPSHOT"));
ResolvedConfiguration resolvedConfiguration = mock(ResolvedConfiguration.class);
given(resolvedConfiguration.getResolvedArtifacts()).willReturn(artifacts);
Configuration configuration = mock(Configuration.class);
given(configuration.getResolvedConfiguration()).willReturn(resolvedConfiguration);
ResolvableDependencies resolvableDependencies = mock(ResolvableDependencies.class);
given(configuration.getIncoming()).willReturn(resolvableDependencies);
DependencySet dependencies = mock(DependencySet.class);
DomainObjectSet<ProjectDependency> projectDependencies = mock(DomainObjectSet.class);
given(dependencies.withType(ProjectDependency.class)).willReturn(projectDependencies);
given(configuration.getAllDependencies()).willReturn(dependencies);
willAnswer((invocation) -> {
invocation.getArgument(0, Action.class).execute(resolvableDependencies);
return null;
}).given(resolvableDependencies).afterResolve(any(Action.class));
given(configuration.getIncoming()).willReturn(resolvableDependencies);
populateResolvedDependencies(configuration);
}
Aggregations