Search in sources :

Example 21 with Project

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

the class GradleBuildBuilder method convert.

private DefaultGradleBuild convert(Gradle gradle) {
    DefaultGradleBuild model = new DefaultGradleBuild();
    Map<Project, BasicGradleProject> convertedProjects = new LinkedHashMap<Project, BasicGradleProject>();
    Project rootProject = gradle.getRootProject();
    BasicGradleProject convertedRootProject = convert(rootProject, convertedProjects);
    model.setRootProject(convertedRootProject);
    for (Project project : rootProject.getAllprojects()) {
        model.addProject(convertedProjects.get(project));
    }
    for (IncludedBuild includedBuild : gradle.getIncludedBuilds()) {
        Gradle includedGradle = ((IncludedBuildInternal) includedBuild).getConfiguredBuild();
        DefaultGradleBuild convertedIncludedBuild = convert(includedGradle);
        model.addIncludedBuild(convertedIncludedBuild);
    }
    return model;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) IncludedBuildInternal(org.gradle.composite.internal.IncludedBuildInternal) DefaultGradleBuild(org.gradle.tooling.internal.gradle.DefaultGradleBuild) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) Gradle(org.gradle.api.invocation.Gradle) LinkedHashMap(java.util.LinkedHashMap) IncludedBuild(org.gradle.api.initialization.IncludedBuild)

Example 22 with Project

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

the class GradleBuildBuilder method convert.

private BasicGradleProject convert(Project project, Map<Project, BasicGradleProject> convertedProjects) {
    DefaultProjectIdentifier id = new DefaultProjectIdentifier(project.getRootDir(), project.getPath());
    BasicGradleProject converted = new BasicGradleProject().setName(project.getName()).setProjectIdentifier(id);
    converted.setProjectDirectory(project.getProjectDir());
    if (project.getParent() != null) {
        converted.setParent(convertedProjects.get(project.getParent()));
    }
    convertedProjects.put(project, converted);
    for (Project child : project.getChildProjects().values()) {
        converted.addChild(convert(child, convertedProjects));
    }
    return converted;
}
Also used : Project(org.gradle.api.Project) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) BasicGradleProject(org.gradle.tooling.internal.gradle.BasicGradleProject) DefaultProjectIdentifier(org.gradle.tooling.internal.gradle.DefaultProjectIdentifier)

Example 23 with Project

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

the class IdePlugin method postProcess.

/**
     * Executes the provided Action after all projects have been evaluated.
     * Action will only be added once per provided key. Any subsequent calls for the same key will be ignored.
     * This permits the plugin to be applied in multiple subprojects, with the postprocess action executed once only.
     */
protected void postProcess(String key, final Action<? super Gradle> action) {
    Project rootProject = project.getRootProject();
    ExtraPropertiesExtension rootExtraProperties = rootProject.getExtensions().getByType(ExtraPropertiesExtension.class);
    String extraPropertyName = "org.gradle." + key + ".postprocess.applied";
    if (!rootExtraProperties.has(extraPropertyName)) {
        project.getGradle().addBuildListener(new BuildAdapter() {

            @Override
            public void projectsEvaluated(Gradle gradle) {
                action.execute(gradle);
            }
        });
        rootExtraProperties.set(extraPropertyName, true);
    }
}
Also used : Project(org.gradle.api.Project) ExtraPropertiesExtension(org.gradle.api.plugins.ExtraPropertiesExtension) BuildAdapter(org.gradle.BuildAdapter) Gradle(org.gradle.api.invocation.Gradle)

Example 24 with Project

use of org.gradle.api.Project in project spring-boot by spring-projects.

the class RepackageTask method repackage.

@TaskAction
public void repackage() {
    Project project = getProject();
    SpringBootPluginExtension extension = project.getExtensions().getByType(SpringBootPluginExtension.class);
    ProjectLibraries libraries = getLibraries();
    project.getTasks().withType(Jar.class, new RepackageAction(extension, libraries));
}
Also used : Project(org.gradle.api.Project) SpringBootPluginExtension(org.springframework.boot.gradle.SpringBootPluginExtension) TaskAction(org.gradle.api.tasks.TaskAction)

Example 25 with Project

use of org.gradle.api.Project in project spring-boot by spring-projects.

the class FindMainClassTask method setMainClassNameProperty.

@TaskAction
public void setMainClassNameProperty() {
    Project project = getProject();
    if (!project.hasProperty("mainClassName") || project.property("mainClassName") == null) {
        String mainClass = findMainClass();
        if (project.hasProperty("mainClassName")) {
            project.setProperty("mainClassName", mainClass);
        } else {
            ExtraPropertiesExtension extraProperties = (ExtraPropertiesExtension) project.getExtensions().getByName("ext");
            extraProperties.set("mainClassName", mainClass);
        }
    }
}
Also used : Project(org.gradle.api.Project) ExtraPropertiesExtension(org.gradle.api.plugins.ExtraPropertiesExtension) TaskAction(org.gradle.api.tasks.TaskAction)

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