org.gradle.tooling.provider.model.ToolingModelBuilderRegistry Java Examples

The following examples show how to use org.gradle.tooling.provider.model.ToolingModelBuilderRegistry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlobalScope.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public GlobalScope(
        @NonNull Project project,
        @NonNull AndroidBuilder androidBuilder,
        @NonNull String projectBaseName,
        @NonNull AndroidConfig extension,
        @NonNull SdkHandler sdkHandler,
        @NonNull ToolingModelBuilderRegistry toolingRegistry) {
    this.project = project;
    this.androidBuilder = androidBuilder;
    this.projectBaseName = projectBaseName;
    this.extension = extension;
    this.sdkHandler = sdkHandler;
    this.toolingRegistry = toolingRegistry;
    intermediatesDir = new File(getBuildDir(), FD_INTERMEDIATES);
    generatedDir = new File(getBuildDir(), FD_GENERATED);
    reportsDir = new File(getBuildDir(), FD_REPORTS);
    outputsDir = new File(getBuildDir(), FD_OUTPUTS);
}
 
Example #2
Source File: TaskManager.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
public TaskManager(
        Project project,
        AndroidBuilder androidBuilder,
        AndroidConfig extension,
        SdkHandler sdkHandler,
        DependencyManager dependencyManager,
        ToolingModelBuilderRegistry toolingRegistry) {
    this.project = project;
    this.androidBuilder = androidBuilder;
    this.sdkHandler = sdkHandler;
    this.extension = extension;
    this.toolingRegistry = toolingRegistry;
    this.dependencyManager = dependencyManager;
    logger = Logging.getLogger(this.getClass());

    globalScope = new GlobalScope(
            project,
            androidBuilder,
            checkNotNull((String) project.getProperties().get("archivesBaseName")),
            extension,
            sdkHandler,
            toolingRegistry);
}
 
Example #3
Source File: AppPlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected TaskManager createTaskManager(
        Project project,
        AndroidBuilder androidBuilder,
        AndroidConfig extension,
        SdkHandler sdkHandler,
        DependencyManager dependencyManager,
        ToolingModelBuilderRegistry toolingRegistry) {
    return new ApplicationTaskManager(
            project,
            androidBuilder,
            extension,
            sdkHandler,
            dependencyManager,
            toolingRegistry);
}
 
Example #4
Source File: BuildModelAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildActionResult run(BuildController buildController) {
    GradleInternal gradle = buildController.getGradle();

    if (runTasks) {
        buildController.run();
    } else {
        buildController.configure();
        // Currently need to force everything to be configured
        gradle.getServices().get(ProjectConfigurer.class).configureHierarchy(gradle.getRootProject());
    }

    ToolingModelBuilderRegistry builderRegistry = getToolingModelBuilderRegistry(gradle);
    ToolingModelBuilder builder;
    try {
        builder = builderRegistry.getBuilder(modelName);
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException)new InternalUnsupportedModelException().initCause(e);
    }

    Object result;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        result = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelName, gradle.getDefaultProject(), true);
    } else {
        result = builder.buildAll(modelName, gradle.getDefaultProject());
    }

    PayloadSerializer payloadSerializer = gradle.getServices().get(PayloadSerializer.class);
    return new BuildActionResult(payloadSerializer.serialize(result), null);
}
 
Example #5
Source File: ToolingRegistrationAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);
    ProjectPublicationRegistry projectPublicationRegistry = project.getServices().get(ProjectPublicationRegistry.class);

    GradleProjectBuilder gradleProjectBuilder  = new GradleProjectBuilder();
    IdeaModelBuilder ideaModelBuilder = new IdeaModelBuilder(gradleProjectBuilder);
    modelBuilderRegistry.register(new EclipseModelBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(ideaModelBuilder);
    modelBuilderRegistry.register(gradleProjectBuilder);
    modelBuilderRegistry.register(new GradleBuildBuilder());
    modelBuilderRegistry.register(new BasicIdeaModelBuilder(ideaModelBuilder));
    modelBuilderRegistry.register(new BuildInvocationsBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(new PublicationsBuilder(projectPublicationRegistry));
}
 
Example #6
Source File: DefaultBuildController.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
    ToolingModelBuilderRegistry modelBuilderRegistry;
    ProjectInternal project;
    boolean isImplicitProject;
    if (target == null) {
        project = gradle.getDefaultProject();
        isImplicitProject = true;
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity gradleProject = (GradleProjectIdentity) target;
        project = gradle.getRootProject().project(gradleProject.getPath());
        isImplicitProject = false;
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
    modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);

    ToolingModelBuilder builder;
    try {
        builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName());
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e);
    }
    Object model;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        model = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelIdentifier.getName(), project, isImplicitProject);
    } else {
        model = builder.buildAll(modelIdentifier.getName(), project);
    }
    return new ProviderBuildResult<Object>(model);
}
 
