Search in sources :

Example 16 with Project

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

the class AbstractScalaCompile method createOrGetGlobalAnalysisMap.

@SuppressWarnings("unchecked")
protected Map<File, File> createOrGetGlobalAnalysisMap() {
    ExtraPropertiesExtension extraProperties = getProject().getRootProject().getExtensions().getExtraProperties();
    Map<File, File> analysisMap;
    if (extraProperties.has("scalaCompileAnalysisMap")) {
        analysisMap = (Map) extraProperties.get("scalaCompileAnalysisMap");
    } else {
        analysisMap = Maps.newHashMap();
        for (Project project : getProject().getRootProject().getAllprojects()) {
            for (AbstractScalaCompile task : project.getTasks().withType(AbstractScalaCompile.class)) {
                File publishedCode = task.getScalaCompileOptions().getIncrementalOptions().getPublishedCode();
                File analysisFile = task.getScalaCompileOptions().getIncrementalOptions().getAnalysisFile();
                analysisMap.put(publishedCode, analysisFile);
            }
        }
        extraProperties.set("scalaCompileAnalysisMap", Collections.unmodifiableMap(analysisMap));
    }
    return analysisMap;
}
Also used : Project(org.gradle.api.Project) ExtraPropertiesExtension(org.gradle.api.plugins.ExtraPropertiesExtension) File(java.io.File)

Example 17 with Project

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

the class GradleProjectBuilder method buildHierarchy.

private DefaultGradleProject<LaunchableGradleTask> buildHierarchy(Project project) {
    List<DefaultGradleProject<LaunchableGradleTask>> children = new ArrayList<DefaultGradleProject<LaunchableGradleTask>>();
    for (Project child : project.getChildProjects().values()) {
        children.add(buildHierarchy(child));
    }
    DefaultGradleProject<LaunchableGradleTask> gradleProject = new DefaultGradleProject<LaunchableGradleTask>().setProjectIdentifier(new DefaultProjectIdentifier(project.getRootDir(), project.getPath())).setName(project.getName()).setDescription(project.getDescription()).setBuildDirectory(project.getBuildDir()).setProjectDirectory(project.getProjectDir()).setChildren(children);
    gradleProject.getBuildScript().setSourceFile(project.getBuildFile());
    gradleProject.setTasks(tasks(gradleProject, (TaskContainerInternal) project.getTasks()));
    for (DefaultGradleProject child : children) {
        child.setParent(gradleProject);
    }
    return gradleProject;
}
Also used : LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) Project(org.gradle.api.Project) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) ArrayList(java.util.ArrayList) TaskContainerInternal(org.gradle.api.internal.tasks.TaskContainerInternal) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 18 with Project

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

the class IdeaModelBuilder method appendModule.

