org.gradle.internal.service.ServiceRegistry Java Examples

The following examples show how to use org.gradle.internal.service.ServiceRegistry. 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: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Mutate
public void createBinaries(BinaryContainer binaries, PlatformContainer platforms, BinaryNamingSchemeBuilder namingSchemeBuilder,
                           NamedDomainObjectCollection<JvmLibrarySpec> libraries, @Path("buildDir") File buildDir, ServiceRegistry serviceRegistry, JavaToolChainRegistry toolChains) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);

    List<Action<? super JarBinarySpec>> actions = Lists.newArrayList();
    actions.add(new JarBinarySpecInitializer(buildDir));
    actions.add(new MarkBinariesBuildable());
    Action<JarBinarySpec> initAction = Actions.composite(actions);
    JarBinariesFactory factory = new DefaultJarBinariesFactory(instantiator, initAction);

    Action<JvmLibrarySpec> createBinariesAction =
            new JvmLibrarySpecInitializer(factory, namingSchemeBuilder, toolChains, platforms);

    for (JvmLibrarySpec jvmLibrary : libraries) {
        createBinariesAction.execute(jvmLibrary);
        binaries.addAll(jvmLibrary.getBinaries());
    }
}
 
Example #2
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private Runnable runBuildInSingleUseDaemon(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    //(SF) this is a workaround until this story is completed. I'm hardcoding setting the idle timeout to be max X mins.
    //this way we avoid potential runaway daemons that steal resources on linux and break builds on windows.
    //We might leave that in if we decide it's a good idea for an extra safety net.
    int maxTimeout = 2 * 60 * 1000;
    if (daemonParameters.getIdleTimeout() > maxTimeout) {
        daemonParameters.setIdleTimeout(maxTimeout);
    }
    //end of workaround.

    // Create a client that will not match any existing daemons, so it will always startup a new one
    ServiceRegistry clientSharedServices = createGlobalClientServices();
    ServiceRegistry clientServices = clientSharedServices.get(DaemonClientFactory.class).createSingleUseDaemonClientServices(loggingServices.get(OutputEventListener.class), daemonParameters, System.in);
    DaemonClient client = clientServices.get(DaemonClient.class);
    return daemonBuildAction(startParameter, daemonParameters, client);
}
 
Example #3
Source File: TestWorker.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void startReceivingTests(WorkerProcessContext workerProcessContext, ServiceRegistry testServices) {
    TestClassProcessor targetProcessor = factory.create(testServices);
    IdGenerator<Object> idGenerator = testServices.get(IdGenerator.class);

    targetProcessor = new WorkerTestClassProcessor(targetProcessor, idGenerator.generateId(),
            workerProcessContext.getDisplayName(), new TrueTimeProvider());
    ContextClassLoaderProxy<TestClassProcessor> proxy = new ContextClassLoaderProxy<TestClassProcessor>(
            TestClassProcessor.class, targetProcessor, workerProcessContext.getApplicationClassLoader());
    processor = proxy.getSource();

    ObjectConnection serverConnection = workerProcessContext.getServerConnection();
    serverConnection.useParameterSerializer(new TestEventSerializer());
    this.resultProcessor = serverConnection.addOutgoing(TestResultProcessor.class);
    serverConnection.addIncoming(RemoteTestClassProcessor.class, this);
    serverConnection.connect();
}
 
Example #4
Source File: DefaultScript.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public void init(final Object target, ServiceRegistry services) {
    super.init(target, services);
    this.__scriptServices = services;
    loggingManager = services.get(LoggingManager.class);
    Instantiator instantiator = services.get(Instantiator.class);
    FileLookup fileLookup = services.get(FileLookup.class);
    if (target instanceof FileOperations) {
        fileOperations = (FileOperations) target;
    } else if (getScriptSource().getResource().getFile() != null) {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(getScriptSource().getResource().getFile().getParentFile()), null, null, instantiator, fileLookup);
    } else {
        fileOperations = new DefaultFileOperations(fileLookup.getFileResolver(), null, null, instantiator, fileLookup);
    }

    processOperations = (ProcessOperations) fileOperations;
}
 
Example #5
Source File: BaseSettings.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public BaseSettings(ServiceRegistryFactory serviceRegistryFactory, GradleInternal gradle,
                    ClassLoaderScope classLoaderScope, File settingsDir, ScriptSource settingsScript,
                    StartParameter startParameter) {
    this.gradle = gradle;
    this.settingsDir = settingsDir;
    this.settingsScript = settingsScript;
    this.startParameter = startParameter;
    this.classLoaderScope = classLoaderScope;
    ServiceRegistry services = serviceRegistryFactory.createFor(this);
    this.plugins = services.get(PluginContainer.class);
    this.fileResolver = services.get(FileResolver.class);
    this.scriptPluginFactory = services.get(ScriptPluginFactory.class);
    this.scriptHandlerFactory = services.get(ScriptHandlerFactory.class);
    this.projectDescriptorRegistry = services.get(ProjectDescriptorRegistry.class);
    rootProjectDescriptor = createProjectDescriptor(null, settingsDir.getName(), settingsDir);
}
 