Example #7
Source File: ToolingRegistrationAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);
    ProjectPublicationRegistry projectPublicationRegistry = project.getServices().get(ProjectPublicationRegistry.class);
    ProjectTaskLister taskLister = project.getServices().get(ProjectTaskLister.class);

    GradleProjectBuilder gradleProjectBuilder  = new GradleProjectBuilder();
    IdeaModelBuilder ideaModelBuilder = new IdeaModelBuilder(gradleProjectBuilder);
    modelBuilderRegistry.register(new EclipseModelBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(ideaModelBuilder);
    modelBuilderRegistry.register(gradleProjectBuilder);
    modelBuilderRegistry.register(new GradleBuildBuilder());
    modelBuilderRegistry.register(new BasicIdeaModelBuilder(ideaModelBuilder));
    modelBuilderRegistry.register(new BuildInvocationsBuilder(taskLister));
    modelBuilderRegistry.register(new PublicationsBuilder(projectPublicationRegistry));
}
 
Example #8
Source File: BuildModelAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildActionResult run(BuildController buildController) {
    GradleInternal gradle = buildController.getGradle();

    if (runTasks) {
        buildController.run();
    } else {
        buildController.configure();
        // Currently need to force everything to be configured
        gradle.getServices().get(ProjectConfigurer.class).configureHierarchy(gradle.getRootProject());
    }

    ToolingModelBuilderRegistry builderRegistry = getToolingModelBuilderRegistry(gradle);
    ToolingModelBuilder builder;
    try {
        builder = builderRegistry.getBuilder(modelName);
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException)new InternalUnsupportedModelException().initCause(e);
    }

    Object result;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        result = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelName, gradle.getDefaultProject(), true);
    } else {
        result = builder.buildAll(modelName, gradle.getDefaultProject());
    }

    PayloadSerializer payloadSerializer = gradle.getServices().get(PayloadSerializer.class);
    return new BuildActionResult(payloadSerializer.serialize(result), null);
}
 
Example #9
Source File: DefaultBuildController.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
    BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class);
    if (cancellationToken.isCancellationRequested()) {
        throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
    }
    ToolingModelBuilderRegistry modelBuilderRegistry;
    ProjectInternal project;
    boolean isImplicitProject;
    if (target == null) {
        project = gradle.getDefaultProject();
        isImplicitProject = true;
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity gradleProject = (GradleProjectIdentity) target;
        project = gradle.getRootProject().project(gradleProject.getPath());
        isImplicitProject = false;
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
    modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);

    ToolingModelBuilder builder;
    try {
        builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName());
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e);
    }
    Object model;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        model = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelIdentifier.getName(), project, isImplicitProject);
    } else {
        model = builder.buildAll(modelIdentifier.getName(), project);
    }
    return new ProviderBuildResult<Object>(model);
}
 
Example #10
Source File: ApplicationTaskManager.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public ApplicationTaskManager(
        Project project,
        AndroidBuilder androidBuilder,
        AndroidConfig extension,
        SdkHandler sdkHandler,
        DependencyManager dependencyManager,
        ToolingModelBuilderRegistry toolingRegistry) {
    super(project, androidBuilder, extension, sdkHandler, dependencyManager, toolingRegistry);
}
 
Example #11
Source File: LibraryTaskManager.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
public LibraryTaskManager(
        Project project,
        AndroidBuilder androidBuilder,
        AndroidConfig extension,
        SdkHandler sdkHandler,
        DependencyManager dependencyManager,
        ToolingModelBuilderRegistry toolingRegistry) {
    super(project, androidBuilder, extension, sdkHandler, dependencyManager, toolingRegistry);
}
 
Example #12
Source File: BasePlugin.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
protected abstract TaskManager createTaskManager(
Project project,
AndroidBuilder androidBuilder,
AndroidConfig extension,
SdkHandler sdkHandler,
DependencyManager dependencyManager,
ToolingModelBuilderRegistry toolingRegistry);
 
Example #13
Source File: DefaultBuildController.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
    BuildCancellationToken cancellationToken = gradle.getServices().get(BuildCancellationToken.class);
    if (cancellationToken.isCancellationRequested()) {
        throw new BuildCancelledException(String.format("Could not build '%s' model. Build cancelled.", modelIdentifier.getName()));
    }
    ToolingModelBuilderRegistry modelBuilderRegistry;
    ProjectInternal project;
    boolean isImplicitProject;
    if (target == null) {
        project = gradle.getDefaultProject();
        isImplicitProject = true;
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity gradleProject = (GradleProjectIdentity) target;
        project = gradle.getRootProject().project(gradleProject.getPath());
        isImplicitProject = false;
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
    modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);

    ToolingModelBuilder builder;
    try {
        builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName());
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e);
    }
    Object model;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        model = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelIdentifier.getName(), project, isImplicitProject);
    } else {
        model = builder.buildAll(modelIdentifier.getName(), project);
    }
    return new ProviderBuildResult<Object>(model);
}
 
