Java Code Examples for org.gradle.internal.service.ServiceRegistry#get()

The following examples show how to use org.gradle.internal.service.ServiceRegistry#get() . These examples are extracted from open source projects. 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
@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
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 3
@Mutate
public void createNativeBinaries(BinaryContainer binaries, NamedDomainObjectSet<NativeComponentSpec> nativeComponents,
                                 LanguageRegistry languages, NativeToolChainRegistryInternal toolChains,
                                 PlatformContainer platforms, BuildTypeContainer buildTypes, FlavorContainer flavors,
                                 ServiceRegistry serviceRegistry, @Path("buildDir") File buildDir) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    NativeDependencyResolver resolver = serviceRegistry.get(NativeDependencyResolver.class);
    Action<NativeBinarySpec> configureBinaryAction = new NativeBinarySpecInitializer(buildDir);
    Action<NativeBinarySpec> setToolsAction = new ToolSettingNativeBinaryInitializer(languages);
    Action<NativeBinarySpec> setDefaultTargetsAction = new ToolSettingNativeBinaryInitializer(languages);
    @SuppressWarnings("unchecked") Action<NativeBinarySpec> initAction = Actions.composite(configureBinaryAction, setToolsAction, new MarkBinariesBuildable());
    NativeBinariesFactory factory = new DefaultNativeBinariesFactory(instantiator, initAction, resolver);
    BinaryNamingSchemeBuilder namingSchemeBuilder = new DefaultBinaryNamingSchemeBuilder();
    Action<NativeComponentSpec> createBinariesAction =
            new NativeComponentSpecInitializer(factory, namingSchemeBuilder, toolChains, platforms, buildTypes, flavors);

    for (NativeComponentSpec component : nativeComponents) {
        createBinariesAction.execute(component);
        binaries.addAll(component.getBinaries());
    }
}
 
Example 4
public Project createProject(String name, File inputProjectDir) {
    File projectDir = prepareProjectDir(inputProjectDir);

    final File homeDir = new File(projectDir, "gradleHome");

    StartParameter startParameter = new StartParameter();
    startParameter.setGradleUserHomeDir(new File(projectDir, "userHome"));

    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(GLOBAL_SERVICES, startParameter, homeDir);
    GradleInternal gradle = new DefaultGradle(null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));

    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(),
            topLevelRegistry.get(FileResolver.class));
    ClassLoaderScope baseScope = gradle.getClassLoaderScope();
    ClassLoaderScope rootProjectScope = baseScope.createChild();
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, rootProjectScope, baseScope);

    gradle.setRootProject(project);
    gradle.setDefaultProject(project);

    return project;
}
 
Example 5
public Project createProject(String name, File inputProjectDir) {
    File projectDir = prepareProjectDir(inputProjectDir);

    final File homeDir = new File(projectDir, "gradleHome");

    StartParameter startParameter = new StartParameter();
    startParameter.setGradleUserHomeDir(new File(projectDir, "userHome"));

    ServiceRegistry topLevelRegistry = new TestBuildScopeServices(GLOBAL_SERVICES, startParameter, homeDir);
    GradleInternal gradle = new DefaultGradle(null, startParameter, topLevelRegistry.get(ServiceRegistryFactory.class));

    DefaultProjectDescriptor projectDescriptor = new DefaultProjectDescriptor(null, name, projectDir, new DefaultProjectDescriptorRegistry(),
            topLevelRegistry.get(FileResolver.class));
    ProjectInternal project = topLevelRegistry.get(IProjectFactory.class).createProject(projectDescriptor, null, gradle, gradle.getClassLoaderScope().createSibling());

    gradle.setRootProject(project);
    gradle.setDefaultProject(project);

    return project;
}
 
Example 6
@Mutate
public void registerJavaPlatformType(PlatformContainer platforms, ServiceRegistry serviceRegistry) {
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    platforms.registerFactory(JavaPlatform.class, new NamedDomainObjectFactory<JavaPlatform>() {
        public JavaPlatform create(String name) {
            return instantiator.newInstance(DefaultJavaPlatform.class, name);
        }
    });
}
 
Example 7
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 8
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 9
@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 10
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 11
/**
 * <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 12
@Model
JavaToolChainRegistry javaToolChain(ServiceRegistry serviceRegistry) {
    JavaToolChainInternal toolChain = serviceRegistry.get(JavaToolChainInternal.class);
    return new DefaultJavaToolChainRegistry(toolChain);
}
 
Example 13
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new JUnitTestClassProcessor(spec, serviceRegistry.get(IdGenerator.class), serviceRegistry.get(ActorFactory.class), new JULRedirector());
}
 
Example 14
@Model
PlatformContainer platforms(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultPlatformContainer.class, Platform.class, instantiator);
}
 
Example 15
@Model
FlavorContainer flavors(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultFlavorContainer.class, instantiator);
}
 
Example 16
@Model
ProjectPublicationRegistry projectPublicationRegistry(ServiceRegistry serviceRegistry) {
    return serviceRegistry.get(ProjectPublicationRegistry.class);
}
 
Example 17
private Runnable stopAllDaemons(DaemonParameters daemonParameters, ServiceRegistry loggingServices) {
    ServiceRegistry clientSharedServices = createGlobalClientServices();
    ServiceRegistry clientServices = clientSharedServices.get(DaemonClientFactory.class).createStopDaemonServices(loggingServices.get(OutputEventListener.class), daemonParameters);
    DaemonStopClient stopClient = clientServices.get(DaemonStopClient.class);
    return new StopDaemonAction(stopClient);
}
 
Example 18
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new TestNGTestClassProcessor(testReportDir, options, suiteFiles,
            serviceRegistry.get(IdGenerator.class), new JULRedirector());
}
 
Example 19
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new TestNGTestClassProcessor(testReportDir, options, suiteFiles,
            serviceRegistry.get(IdGenerator.class), new JULRedirector());
}
 
Example 20
public void init(Object target, ServiceRegistry services) {
    standardOutputCapture = services.get(StandardOutputCapture.class);
    setScriptTarget(target);
}