Search in sources :

Example 31 with Project

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

the class ProfileEventAdapter method afterExecute.

public void afterExecute(Task task, TaskState state) {
    long now = clock.getCurrentTime();
    Project project = task.getProject();
    ProjectProfile projectProfile = buildProfile.getProjectProfile(project.getPath());
    TaskExecution taskExecution = projectProfile.getTaskProfile(task.getPath());
    taskExecution.setFinish(now);
    taskExecution.completed(state);
}
Also used : Project(org.gradle.api.Project)

Example 32 with Project

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

the class ProfileEventAdapter method beforeExecute.

// TaskExecutionListener
public void beforeExecute(Task task) {
    long now = clock.getCurrentTime();
    Project project = task.getProject();
    ProjectProfile projectProfile = buildProfile.getProjectProfile(project.getPath());
    projectProfile.getTaskProfile(task.getPath()).setStart(now);
}
Also used : Project(org.gradle.api.Project)

Example 33 with Project

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

the class TaskConfiguration method configureInit.

public static void configureInit(final InitBuild init) {
    init.setGroup(GROUP);
    init.setDescription("Initializes a new Gradle build.");
    final Project project = init.getProject();
    init.onlyIf(new Spec<Task>() {

        @Override
        public boolean isSatisfiedBy(Task element) {
            Object skippedMsg = reasonToSkip(project);
            if (skippedMsg != null) {
                project.getLogger().warn((String) skippedMsg);
                return false;
            }
            return true;
        }
    });
    init.dependsOn(new Callable<String>() {

        @Override
        public String call() throws Exception {
            if (reasonToSkip(project) == null) {
                return "wrapper";
            } else {
                return null;
            }
        }
    });
    project.getGradle().getTaskGraph().whenReady(new Action<TaskExecutionGraph>() {

        @Override
        public void execute(TaskExecutionGraph taskGraph) {
            if (reasonToSkip(project) == null && taskGraph.hasTask(init)) {
                wrapperTaskOf(project).setDistributionType(wrapperDistributionTypeFor(init.getDsl()));
            }
        }
    });
}
Also used : Project(org.gradle.api.Project) Task(org.gradle.api.Task) TaskExecutionGraph(org.gradle.api.execution.TaskExecutionGraph)

Example 34 with Project

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

the class IdeaScalaConfigurer method configure.

public void configure() {
    rootProject.getGradle().addBuildListener(new BuildAdapter() {

        public void projectsEvaluated(Gradle gradle) {
            VersionNumber ideaTargetVersion = findIdeaTargetVersion();
            final boolean useScalaSdk = ideaTargetVersion == null || IDEA_VERSION_WHEN_SCALA_SDK_WAS_INTRODUCED.compareTo(ideaTargetVersion) <= 0;
            final Collection<Project> scalaProjects = findProjectsApplyingIdeaAndScalaPlugins();
            final Map<String, ProjectLibrary> scalaCompilerLibraries = Maps.newLinkedHashMap();
            rootProject.getTasks().getByName("ideaProject").doFirst(new Action<Task>() {

                @Override
                public void execute(Task task) {
                    if (scalaProjects.size() > 0) {
                        scalaCompilerLibraries.clear();
                        scalaCompilerLibraries.putAll(resolveScalaCompilerLibraries(scalaProjects, useScalaSdk));
                        declareUniqueProjectLibraries(Sets.newLinkedHashSet(scalaCompilerLibraries.values()));
                    }
                }
            });
            rootProject.configure(scalaProjects, new Action<Project>() {

                @Override
                public void execute(final Project project) {
                    project.getExtensions().getByType(IdeaModel.class).getModule().getIml().withXml(new Action<XmlProvider>() {

                        @Override
                        public void execute(XmlProvider xmlProvider) {
                            if (useScalaSdk) {
                                declareScalaSdk(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
                            } else {
                                declareScalaFacet(scalaCompilerLibraries.get(project.getPath()), xmlProvider.asNode());
                            }
                        }
                    });
                }
            });
        }
    });
}
Also used : Project(org.gradle.api.Project) Action(org.gradle.api.Action) Task(org.gradle.api.Task) IdeaModel(org.gradle.plugins.ide.idea.model.IdeaModel) XmlProvider(org.gradle.api.XmlProvider) FileCollection(org.gradle.api.file.FileCollection) Collection(java.util.Collection) BuildAdapter(org.gradle.BuildAdapter) Gradle(org.gradle.api.invocation.Gradle) Map(java.util.Map) VersionNumber(org.gradle.util.VersionNumber)

Example 35 with Project

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

the class EclipseModelBuilder method applyEclipsePlugin.

private void applyEclipsePlugin(Project root) {
    Set<Project> allProjects = root.getAllprojects();
    for (Project p : allProjects) {
        p.getPluginManager().apply(EclipsePlugin.class);
    }
    for (IncludedBuild includedBuild : root.getGradle().getIncludedBuilds()) {
        IncludedBuildInternal includedBuildInternal = (IncludedBuildInternal) includedBuild;
        applyEclipsePlugin(includedBuildInternal.getConfiguredBuild().getRootProject());
    }
}
Also used : DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) Project(org.gradle.api.Project) DefaultEclipseProject(org.gradle.plugins.ide.internal.tooling.eclipse.DefaultEclipseProject) IncludedBuildInternal(org.gradle.composite.internal.IncludedBuildInternal) IncludedBuild(org.gradle.api.initialization.IncludedBuild)

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