Example #14
Source File: ToolingRegistrationAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);
    ProjectPublicationRegistry projectPublicationRegistry = project.getServices().get(ProjectPublicationRegistry.class);
    ProjectTaskLister taskLister = project.getServices().get(ProjectTaskLister.class);

    GradleProjectBuilder gradleProjectBuilder  = new GradleProjectBuilder();
    IdeaModelBuilder ideaModelBuilder = new IdeaModelBuilder(gradleProjectBuilder);
    modelBuilderRegistry.register(new EclipseModelBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(ideaModelBuilder);
    modelBuilderRegistry.register(gradleProjectBuilder);
    modelBuilderRegistry.register(new GradleBuildBuilder());
    modelBuilderRegistry.register(new BasicIdeaModelBuilder(ideaModelBuilder));
    modelBuilderRegistry.register(new BuildInvocationsBuilder(taskLister));
    modelBuilderRegistry.register(new PublicationsBuilder(projectPublicationRegistry));
}
 
Example #15
Source File: DefaultBuildController.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildResult<?> getModel(Object target, ModelIdentifier modelIdentifier) throws BuildExceptionVersion1, InternalUnsupportedModelException {
    ToolingModelBuilderRegistry modelBuilderRegistry;
    ProjectInternal project;
    boolean isImplicitProject;
    if (target == null) {
        project = gradle.getDefaultProject();
        isImplicitProject = true;
    } else if (target instanceof GradleProjectIdentity) {
        GradleProjectIdentity gradleProject = (GradleProjectIdentity) target;
        project = gradle.getRootProject().project(gradleProject.getPath());
        isImplicitProject = false;
    } else {
        throw new IllegalArgumentException("Don't know how to build models for " + target);
    }
    modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);

    ToolingModelBuilder builder;
    try {
        builder = modelBuilderRegistry.getBuilder(modelIdentifier.getName());
    } catch (UnknownModelException e) {
        throw (InternalUnsupportedModelException) (new InternalUnsupportedModelException()).initCause(e);
    }
    Object model;
    if (builder instanceof ProjectSensitiveToolingModelBuilder) {
        model = ((ProjectSensitiveToolingModelBuilder) builder).buildAll(modelIdentifier.getName(), project, isImplicitProject);
    } else {
        model = builder.buildAll(modelIdentifier.getName(), project);
    }
    return new ProviderBuildResult<Object>(model);
}
 