Example #6
Source File: CommandLineActionFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * <p>Converts the given command-line arguments to an {@link Action} which performs the action requested by the
 * command-line args.
 *
 * @param args The command-line arguments.
 * @return The action to execute.
 */
public Action<ExecutionListener> convert(List<String> args) {
    ServiceRegistry loggingServices = createLoggingServices();

    LoggingConfiguration loggingConfiguration = new LoggingConfiguration();

    return new ExceptionReportingAction(
            new WithLogging(loggingServices, args, loggingConfiguration,
                    new ParseAndBuildAction(loggingServices, args)),
            new BuildExceptionReporter(loggingServices.get(StyledTextOutputFactory.class), loggingConfiguration, clientMetaData()));
}
 
Example #7
Source File: ProjectScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ProjectScopeServices(final ServiceRegistry parent, final ProjectInternal project) {
    super(parent);
    this.project = project;
    register(new Action<ServiceRegistration>() {
        public void execute(ServiceRegistration registration) {
            registration.add(DomainObjectContext.class, project);
            parent.get(DependencyManagementServices.class).addDslServices(registration);
            for (PluginServiceRegistry pluginServiceRegistry : parent.getAll(PluginServiceRegistry.class)) {
                pluginServiceRegistry.registerProjectServices(registration);
            }
        }
    });
}
 
Example #8
Source File: DependencyInjectingInstantiator.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DependencyInjectingInstantiator(ServiceRegistry services) {
    this.services = services;
    onDeprecationWarning = new Action<String>() {
        public void execute(String message) {
            DeprecationLogger.nagUserWith(message);
        }
    };
}
 
Example #9
Source File: GradleScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
ServiceRegistryFactory createServiceRegistryFactory(final ServiceRegistry services) {
    return new ServiceRegistryFactory() {
        public ServiceRegistry createFor(Object domainObject) {
            if (domainObject instanceof ProjectInternal) {
                ProjectScopeServices projectScopeServices = new ProjectScopeServices(services, (ProjectInternal) domainObject);
                registries.add(projectScopeServices);
                return projectScopeServices;
            }
            throw new UnsupportedOperationException();
        }
    };
}
 
Example #10
Source File: BuildScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildScopeServices(final ServiceRegistry parent, final StartParameter startParameter) {
    super(parent);
    register(new Action<ServiceRegistration>() {
        public void execute(ServiceRegistration registration) {
            add(StartParameter.class, startParameter);
            for (PluginServiceRegistry pluginServiceRegistry : parent.getAll(PluginServiceRegistry.class)) {
                pluginServiceRegistry.registerBuildServices(registration);
            }
        }
    });
}
 
Example #11
Source File: BuildScopeServiceRegistryFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ServiceRegistry createFor(Object domainObject) {
    if (domainObject instanceof GradleInternal) {
        GradleScopeServices gradleServices = new GradleScopeServices(services, (GradleInternal) domainObject);
        registries.add(gradleServices);
        return gradleServices;
    }
    if (domainObject instanceof SettingsInternal) {
        SettingsScopeServices settingsServices = new SettingsScopeServices(services, (SettingsInternal) domainObject);
        registries.add(settingsServices);
        return settingsServices;
    }
    throw new IllegalArgumentException(String.format("Cannot create services for unknown domain object of type %s.",
            domainObject.getClass().getSimpleName()));
}
 
Example #12
Source File: DaemonServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DaemonServices(DaemonServerConfiguration configuration, ServiceRegistry loggingServices, LoggingManagerInternal loggingManager) {
    super(NativeServices.getInstance(), loggingServices);
    this.configuration = configuration;
    this.loggingManager = loggingManager;

    addProvider(new DaemonRegistryServices(configuration.getBaseDir()));
    addProvider(new GlobalScopeServices(true));
}
 
Example #13
Source File: DefaultGradleLauncherFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public DefaultGradleLauncherFactory(ServiceRegistry globalServices) {
    sharedServices = globalServices;
    tracker = new NestedBuildTracker();

    // Register default loggers 
    ListenerManager listenerManager = sharedServices.get(ListenerManager.class);
    buildProgressLogger = new BuildProgressLogger(sharedServices.get(ProgressLoggerFactory.class));
    listenerManager.addListener(new BuildProgressFilter(buildProgressLogger));
    listenerManager.useLogger(new DependencyResolutionLogger(sharedServices.get(ProgressLoggerFactory.class)));

    GradleLauncher.injectCustomFactory(this);
}
 
