Search in sources :

Example 96 with Project

use of org.gradle.api.Project in project gradle by gradle.

the class GradleReleaseNotesPlugin method generateReleaseNotes.

private void generateReleaseNotes(Project project, ProjectLayout layout, TaskContainer tasks, GradleDocumentationExtension extension) {
    TaskProvider<RenderMarkdown> releaseNotesMarkdown = tasks.register("releaseNotesMarkdown", RenderMarkdown.class, task -> {
        task.setGroup("release notes");
        task.setDescription("Generate release notes HTML page from Markdown.");
        task.getInputEncoding().convention(Charset.defaultCharset().name());
        task.getOutputEncoding().convention(Charset.defaultCharset().name());
        task.getMarkdownFile().convention(extension.getReleaseNotes().getMarkdownFile());
        task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/raw.html"));
    });
    TaskProvider<DecorateReleaseNotes> releaseNotesPostProcess = tasks.register("releaseNotes", DecorateReleaseNotes.class, task -> {
        task.setGroup("release notes");
        task.setDescription("Transforms generated release notes.");
        task.getHtmlFile().convention(releaseNotesMarkdown.flatMap(RenderMarkdown::getDestinationFile));
        task.getBaseCssFile().convention(extension.getReleaseNotes().getBaseCssFile());
        task.getReleaseNotesCssFile().convention(extension.getReleaseNotes().getReleaseNotesCssFile());
        task.getReleaseNotesJavascriptFile().convention(extension.getReleaseNotes().getReleaseNotesJsFile());
        task.getJquery().from(extension.getReleaseNotes().getJquery());
        ModuleIdentityExtension moduleIdentity = project.getExtensions().getByType(ModuleIdentityExtension.class);
        MapProperty<String, String> replacementTokens = task.getReplacementTokens();
        replacementTokens.put("version", moduleIdentity.getVersion().map(GradleVersion::getVersion));
        replacementTokens.put("baseVersion", moduleIdentity.getVersion().map(v -> v.getBaseVersion().getVersion()));
        task.getDestinationFile().convention(extension.getStagingRoot().file("release-notes/release-notes.html"));
    });
    Configuration jquery = project.getConfigurations().create("jquery", conf -> {
        conf.setDescription("JQuery dependencies embedded by release notes.");
    });
    extension.releaseNotes(releaseNotes -> {
        releaseNotes.getMarkdownFile().convention(extension.getSourceRoot().file("release/notes.md"));
        releaseNotes.getRenderedDocumentation().convention(releaseNotesPostProcess.flatMap(DecorateReleaseNotes::getDestinationFile));
        releaseNotes.getBaseCssFile().convention(extension.getSourceRoot().file("css/base.css"));
        releaseNotes.getReleaseNotesCssFile().convention(extension.getSourceRoot().file("css/release-notes.css"));
        releaseNotes.getReleaseNotesJsFile().convention(extension.getSourceRoot().file("release/content/script.js"));
        releaseNotes.getJquery().from(jquery);
    });
}
Also used : Configuration(org.gradle.api.artifacts.Configuration) ProjectLayout(org.gradle.api.file.ProjectLayout) TaskContainer(org.gradle.api.tasks.TaskContainer) Charset(java.nio.charset.Charset) Project(org.gradle.api.Project) MapProperty(org.gradle.api.provider.MapProperty) TaskProvider(org.gradle.api.tasks.TaskProvider) ModuleIdentityExtension(gradlebuild.identity.extension.ModuleIdentityExtension) Plugin(org.gradle.api.Plugin) GradleVersion(org.gradle.util.GradleVersion) Configuration(org.gradle.api.artifacts.Configuration) ModuleIdentityExtension(gradlebuild.identity.extension.ModuleIdentityExtension)

Example 97 with Project

use of org.gradle.api.Project in project gradle by gradle.

the class SelectedTaskExecutionAction method bindAllReferencesOfProject.

private void bindAllReferencesOfProject(TaskExecutionGraph graph) {
    Set<Project> seen = Sets.newHashSet();
    for (Task task : graph.getAllTasks()) {
        if (seen.add(task.getProject())) {
            ProjectInternal projectInternal = (ProjectInternal) task.getProject();
            projectInternal.bindAllModelRules();
        }
    }
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 98 with Project

use of org.gradle.api.Project in project gradle by gradle.

the class ProjectPropertySettingBuildLoader method load.

@Override
public void load(SettingsInternal settings, GradleInternal gradle) {
    buildLoader.load(settings, gradle);
    Project rootProject = gradle.getRootProject();
    setProjectProperties(rootProject, new CachingPropertyApplicator(rootProject.getClass()));
}
Also used : Project(org.gradle.api.Project)

Example 99 with Project

use of org.gradle.api.Project in project gradle by gradle.

the class ProjectFinderByTaskPath method findProject.

public ProjectInternal findProject(String projectPath, ProjectInternal startFrom) {
    if (projectPath.equals(Project.PATH_SEPARATOR)) {
        return startFrom.getRootProject();
    }
    Project current = startFrom;
    if (projectPath.startsWith(Project.PATH_SEPARATOR)) {
        current = current.getRootProject();
        projectPath = projectPath.substring(1);
    }
    for (String pattern : projectPath.split(Project.PATH_SEPARATOR)) {
        Map<String, Project> children = current.getChildProjects();
        NameMatcher matcher = new NameMatcher();
        Project child = matcher.find(pattern, children);
        if (child != null) {
            current = child;
            continue;
        }
        throw new ProjectLookupException(matcher.formatErrorMessage("project", current));
    }
    return (ProjectInternal) current;
}
Also used : Project(org.gradle.api.Project) NameMatcher(org.gradle.util.internal.NameMatcher) ProjectInternal(org.gradle.api.internal.project.ProjectInternal)

Example 100 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>() {

        @Override
        public void execute(Project project) {
            // Don't force evaluation of rules here, let the task container do what it needs to
            ((ProjectInternal) project).getOwner().ensureTasksDiscovered();
            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.util.internal.ClosureBackedAction) Action(org.gradle.api.Action) DefaultObjectConfigurationAction(org.gradle.api.internal.plugins.DefaultObjectConfigurationAction) InvalidUserDataException(org.gradle.api.InvalidUserDataException) HashSet(java.util.HashSet)

Aggregations

Project (org.gradle.api.Project)269 File (java.io.File)98 Task (org.gradle.api.Task)71 Plugin (org.gradle.api.Plugin)69 Configuration (org.gradle.api.artifacts.Configuration)53 List (java.util.List)40 ArrayList (java.util.ArrayList)39 SourceSet (org.gradle.api.tasks.SourceSet)38 TaskProvider (org.gradle.api.tasks.TaskProvider)38 IOException (java.io.IOException)35 Map (java.util.Map)35 Action (org.gradle.api.Action)34 Set (java.util.Set)32 JavaPlugin (org.gradle.api.plugins.JavaPlugin)31 FileCollection (org.gradle.api.file.FileCollection)30 Provider (org.gradle.api.provider.Provider)27 HashMap (java.util.HashMap)26 Collectors (java.util.stream.Collectors)26 ObjectFactory (org.gradle.api.model.ObjectFactory)25 Collections (java.util.Collections)24