org.gradle.api.artifacts.ProjectDependency Java Examples
The following examples show how to use
org.gradle.api.artifacts.ProjectDependency.
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: Publisher.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static Library getType(Configuration config, Dependency d) { if (d instanceof ProjectDependency) { FirebaseLibraryExtension library = getFirebaseLibrary(((ProjectDependency) d).getDependencyProject()); return new Library(library.getMavenName(), library.type); } Optional<Library> path = StreamSupport.stream(config.spliterator(), false) .map(File::getAbsolutePath) .filter( absPath -> absPath.matches( MessageFormat.format( ".*\\Q{0}/{1}/{2}/\\E[a-zA-Z0-9]+/\\Q{1}-{2}.\\E[aj]ar", d.getGroup(), d.getName(), d.getVersion()))) .findFirst() .map(absPath -> absPath.endsWith(".aar") ? LibraryType.ANDROID : LibraryType.JAVA) .map(type -> new Library(d.getGroup() + ":" + d.getName(), type)); return path.orElse(null); }
Example #2
Source File: ProjectDependencyPublicationResolver.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #3
Source File: DefaultMavenPublication.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
Example #4
Source File: ProjectDependencyPublicationResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #5
Source File: DefaultMavenPublication.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 6 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
Example #6
Source File: CodeServerBuilder.java From putnami-gradle-plugin with GNU Lesser General Public License v3.0 | 6 votes |
private Collection<File> listProjectDepsSrcDirs(Project project) { ConfigurationContainer configs = project.getConfigurations(); Configuration compileConf = configs.getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); DependencySet depSet = compileConf.getAllDependencies(); List<File> result = Lists.newArrayList(); for (Dependency dep : depSet) { if (dep instanceof ProjectDependency) { Project projectDependency = ((ProjectDependency) dep).getDependencyProject(); if (projectDependency.getPlugins().hasPlugin(PwtLibPlugin.class)) { JavaPluginConvention javaConvention = projectDependency.getConvention().getPlugin(JavaPluginConvention.class); SourceSet mainSourceSet = javaConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); result.addAll(mainSourceSet.getAllSource().getSrcDirs()); } } } return result; }
Example #7
Source File: DependencyManager.java From javaide with GNU General Public License v3.0 | 6 votes |
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); } } } }
Example #8
Source File: QuarkusDev.java From quarkus with Apache License 2.0 | 6 votes |
private void addSelfWithLocalDeps(Project project, DevModeContext context, Set<String> visited, Set<AppArtifactKey> addedDeps, boolean root) { if (!visited.add(project.getPath())) { return; } final Configuration compileCp = project.getConfigurations().findByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME); if (compileCp != null) { compileCp.getIncoming().getDependencies().forEach(d -> { if (d instanceof ProjectDependency) { addSelfWithLocalDeps(((ProjectDependency) d).getDependencyProject(), context, visited, addedDeps, false); } }); } addLocalProject(project, context, addedDeps, root); }
Example #9
Source File: GradleProject.java From jig with Apache License 2.0 | 6 votes |
private Stream<Project> allDependencyProjectsFrom(Project root) { if (isNonJavaProject(root)) { return Stream.empty(); } //FIXME: 誰かcompileとimplementation両方が取得できるより良い方法があれば DependencySet compileDependencies = root.getConfigurations().getByName("compile").getAllDependencies(); DependencySet implementationDependencies = root.getConfigurations().getByName("implementation").getAllDependencies(); Stream<Project> descendantStream = Stream.concat(compileDependencies.stream(), implementationDependencies.stream()) .filter(dependency -> ProjectDependency.class.isAssignableFrom(dependency.getClass())) .map(ProjectDependency.class::cast) .map(ProjectDependency::getDependencyProject) .flatMap(this::allDependencyProjectsFrom); return Stream.concat(Stream.of(root), descendantStream); }
Example #10
Source File: ProjectDependencyPublicationResolver.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public ModuleVersionIdentifier resolve(ProjectDependency dependency) { Project dependencyProject = dependency.getDependencyProject(); ((ProjectInternal) dependencyProject).evaluate(); PublishingExtension publishing = dependencyProject.getExtensions().findByType(PublishingExtension.class); if (publishing == null || publishing.getPublications().withType(PublicationInternal.class).isEmpty()) { // Project does not apply publishing (or has no publications): simply use the project name in place of the dependency name return new DefaultModuleVersionIdentifier(dependency.getGroup(), dependencyProject.getName(), dependency.getVersion()); } // See if all publications have the same identifier Set<? extends PublicationInternal> publications = publishing.getPublications().withType(PublicationInternal.class); Iterator<? extends PublicationInternal> iterator = publications.iterator(); ModuleVersionIdentifier candidate = iterator.next().getCoordinates(); while (iterator.hasNext()) { ModuleVersionIdentifier alternative = iterator.next().getCoordinates(); if (!candidate.equals(alternative)) { throw new UnsupportedOperationException("Publishing is not yet able to resolve a dependency on a project with multiple different publications."); } } return candidate; }
Example #11
Source File: DefaultMavenPublication.java From pushfish-android with BSD 2-Clause "Simplified" License | 6 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Maven publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; for (Usage usage : this.component.getUsages()) { // TODO Need a smarter way to map usage to artifact classifier for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact); } // TODO Need a smarter way to map usage to scope for (ModuleDependency dependency : usage.getDependencies()) { if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency); } else { addModuleDependency(dependency); } } } }
Example #12
Source File: Publisher.java From firebase-android-sdk with Apache License 2.0 | 6 votes |
private static Map<String, String> getDependencyTypes(Project project) { Configuration dummyDependencyConfiguration = project.getConfigurations().create("publisherDummyConfig"); Set<Dependency> nonProjectDependencies = project .getConfigurations() .getByName("releaseRuntimeClasspath") .getAllDependencies() .stream() .filter(dep -> !(dep instanceof ProjectDependency)) .collect(Collectors.toSet()); dummyDependencyConfiguration.getDependencies().addAll(nonProjectDependencies); try { return project .getConfigurations() .getByName("releaseRuntimeClasspath") .getAllDependencies() .stream() .map(dep -> getType(dummyDependencyConfiguration, dep)) .filter(Objects::nonNull) .collect(Collectors.toMap(lib -> lib.name, lib -> lib.type.getFormat())); } finally { project.getConfigurations().remove(dummyDependencyConfiguration); } }
Example #13
Source File: QuarkusPlugin.java From quarkus with Apache License 2.0 | 5 votes |
private void afterEvaluate(Project project) { final HashSet<String> visited = new HashSet<>(); project.getConfigurations().getByName(JavaPlugin.COMPILE_CLASSPATH_CONFIGURATION_NAME) .getIncoming().getDependencies() .forEach(d -> { if (d instanceof ProjectDependency) { visitProjectDep(project, ((ProjectDependency) d).getDependencyProject(), visited); } }); }
Example #14
Source File: DefaultIvyPublication.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public void from(SoftwareComponent component) { if (this.component != null) { throw new InvalidUserDataException(String.format("Ivy publication '%s' cannot include multiple components", name)); } this.component = (SoftwareComponentInternal) component; configurations.maybeCreate("default"); for (Usage usage : this.component.getUsages()) { String conf = usage.getName(); configurations.maybeCreate(conf); configurations.getByName("default").extend(conf); for (PublishArtifact publishArtifact : usage.getArtifacts()) { artifact(publishArtifact).setConf(conf); } for (ModuleDependency dependency : usage.getDependencies()) { // TODO: When we support multiple components or configurable dependencies, we'll need to merge the confs of multiple dependencies with same id. String confMapping = String.format("%s->%s", conf, dependency.getConfiguration()); if (dependency instanceof ProjectDependency) { addProjectDependency((ProjectDependency) dependency, confMapping); } else { addModuleDependency(dependency, confMapping); } } } }
Example #15
Source File: TasksFromDependentProjects.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example #16
Source File: TasksFromProjectDependencies.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
void resolveProjectDependencies(TaskDependencyResolveContext context, Set<ProjectDependency> projectDependencies) { for (ProjectDependency projectDependency : projectDependencies) { //in configure-on-demand we don't know if the project was configured, hence explicit evaluate. // Not especially tidy, we should clean this up while working on new configuration model. ((ProjectInternal) projectDependency.getDependencyProject()).evaluate(); Task nextTask = projectDependency.getDependencyProject().getTasks().findByName(taskName); if (nextTask != null) { context.add(nextTask); } } }
Example #17
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ProjectDependency that = (ProjectDependency) dependency; if (!isCommonContentEquals(that)) { return false; } return dependencyProject.equals(that.getDependencyProject()); }
Example #18
Source File: TasksFromProjectDependencies.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
void resolveProjectDependencies(TaskDependencyResolveContext context, Set<ProjectDependency> projectDependencies) { for (ProjectDependency projectDependency : projectDependencies) { //in configure-on-demand we don't know if the project was configured, hence explicit evaluate. // Not especially tidy, we should clean this up while working on new configuration model. ((ProjectInternal) projectDependency.getDependencyProject()).evaluate(); Task nextTask = projectDependency.getDependencyProject().getTasks().findByName(taskName); if (nextTask != null) { context.add(nextTask); } } }
Example #19
Source File: CompileTask.java From gradle-modules-plugin with MIT License | 5 votes |
private void configureCompileJava(JavaCompile compileJava) { project.getConfigurations().stream() .flatMap(configuration -> configuration.getDependencies().stream()) .filter(dependency -> dependency instanceof ProjectDependency) .map(dependency -> ((ProjectDependency) dependency).getDependencyProject().getTasks()) .map(tasks -> tasks.findByName(CompileModuleOptions.COMPILE_MODULE_INFO_TASK_NAME)) .filter(Objects::nonNull); var moduleOptions = compileJava.getExtensions().create("moduleOptions", CompileModuleOptions.class, project); project.afterEvaluate(p -> { adjustMainClass(compileJava); MergeClassesHelper.POST_JAVA_COMPILE_TASK_NAMES.stream() .map(name -> helper().findTask(name, AbstractCompile.class)) .flatMap(Optional::stream) .filter(task -> !task.getSource().isEmpty()) .findAny() .ifPresent(task -> moduleOptions.setCompileModuleInfoSeparately(true)); if (moduleOptions.getCompileModuleInfoSeparately()) { compileJava.exclude("module-info.java"); } else { configureModularityForCompileJava(compileJava, moduleOptions); } }); }
Example #20
Source File: TasksFromDependentProjects.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
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; }
Example #21
Source File: DefaultProjectDependency.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ProjectDependency that = (ProjectDependency) dependency; if (!isCommonContentEquals(that)) { return false; } return dependencyProject.equals(that.getDependencyProject()); }
Example #22
Source File: AssembleNeededPlugin.java From gradle-plugins with Apache License 2.0 | 5 votes |
@Override public void apply(Project project) { project.getPlugins().apply("base"); Task assembleNeeded = project.getTasks().create("assembleNeeded"); assembleNeeded.dependsOn("assemble"); project.afterEvaluate(project1 -> { DomainObjectSet<ProjectDependency> projectDependencies = project1.getConfigurations().getByName("runtime").getAllDependencies().withType(ProjectDependency.class); for (ProjectDependency neededProjectDependency : projectDependencies) { assembleNeeded.dependsOn(neededProjectDependency.getDependencyProject().getPath() + ":assembleNeeded"); } }); }
Example #23
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
public boolean contentEquals(Dependency dependency) { if (this == dependency) { return true; } if (dependency == null || getClass() != dependency.getClass()) { return false; } ProjectDependency that = (ProjectDependency) dependency; if (!isCommonContentEquals(that)) { return false; } return dependencyProject.equals(that.getDependencyProject()); }
Example #24
Source File: DefaultProjectDependencyMetaData.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
@Override public ProjectComponentSelector getSelector() { return new DefaultProjectComponentSelector(((ProjectDependency)getSource()).getDependencyProject().getPath()); }
Example #25
Source File: WarOverlayPlugin.java From gradle-plugins with MIT License | 4 votes |
private void configureOverlay(WarOverlay overlay) { if (overlay.isDeferProvidedConfiguration()) { //Delay this to trick IntelliJ //noinspection Convert2Lambda overlay.getWarTask().doFirst(new Action<Task>() { @Override public void execute(Task w) { overlay.getWarCopySpec().exclude(element -> overlay.isProvided()); } }); } else { overlay.getWarCopySpec().exclude(element -> overlay.isProvided()); } Object source = overlay.getSource(); if (source instanceof AbstractArchiveTask) { configureOverlay(overlay, (AbstractArchiveTask) source); } else if (source instanceof Project && overlay.getConfigureClosure() == null) { configureOverlay(overlay, (Project) source); } else if (source instanceof File) { configureOverlay(overlay, (File) source); } else { Closure configClosure = overlay.getConfigureClosure(); Dependency dependency; if (configClosure == null) { dependency = project.getDependencies().create(source); } else { dependency = project.getDependencies().create(source, configClosure); } if (dependency instanceof ProjectDependency) { configureOverlay(overlay, ((ProjectDependency) dependency).getDependencyProject()); } else if (dependency instanceof ExternalDependency) { configureOverlay(overlay, (ExternalDependency) dependency); } else { throw new GradleException("Unsupported dependency type: " + dependency.getClass().getName()); } } }
Example #26
Source File: DefaultProjectDependencyMetaData.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public DefaultProjectDependencyMetaData(DependencyDescriptor dependencyDescriptor, ProjectDependency source) { super(dependencyDescriptor, source); }
Example #27
Source File: BuildAtlasEnvTask.java From atlas with Apache License 2.0 | 4 votes |
@Override public void execute(BuildAtlasEnvTask updateDependenciesTask) { super.execute(updateDependenciesTask); updateDependenciesTask.appVariantContext = this.appVariantContext; updateDependenciesTask.compileManifests = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, MANIFEST); updateDependenciesTask.compileJars = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, CLASSES); updateDependenciesTask.appVariantOutputContext = getAppVariantOutputContext(); updateDependenciesTask.nativeLibs = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, JNI); updateDependenciesTask.nativeLibs2 = AtlasDependencyGraph.computeArtifactCollection(variantContext.getScope(), AtlasAndroidArtifacts.ConsumedConfigType.COMPILE_CLASSPATH, ALL, AtlasAndroidArtifacts.AtlasArtifactType.LIBS); updateDependenciesTask.javaResources = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, JAVA_RES); updateDependenciesTask.res = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, ANDROID_RES); updateDependenciesTask.assets = appVariantContext.getScope().getArtifactCollection(COMPILE_CLASSPATH, ALL, ASSETS); updateDependenciesTask.symbolListWithPackageNames = appVariantContext.getScope().getArtifactCollection( RUNTIME_CLASSPATH, ALL, AndroidArtifacts.ArtifactType.SYMBOL_LIST_WITH_PACKAGE_NAME); List<ProjectDependency> projectDependencies = new ArrayList<>(); appVariantContext.getScope().getVariantDependencies().getCompileClasspath().getAllDependencies().forEach(dependency -> { if (dependency instanceof ProjectDependency) { projectDependencies.add((ProjectDependency) dependency); // ((ProjectDependency) dependency).getDependencyProject().getConfigurations().getByName("compile"). // getIncoming() // .artifactView( // config -> { // config.attributes(attributes); // if (filter != null) { // config.componentFilter(filter); // } // // TODO somehow read the unresolved dependencies? // config.lenient(lenientMode); // }) // .getArtifacts(); } }); }
Example #28
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 #29
Source File: DefaultProjectDependency.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectDependency copy() { DefaultProjectDependency copiedProjectDependency = new DefaultProjectDependency(dependencyProject, getConfiguration(), projectAccessListener, buildProjectDependencies); copyTo(copiedProjectDependency); return copiedProjectDependency; }
Example #30
Source File: ProjectDependencyDescriptor.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 4 votes |
public ProjectInternal getTargetProject() { return (ProjectInternal) ((ProjectDependency) getModuleDependency()).getDependencyProject(); }