Example #16
Source File: ToolingRegistrationAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void execute(ProjectInternal project) {
    ToolingModelBuilderRegistry modelBuilderRegistry = project.getServices().get(ToolingModelBuilderRegistry.class);
    ProjectPublicationRegistry projectPublicationRegistry = project.getServices().get(ProjectPublicationRegistry.class);

    GradleProjectBuilder gradleProjectBuilder  = new GradleProjectBuilder();
    IdeaModelBuilder ideaModelBuilder = new IdeaModelBuilder(gradleProjectBuilder);
    modelBuilderRegistry.register(new EclipseModelBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(ideaModelBuilder);
    modelBuilderRegistry.register(gradleProjectBuilder);
    modelBuilderRegistry.register(new GradleBuildBuilder());
    modelBuilderRegistry.register(new BasicIdeaModelBuilder(ideaModelBuilder));
    modelBuilderRegistry.register(new BuildInvocationsBuilder(gradleProjectBuilder));
    modelBuilderRegistry.register(new PublicationsBuilder(projectPublicationRegistry));
}
 
Example #17
Source File: ProjectScopeServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected ToolingModelBuilderRegistry createToolingModelRegistry() {
    return new DefaultToolingModelBuilderRegistry();
}
 
Example #18
Source File: ThorntailArquillianPlugin.java    From thorntail with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new instance of {@code PackagePlugin}, which is initialized with the Gradle tooling model builder registry.
 *
 * @param registry the Gradle project's {@code ToolingModelBuilderRegistry}.
 */
@SuppressWarnings("UnstableApiUsage")
@Inject
public ThorntailArquillianPlugin(ToolingModelBuilderRegistry registry) {
    super(registry);
}
 
Example #19
Source File: ProjectScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected ToolingModelBuilderRegistry createToolingModelRegistry() {
    return new DefaultToolingModelBuilderRegistry();
}
 
Example #20
Source File: BuildModelAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ToolingModelBuilderRegistry getToolingModelBuilderRegistry(GradleInternal gradle) {
    return gradle.getDefaultProject().getServices().get(ToolingModelBuilderRegistry.class);
}
 
Example #21
Source File: ToolingRegistrationAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(ProjectInternal project) {
    project.getServices().get(ToolingModelBuilderRegistry.class).register(new ProjectOutcomesModelBuilder());
}
 
Example #22
Source File: ToolingRegistrationAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(ProjectInternal project) {
    project.getServices().get(ToolingModelBuilderRegistry.class).register(new ProjectOutcomesModelBuilder());
}
 
Example #23
Source File: AndroidExtension.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public AndroidExtension(Project project, ToolingModelBuilderRegistry registry) {
    this.project = project;

    this.extraModelInfo = new ExtraModelInfo(new ProjectOptions(project), project.getLogger());

    this.signingConfig = project.getExtensions().create("signingConfig", SigningConfig.class, "signing");
    this.packagingOptions = project.getExtensions().create("packagingOptions", PackagingOptions.class);
    this.dexOptions = project.getExtensions().create("dexOptions", DexOptions.class, extraModelInfo);

    try {
        this.buildCache = FileCache.getInstanceWithMultiProcessLocking(new File(AndroidLocation.getFolder(), "build-cache"));
    } catch (AndroidLocation.AndroidLocationException e) {
        throw new RuntimeException(e);
    }

    LoggerWrapper loggerWrapper = new LoggerWrapper(project.getLogger());

    this.sdkHandler = new SdkHandler(project, loggerWrapper);
    this.androidBuilder = new AndroidBuilder(
            project == project.getRootProject() ? project.getName() : project.getPath(),
            "JavaFX Mobile",
            new GradleProcessExecutor(project),
            new GradleJavaProcessExecutor(project),
            extraModelInfo,
            loggerWrapper,
            false);

    this.androidTaskRegistry = new AndroidTaskRegistry();
    this.taskFactory = new TaskContainerAdaptor(project.getTasks());

    installDirectory = new File(project.getBuildDir(), "javafxports/android");
    project.getLogger().info("Android install directory: " + installDirectory);

    temporaryDirectory = new File(project.getBuildDir(), "javafxports/tmp/android");
    project.getLogger().info("Android temporary output directory: " + temporaryDirectory);

    resourcesDirectory = new File(temporaryDirectory, "resources");
    resourcesDirectory.mkdirs();
    project.getLogger().info("Resources directory: " + resourcesDirectory);

    multidexOutputDirectory = new File(temporaryDirectory, "multi-dex");
    multidexOutputDirectory.mkdirs();
    project.getLogger().info("Multi-dex output directory: " + multidexOutputDirectory);

    dexOutputDirectory = new File(temporaryDirectory, "dex");
    dexOutputDirectory.mkdirs();
    project.getLogger().info("Dex output directory: " + dexOutputDirectory);
}
 
Example #24
Source File: CustomPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Need to use a {@link ToolingModelBuilderRegistry} to register the custom tooling model, so inject this into
 * the constructor.
 */
@Inject
public CustomPlugin(ToolingModelBuilderRegistry registry) {
    this.registry = registry;
}
 
Example #25
Source File: BuildModelAction.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ToolingModelBuilderRegistry getToolingModelBuilderRegistry(GradleInternal gradle) {
    return gradle.getDefaultProject().getServices().get(ToolingModelBuilderRegistry.class);
}
 
Example #26
Source File: BuildModelAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private ToolingModelBuilderRegistry getToolingModelBuilderRegistry(GradleInternal gradle) {
    return gradle.getDefaultProject().getServices().get(ToolingModelBuilderRegistry.class);
}
 
Example #27
Source File: ToolingRegistrationAction.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void execute(ProjectInternal project) {
    project.getServices().get(ToolingModelBuilderRegistry.class).register(new ProjectOutcomesModelBuilder());
}
 
Example #28
Source File: ProjectScopeServices.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected ToolingModelBuilderRegistry createToolingModelRegistry() {
    return new DefaultToolingModelBuilderRegistry();
}
 
Example #29
Source File: CustomPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * Need to use a {@link ToolingModelBuilderRegistry} to register the custom tooling model, so inject this into
 * the constructor.
 */
@Inject
public CustomPlugin(ToolingModelBuilderRegistry registry) {
    this.registry = registry;
}
 
Example #30
Source File: NbAndroidToolingPlugin.java    From NBANDROID-V2 with Apache License 2.0 4 votes vote down vote up
@Inject
public NbAndroidToolingPlugin(ToolingModelBuilderRegistry registry) {
    this.registry = registry;
}