Example #14
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Action<? super ExecutionListener> runBuildInSingleUseDaemon(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    //(SF) this is a workaround until this story is completed. I'm hardcoding setting the idle timeout to be max X mins.
    //this way we avoid potential runaway daemons that steal resources on linux and break builds on windows.
    //We might leave that in if we decide it's a good idea for an extra safety net.
    int maxTimeout = 2 * 60 * 1000;
    if (daemonParameters.getIdleTimeout() > maxTimeout) {
        daemonParameters.setIdleTimeout(maxTimeout);
    }
    //end of workaround.

    // Create a client that will not match any existing daemons, so it will always startup a new one
    DaemonClientServices clientServices = new SingleUseDaemonClientServices(loggingServices, daemonParameters, System.in);
    DaemonClient client = clientServices.get(DaemonClient.class);
    return daemonBuildAction(startParameter, daemonParameters, client);
}
 
Example #15
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Action<? super ExecutionListener> runBuildInProcess(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    ServiceRegistry globalServices = ServiceRegistryBuilder.builder()
            .displayName("Global services")
            .parent(loggingServices)
            .parent(NativeServices.getInstance())
            .provider(new GlobalScopeServices(false))
            .build();
    InProcessBuildActionExecuter executer = new InProcessBuildActionExecuter(globalServices.get(GradleLauncherFactory.class));
    return daemonBuildAction(startParameter, daemonParameters, executer);
}
 
Example #16
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
BuildActionsFactory(ServiceRegistry loggingServices, DefaultCommandLineConverter commandLineConverter,
                    DaemonCommandLineConverter daemonConverter, LayoutCommandLineConverter layoutConverter,
                    SystemPropertiesCommandLineConverter propertiesConverter,
                    LayoutToPropertiesConverter layoutToPropertiesConverter,
                    PropertiesToStartParameterConverter propertiesToStartParameterConverter,
                    PropertiesToDaemonParametersConverter propertiesToDaemonParametersConverter) {
    this.loggingServices = loggingServices;
    this.commandLineConverter = commandLineConverter;
    this.daemonConverter = daemonConverter;
    this.layoutConverter = layoutConverter;
    this.propertiesConverter = propertiesConverter;
    this.layoutToPropertiesConverter = layoutToPropertiesConverter;
    this.propertiesToStartParameterConverter = propertiesToStartParameterConverter;
    this.propertiesToDaemonParametersConverter = propertiesToDaemonParametersConverter;
}
 
Example #17
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Runnable runBuildWithDaemon(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    // Create a client that will match based on the daemon startup parameters.
    ServiceRegistry clientSharedServices = createGlobalClientServices();
    ServiceRegistry clientServices = clientSharedServices.get(DaemonClientFactory.class).createBuildClientServices(loggingServices.get(OutputEventListener.class), daemonParameters, System.in);
    DaemonClient client = clientServices.get(DaemonClient.class);
    return daemonBuildAction(startParameter, daemonParameters, client);
}
 
Example #18
Source File: BuildScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public BuildScopeServices(final ServiceRegistry parent, final StartParameter startParameter) {
    super(parent);
    register(new Action<ServiceRegistration>() {
        public void execute(ServiceRegistration registration) {
            add(StartParameter.class, startParameter);
            for (PluginServiceRegistry pluginServiceRegistry : parent.getAll(PluginServiceRegistry.class)) {
                pluginServiceRegistry.registerBuildServices(registration);
            }
        }
    });
}
 
Example #19
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public void registerNativePlatformFactory(PlatformContainer platforms, ServiceRegistry serviceRegistry) {
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    NamedDomainObjectFactory<NativePlatform> nativePlatformFactory = new NamedDomainObjectFactory<NativePlatform>() {
        public NativePlatform create(String name) {
            return instantiator.newInstance(DefaultNativePlatform.class, name);
        }
    };

    //TODO freekh: remove cast/this comment when registerDefault exists on interface
    ((DefaultPlatformContainer) platforms).registerDefaultFactory(nativePlatformFactory);
    platforms.registerFactory(NativePlatform.class, nativePlatformFactory);
}
 
Example #20
Source File: CUnitPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private DefaultCUnitTestSuiteBinary createTestBinary(ServiceRegistry serviceRegistry, CUnitTestSuiteSpec cUnitTestSuite, NativeBinarySpec testedBinary) {
    BinaryNamingScheme namingScheme = new DefaultBinaryNamingSchemeBuilder(((NativeBinarySpecInternal) testedBinary).getNamingScheme())
            .withComponentName(cUnitTestSuite.getBaseName())
            .withTypeString("CUnitExe").build();

    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    NativeDependencyResolver resolver = serviceRegistry.get(NativeDependencyResolver.class);
    return instantiator.newInstance(DefaultCUnitTestSuiteBinary.class, cUnitTestSuite, testedBinary, namingScheme, resolver);
}
 
