use of org.gradle.api.Project in project gradle by gradle.
the class ProjectReportTask method render.
private void render(final Project project, GraphRenderer renderer, boolean lastChild, final StyledTextOutput textOutput) {
renderer.visit(new Action<StyledTextOutput>() {
public void execute(StyledTextOutput styledTextOutput) {
styledTextOutput.text(StringUtils.capitalize(project.toString()));
if (GUtil.isTrue(project.getDescription())) {
textOutput.withStyle(Description).format(" - %s", project.getDescription());
}
}
}, lastChild);
renderer.startChildren();
List<Project> children = getChildren(project);
for (Project child : children) {
render(child, renderer, child == children.get(children.size() - 1), textOutput);
}
renderer.completeChildren();
}
use of org.gradle.api.Project in project gradle by gradle.
the class JavaPlugin method configureJavaDoc.
private void configureJavaDoc(JavaPluginConvention pluginConvention) {
Project project = pluginConvention.getProject();
SourceSet mainSourceSet = pluginConvention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME);
Javadoc javadoc = project.getTasks().create(JAVADOC_TASK_NAME, Javadoc.class);
javadoc.setDescription("Generates Javadoc API documentation for the main source code.");
javadoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP);
javadoc.setClasspath(mainSourceSet.getOutput().plus(mainSourceSet.getCompileClasspath()));
javadoc.setSource(mainSourceSet.getAllJava());
addDependsOnTaskInOtherProjects(javadoc, true, JAVADOC_TASK_NAME, COMPILE_CONFIGURATION_NAME);
}
use of org.gradle.api.Project in project gradle by gradle.
the class ProjectDependencyPublicationResolver method resolve.
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;
}
use of org.gradle.api.Project in project gradle by gradle.
the class DefaultProject method getTasksByName.
@Override
public Set<Task> getTasksByName(final String name, boolean recursive) {
if (isNullOrEmpty(name)) {
throw new InvalidUserDataException("Name is not specified!");
}
final Set<Task> foundTasks = new HashSet<Task>();
Action<Project> action = new Action<Project>() {
public void execute(Project project) {
// Don't force evaluation of rules here, let the task container do what it needs to
((ProjectInternal) project).evaluate();
Task task = project.getTasks().findByName(name);
if (task != null) {
foundTasks.add(task);
}
}
};
if (recursive) {
allprojects(action);
} else {
action.execute(this);
}
return foundTasks;
}
use of org.gradle.api.Project in project gradle by gradle.
the class DefaultCacheScopeMapping method getBaseDirectory.
public File getBaseDirectory(Object scope, String key, VersionStrategy versionStrategy) {
if (key.equalsIgnoreCase("projects") || key.equalsIgnoreCase("tasks") || !key.matches("\\p{Alpha}+[-//.\\w]*")) {
throw new IllegalArgumentException(String.format("Unsupported cache key '%s'.", key));
}
File cacheRootDir = getRootDirectory(scope);
String subDir = key;
if (scope instanceof Project) {
Project project = (Project) scope;
subDir = "projects/" + project.getPath().replace(':', '_') + "/" + key;
}
if (scope instanceof Task) {
Task task = (Task) scope;
subDir = "tasks/" + task.getPath().replace(':', '_') + "/" + key;
}
return getCacheDir(cacheRootDir, versionStrategy, subDir);
}
Aggregations