private void appendModule(Map<String, DefaultIdeaModule> modules, IdeaModule ideaModule, DefaultIdeaProject ideaProject, DefaultGradleProject rootGradleProject) {
    DefaultIdeaContentRoot contentRoot = new DefaultIdeaContentRoot().setRootDirectory(ideaModule.getContentRoot()).setSourceDirectories(srcDirs(ideaModule.getSourceDirs(), ideaModule.getGeneratedSourceDirs())).setTestDirectories(srcDirs(ideaModule.getTestSourceDirs(), ideaModule.getGeneratedSourceDirs())).setExcludeDirectories(ideaModule.getExcludeDirs());
    Project project = ideaModule.getProject();
    DefaultIdeaModule defaultIdeaModule = new DefaultIdeaModule().setName(ideaModule.getName()).setParent(ideaProject).setGradleProject(rootGradleProject.findByPath(ideaModule.getProject().getPath())).setContentRoots(Collections.singletonList(contentRoot)).setJdkName(ideaModule.getJdkName()).setCompilerOutput(new DefaultIdeaCompilerOutput().setInheritOutputDirs(ideaModule.getInheritOutputDirs() != null ? ideaModule.getInheritOutputDirs() : false).setOutputDir(ideaModule.getOutputDir()).setTestOutputDir(ideaModule.getTestOutputDir()));
    JavaPluginConvention javaPluginConvention = project.getConvention().findPlugin(JavaPluginConvention.class);
    if (javaPluginConvention != null) {
        final IdeaLanguageLevel ideaModuleLanguageLevel = ideaModule.getLanguageLevel();
        JavaVersion moduleSourceLanguageLevel = convertIdeaLanguageLevelToJavaVersion(ideaModuleLanguageLevel);
        JavaVersion moduleTargetBytecodeVersion = ideaModule.getTargetBytecodeVersion();
        defaultIdeaModule.setJavaLanguageSettings(new DefaultIdeaJavaLanguageSettings().setSourceLanguageLevel(moduleSourceLanguageLevel).setTargetBytecodeVersion(moduleTargetBytecodeVersion));
    }
    modules.put(ideaModule.getName(), defaultIdeaModule);
}
Also used : DefaultIdeaContentRoot(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaContentRoot) IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject) DefaultIdeaModule(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaModule) JavaPluginConvention(org.gradle.api.plugins.JavaPluginConvention) DefaultIdeaJavaLanguageSettings(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaJavaLanguageSettings) DefaultIdeaLanguageLevel(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaLanguageLevel) IdeaLanguageLevel(org.gradle.plugins.ide.idea.model.IdeaLanguageLevel) JavaVersion(org.gradle.api.JavaVersion) DefaultIdeaCompilerOutput(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaCompilerOutput)

Example 19 with Project

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

the class IdeaModelBuilder method buildAll.

@Override
public DefaultIdeaProject buildAll(String modelName, Project project) {
    Project root = project.getRootProject();
    applyIdeaPlugin(root);
    DefaultGradleProject<?> rootGradleProject = gradleProjectBuilder.buildAll(project);
    return build(root, rootGradleProject);
}
Also used : IdeaProject(org.gradle.plugins.ide.idea.model.IdeaProject) DefaultGradleProject(org.gradle.tooling.internal.gradle.DefaultGradleProject) Project(org.gradle.api.Project) DefaultIdeaProject(org.gradle.plugins.ide.internal.tooling.idea.DefaultIdeaProject)

Example 20 with Project

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

the class BuildInvocationsBuilder method findTasks.

private void findTasks(Project project, Map<String, LaunchableGradleTaskSelector> taskSelectors, Collection<String> visibleTasks) {
    for (Project child : project.getChildProjects().values()) {
        findTasks(child, taskSelectors, visibleTasks);
    }
    for (Task task : taskLister.listProjectTasks(project)) {
        // this way, for each task selector, its description will be the one from the selected task with the 'smallest' path
        if (!taskSelectors.containsKey(task.getName())) {
            LaunchableGradleTaskSelector taskSelector = new LaunchableGradleTaskSelector().setDescription(task.getDescription()).setPath(task.getPath());
            taskSelectors.put(task.getName(), taskSelector);
        } else {
            LaunchableGradleTaskSelector taskSelector = taskSelectors.get(task.getName());
            if (hasPathWithLowerOrdering(task, taskSelector)) {
                taskSelector.setDescription(task.getDescription()).setPath(task.getPath());
            }
        }
        // visible tasks are specified as those that have a non-empty group
        if (PublicTaskSpecification.INSTANCE.isSatisfiedBy(task)) {
            visibleTasks.add(task.getName());
        }
    }
}
Also used : Project(org.gradle.api.Project) ToolingModelBuilderSupport.buildFromTask(org.gradle.plugins.ide.internal.tooling.ToolingModelBuilderSupport.buildFromTask) LaunchableGradleTask(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTask) Task(org.gradle.api.Task) LaunchableGradleTaskSelector(org.gradle.plugins.ide.internal.tooling.model.LaunchableGradleTaskSelector)

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