Search in sources :

Example 11 with Project

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();
}
Also used : Project(org.gradle.api.Project) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput)

Example 12 with Project

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);
}
Also used : Project(org.gradle.api.Project) SourceSet(org.gradle.api.tasks.SourceSet) Javadoc(org.gradle.api.tasks.javadoc.Javadoc)

Example 13 with Project

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;
}
Also used : ModuleVersionIdentifier(org.gradle.api.artifacts.ModuleVersionIdentifier) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier) Project(org.gradle.api.Project) DefaultModuleVersionIdentifier(org.gradle.api.internal.artifacts.DefaultModuleVersionIdentifier) ProjectInternal(org.gradle.api.internal.project.ProjectInternal) PublishingExtension(org.gradle.api.publish.PublishingExtension)

Example 14 with Project

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;
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) ClosureBackedAction(org.gradle.api.internal.ClosureBackedAction) Action(org.gradle.api.Action) DefaultObjectConfigurationAction(org.gradle.api.internal.plugins.DefaultObjectConfigurationAction) InvalidUserDataException(org.gradle.api.InvalidUserDataException) HashSet(java.util.HashSet)

Example 15 with Project

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);
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) File(java.io.File)

Aggregations

Project (org.gradle.api.Project)93 File (java.io.File)20 Task (org.gradle.api.Task)12 Action (org.gradle.api.Action)11 Configuration (org.gradle.api.artifacts.Configuration)11 Set (java.util.Set)8 Callable (java.util.concurrent.Callable)8 TaskAction (org.gradle.api.tasks.TaskAction)8 DefaultGradleProject (org.gradle.tooling.internal.gradle.DefaultGradleProject)8 Provider (org.gradle.api.provider.Provider)7 ArrayList (java.util.ArrayList)6 AttributeContainer (org.gradle.api.attributes.AttributeContainer)6 Usage (org.gradle.api.attributes.Usage)6 Gradle (org.gradle.api.invocation.Gradle)6 StyledTextOutput (org.gradle.internal.logging.text.StyledTextOutput)6 DefaultUsageContext (org.gradle.language.cpp.internal.DefaultUsageContext)6 NativeVariantIdentity (org.gradle.language.cpp.internal.NativeVariantIdentity)6 OperatingSystemFamily (org.gradle.nativeplatform.OperatingSystemFamily)6 FileCollection (org.gradle.api.file.FileCollection)4 IdeaProject (org.gradle.plugins.ide.idea.model.IdeaProject)4