Example #21
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Model
Repositories repositories(ServiceRegistry serviceRegistry, FlavorContainer flavors, PlatformContainer platforms, BuildTypeContainer buildTypes) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    FileResolver fileResolver = serviceRegistry.get(FileResolver.class);
    Action<PrebuiltLibrary> initializer = new PrebuiltLibraryInitializer(instantiator, platforms.withType(NativePlatform.class), buildTypes, flavors);
    return new DefaultRepositories(instantiator, fileResolver, initializer);
}
 
Example #22
Source File: GccCompilerPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public static void addGccToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) {
    final FileResolver fileResolver = serviceRegistry.get(FileResolver.class);
    final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class);
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    final CompilerMetaDataProviderFactory metaDataProviderFactory = serviceRegistry.get(CompilerMetaDataProviderFactory.class);

    toolChainRegistry.registerFactory(Gcc.class, new NamedDomainObjectFactory<Gcc>() {
        public Gcc create(String name) {
            return instantiator.newInstance(GccToolChain.class, instantiator, name, OperatingSystem.current(), fileResolver, execActionFactory, metaDataProviderFactory);
        }
    });
    toolChainRegistry.registerDefaultToolChain(GccToolChain.DEFAULT_NAME, Gcc.class);
}
 
Example #23
Source File: ClangCompilerPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public static void addToolChain(NativeToolChainRegistryInternal toolChainRegistry, ServiceRegistry serviceRegistry) {
    final FileResolver fileResolver = serviceRegistry.get(FileResolver.class);
    final ExecActionFactory execActionFactory = serviceRegistry.get(ExecActionFactory.class);
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    final CompilerMetaDataProviderFactory metaDataProviderFactory = serviceRegistry.get(CompilerMetaDataProviderFactory.class);

    toolChainRegistry.registerFactory(Clang.class, new NamedDomainObjectFactory<Clang>() {
        public Clang create(String name) {
            return instantiator.newInstance(ClangToolChain.class, name, OperatingSystem.current(), fileResolver, execActionFactory, metaDataProviderFactory, instantiator);
        }
    });
    toolChainRegistry.registerDefaultToolChain(ClangToolChain.DEFAULT_NAME, Clang.class);
}
 
Example #24
Source File: ProjectScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ProjectScopeServices(final ServiceRegistry parent, final ProjectInternal project) {
    super(parent);
    this.project = project;
    register(new Action<ServiceRegistration>() {
        public void execute(ServiceRegistration registration) {
            registration.add(DomainObjectContext.class, project);
            parent.get(DependencyManagementServices.class).addDslServices(registration);
            for (PluginServiceRegistry pluginServiceRegistry : parent.getAll(PluginServiceRegistry.class)) {
                pluginServiceRegistry.registerProjectServices(registration);
            }
        }
    });
}
 
Example #25
Source File: NativeBinariesTestPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
TestSuiteContainer testSuites(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultTestSuiteContainer.class, instantiator);
}
 
Example #26
Source File: GradleScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleScopeServices(ServiceRegistry parent, GradleInternal gradle) {
    super(parent);
    add(GradleInternal.class, gradle);
    addProvider(new TaskExecutionServices());
}
 
Example #27
Source File: GradleScopeServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public GradleScopeServices(ServiceRegistry parent, GradleInternal gradle) {
    super(parent);
    add(GradleInternal.class, gradle);
    addProvider(new TaskExecutionServices());
}
 
Example #28
Source File: CommandLineActionFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
WithLogging(ServiceRegistry loggingServices, List<String> args, LoggingConfiguration loggingConfiguration, Action<ExecutionListener> action) {
    this.loggingServices = loggingServices;
    this.args = args;
    this.loggingConfiguration = loggingConfiguration;
    this.action = action;
}
 
Example #29
Source File: BuildScopeServiceRegistryFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public BuildScopeServiceRegistryFactory(ServiceRegistry services) {
    this.services = services;
}
 
Example #30
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private Action<? super ExecutionListener> runBuildWithDaemon(StartParameter startParameter, DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    // Create a client that will match based on the daemon startup parameters.
    DaemonClientServices clientServices = new DaemonClientServices(loggingServices, daemonParameters, System.in);
    DaemonClient client = clientServices.get(DaemonClient.class);
    return daemonBuildAction(startParameter, daemonParameters, client);
}