当前位置: 首页>>代码示例>>Java>>正文


Java ProjectDependency类代码示例

本文整理汇总了Java中org.gradle.api.artifacts.ProjectDependency的典型用法代码示例。如果您正苦于以下问题:Java ProjectDependency类的具体用法?Java ProjectDependency怎么用?Java ProjectDependency使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ProjectDependency类属于org.gradle.api.artifacts包,在下文中一共展示了ProjectDependency类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolve

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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;

}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:25,代码来源:ProjectDependencyPublicationResolver.java

示例2: getLibrariesForFileDependencies

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
private Set<GradleLibrary> getLibrariesForFileDependencies(
		Configuration configuration, LibraryScope scope) {
	Set<GradleLibrary> libraries = new LinkedHashSet<GradleLibrary>();
	for (Dependency dependency : configuration.getIncoming().getDependencies()) {
		if (dependency instanceof FileCollectionDependency) {
			FileCollectionDependency fileDependency = (FileCollectionDependency) dependency;
			for (File file : fileDependency.resolve()) {
				libraries.add(
						new GradleLibrary(fileDependency.getGroup(), file, scope));
			}
		}
		else if (dependency instanceof ProjectDependency) {
			ProjectDependency projectDependency = (ProjectDependency) dependency;
			libraries.addAll(getLibrariesForFileDependencies(
					projectDependency.getProjectConfiguration(), scope));
		}
	}
	return libraries;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:ProjectLibraries.java

示例3: ensureConfigured

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:DependencyManager.java

示例4: listProjectDepsSrcDirs

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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;
}
 
开发者ID:Putnami,项目名称:putnami-gradle-plugin,代码行数:20,代码来源:CodeServerBuilder.java

示例5: applyOnce

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
@Override
protected void applyOnce(Project project) {
	ProjectDepsExtension extension = project.getExtensions().create(ProjectDepsExtension.NAME, ProjectDepsExtension.class);
	EclipseProjectPlugin.modifyEclipseProject(project, eclipseModel -> {
		// find the project's referenced projects and reference them explicitly in the eclipse model
		Task prepareEclipse = project.task("prepareEclipse");
		prepareEclipse.doLast(task -> {
			Set<String> referencedProjects = eclipseModel.getProject().getReferencedProjects();
			project.getConfigurations().stream()
					.flatMap(config -> config.getDependencies().stream())
					.filter(dep -> dep instanceof ProjectDependency)
					.forEach(dep -> {
						referencedProjects.add(dep.getName());
					});
		});
		// it's needed for generating the eclipseClasspath and eclipseProject
		Iterables.getOnlyElement(project.getTasksByName("eclipseClasspath", false)).dependsOn(prepareEclipse);
		Iterables.getOnlyElement(project.getTasksByName("eclipseProject", false)).dependsOn(prepareEclipse);

		// create robust classpath entries for all referenced projects
		eclipseModel.getClasspath().getFile().getXmlTransformer().addAction(xmlProvider -> {
			modifyClasspath(xmlProvider.asNode(), eclipseModel, extension);
		});
	});
}
 
开发者ID:diffplug,项目名称:goomph,代码行数:26,代码来源:ProjectDepsPlugin.java

示例6: from

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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);
            }
        }
    }
}
 
开发者ID:Pushjet,项目名称:Pushjet-Android,代码行数:23,代码来源:DefaultMavenPublication.java

示例7: getProjectTypeDependencies

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
/**
 * Helper to get project dependent, optionally recursively.
 */
private static Set<Project> getProjectTypeDependencies(final Project project, boolean recursive) {
  //System.out.println("--------getProjectDependencies--------");
  Set<Project> result = new HashSet<Project>();
  //Set<ProjectDependency> set = new HashSet<ProjectDependency>();
  DomainObjectSet<ProjectDependency> directProjectTypeDependent = getDirectProjectTypeDependencies(project);
  //System.out.println("--directDependentProjects.size(): " + directDependentProjects.size());
  for (ProjectDependency projectTypeDependency : directProjectTypeDependent) {
    Project dependentProject = projectTypeDependency.getDependencyProject();
    //System.out.println("------project: " + dependentProject);
    if (dependentProject!=null) {
      result.add(dependentProject);
      if (recursive) {
        result.addAll(getProjectTypeDependencies(dependentProject, recursive));
      }
    }
  }
  return result;
}
 
开发者ID:r-murphy,项目名称:nw-gradle,代码行数:22,代码来源:DependenciesUtil.java

示例8: doesConfigurationDependOnProject

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:10,代码来源:TasksFromDependentProjects.java

示例9: resolveProjectDependencies

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
void resolveProjectDependencies(TaskDependencyResolveContext context, Set<ProjectDependency> projectDependencies) {
    for (ProjectDependency projectDependency : projectDependencies) {
        projectAccessListener.beforeResolvingProjectDependency((ProjectInternal) projectDependency.getDependencyProject());

        Task nextTask = projectDependency.getDependencyProject().getTasks().findByName(taskName);
        if (nextTask != null) {
            context.add(nextTask);
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:TasksFromProjectDependencies.java

示例10: from

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : dependency.getTargetConfiguration());
            if (dependency instanceof ProjectDependency) {
                addProjectDependency((ProjectDependency) dependency, confMapping);
            } else {
                addModuleDependency(dependency, confMapping);
            }
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:29,代码来源:DefaultIvyPublication.java

示例11: findAllExternalDependencies

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:20,代码来源:DefaultIdeDependencyResolver.java

示例12: getTargetConfiguration

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
private Configuration getTargetConfiguration(ProjectDependency dependency) {
    String targetConfiguration = dependency.getTargetConfiguration();
    if (targetConfiguration == null) {
        targetConfiguration = Dependency.DEFAULT_CONFIGURATION;
    }
    return dependency.getDependencyProject().getConfigurations().getByName(targetConfiguration);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:DefaultIdeDependencyResolver.java

示例13: contentEquals

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
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());
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:16,代码来源:DefaultProjectDependency.java

示例14: ensureConfigured

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
private void ensureConfigured(Configuration config) {
    for (Dependency dependency : config.getAllDependencies()) {
        if (dependency instanceof ProjectDependency) {
            ProjectDependency projectDependency = (ProjectDependency)dependency;
            project.evaluationDependsOn(projectDependency.getDependencyProject().getPath());
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:9,代码来源:AtlasDepTreeParser.java

示例15: configureOverlay

import org.gradle.api.artifacts.ProjectDependency; //导入依赖的package包/类
private void configureOverlay(WarOverlay overlay) {

        if (overlay.isDeferProvidedConfiguration()) {
            //Delay this to trick IntelliJ
            overlay.getWarTask().doFirst(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 {
            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());
            }
        }
    }
 
开发者ID:freefair,项目名称:gradle-plugins,代码行数:34,代码来源:WarOverlayPlugin.java


注:本文中的org.gradle.api.artifacts.ProjectDependency类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。