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

The following examples show how to use org.gradle.internal.service.ServiceRegistry#get() . 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: ProjectBuilderImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 2
Source File: ProjectBuilderImpl.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 3
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 4
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@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 5
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 6
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
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 8
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 9
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 10
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 11
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 12
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new TestNGTestClassProcessor(testReportDir, options, suiteFiles,
            serviceRegistry.get(IdGenerator.class), new JULRedirector());
}
 
Example 13
Source File: BuildActionsFactory.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
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 14
Source File: PublishingPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
ProjectPublicationRegistry projectPublicationRegistry(ServiceRegistry serviceRegistry) {
    return serviceRegistry.get(ProjectPublicationRegistry.class);
}
 
Example 15
Source File: TestNGTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new TestNGTestClassProcessor(testReportDir, options, suiteFiles,
            serviceRegistry.get(IdGenerator.class), new JULRedirector());
}
 
Example 16
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
FlavorContainer flavors(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultFlavorContainer.class, instantiator);
}
 
Example 17
Source File: ComponentModelBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
PlatformContainer platforms(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultPlatformContainer.class, Platform.class, instantiator);
}
 
Example 18
Source File: JUnitTestFramework.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public TestClassProcessor create(ServiceRegistry serviceRegistry) {
    return new JUnitTestClassProcessor(spec, serviceRegistry.get(IdGenerator.class), serviceRegistry.get(ActorFactory.class), new JULRedirector());
}
 
Example 19
Source File: BasicScript.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void init(Object target, ServiceRegistry services) {
    standardOutputCapture = services.get(StandardOutputCapture.class);
    setScriptTarget(target);
}
 
Example 20
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
JavaToolChainRegistry javaToolChain(ServiceRegistry serviceRegistry) {
    JavaToolChainInternal toolChain = serviceRegistry.get(JavaToolChainInternal.class);
    return new DefaultJavaToolChainRegistry(toolChain);
}