Java Code Examples for org.gradle.api.NamedDomainObjectFactory

The following examples show how to use org.gradle.api.NamedDomainObjectFactory. 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 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 OperatingSystem operatingSystem = serviceRegistry.get(OperatingSystem.class);
    final VisualStudioLocator visualStudioLocator = serviceRegistry.get(VisualStudioLocator.class);
    final WindowsSdkLocator windowsSdkLocator = serviceRegistry.get(WindowsSdkLocator.class);

    toolChainRegistry.registerFactory(VisualCpp.class, new NamedDomainObjectFactory<VisualCpp>() {
        public VisualCpp create(String name) {
            return instantiator.newInstance(VisualCppToolChain.class, name, operatingSystem, fileResolver, execActionFactory, visualStudioLocator, windowsSdkLocator, instantiator);
        }
    });
    toolChainRegistry.registerDefaultToolChain(VisualCppToolChain.DEFAULT_NAME, VisualCpp.class);
}
 
Example 2
@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 OperatingSystem operatingSystem = serviceRegistry.get(OperatingSystem.class);
    final VisualStudioLocator visualStudioLocator = serviceRegistry.get(VisualStudioLocator.class);
    final WindowsSdkLocator windowsSdkLocator = serviceRegistry.get(WindowsSdkLocator.class);

    toolChainRegistry.registerFactory(VisualCpp.class, new NamedDomainObjectFactory<VisualCpp>() {
        public VisualCpp create(String name) {
            return instantiator.newInstance(VisualCppToolChain.class, name, operatingSystem, fileResolver, execActionFactory, visualStudioLocator, windowsSdkLocator, instantiator);
        }
    });
    toolChainRegistry.registerDefaultToolChain(VisualCppToolChain.DEFAULT_NAME, VisualCpp.class);
}
 
Example 3
private <T extends ComponentSpec, I extends BaseComponentSpec> void doRegister(final ModelType<T> type, final ModelType<I> implementation, final ProjectSourceSet projectSourceSet, ComponentSpecContainer componentSpecs, final ProjectIdentifier projectIdentifier) {
    componentSpecs.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            FunctionalSourceSet componentSourceSet = projectSourceSet.maybeCreate(name);
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name);

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseComponentSpec.create(implementation.getConcreteClass(), id, componentSourceSet, instantiator);

            return created;
        }
    });
}
 
Example 4
private <T extends BinarySpec, U extends BaseBinarySpec> void doRegister(BinaryContainer binaries, ModelType<T> type, final ModelType<U> implementation) {
    binaries.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            BinaryNamingScheme binaryNamingScheme = new DefaultBinaryNamingSchemeBuilder()
                    .withComponentName(name)
                    .build();

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseBinarySpec.create(implementation.getConcreteClass(), binaryNamingScheme, instantiator);

            return created;
        }
    });
}
 
Example 5
@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 6
@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 7
private DefaultRepositories(final Instantiator instantiator, final FileResolver fileResolver, final Action<PrebuiltLibrary> binaryFactory) {
    super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer());
    registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() {
        public PrebuiltLibraries create(String name) {
            return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, fileResolver, binaryFactory);
        }
    });
}
 
Example 8
private <T extends ComponentSpec, I extends BaseComponentSpec> void doRegister(final ModelType<T> type, final ModelType<I> implementation, final ProjectSourceSet projectSourceSet, ComponentSpecContainer componentSpecs, final ProjectIdentifier projectIdentifier) {
    componentSpecs.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            FunctionalSourceSet componentSourceSet = projectSourceSet.maybeCreate(name);
            ComponentSpecIdentifier id = new DefaultComponentSpecIdentifier(projectIdentifier.getPath(), name);

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseComponentSpec.create(implementation.getConcreteClass(), id, componentSourceSet, instantiator);

            return created;
        }
    });
}
 
Example 9
private <T extends BinarySpec, U extends BaseBinarySpec> void doRegister(BinaryContainer binaries, ModelType<T> type, final ModelType<U> implementation) {
    binaries.registerFactory(type.getConcreteClass(), new NamedDomainObjectFactory<T>() {
        public T create(String name) {
            BinaryNamingScheme binaryNamingScheme = new DefaultBinaryNamingSchemeBuilder()
                    .withComponentName(name)
                    .build();

            // safe because we implicitly know that U extends V, but can't express this in the type system
            @SuppressWarnings("unchecked")
            T created = (T) BaseBinarySpec.create(implementation.getConcreteClass(), binaryNamingScheme, instantiator);

            return created;
        }
    });
}
 
Example 10
@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 11
@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 12
private DefaultRepositories(final Instantiator instantiator, final FileResolver fileResolver, final Action<PrebuiltLibrary> binaryFactory) {
    super(ArtifactRepository.class, instantiator, new ArtifactRepositoryNamer());
    registerFactory(PrebuiltLibraries.class, new NamedDomainObjectFactory<PrebuiltLibraries>() {
        public PrebuiltLibraries create(String name) {
            return instantiator.newInstance(DefaultPrebuiltLibraries.class, name, instantiator, fileResolver, binaryFactory);
        }
    });
}
 
Example 13
@Override
public <U extends T> void registerFactory(Class<U> type, NamedDomainObjectFactory<? extends U> factory) {
    checkCanRegister(type);
    super.registerFactory(type, factory);
}
 
Example 14
@Override
public <U extends T> void registerFactory(Class<U> type, NamedDomainObjectFactory<? extends U> factory) {
    checkCanRegister(type);
    super.registerFactory(type, factory);
}
 
Example 15
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container (must implement {@link Named})
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, NamedDomainObjectFactory<T> factory) {
    this(type, instantiator, Named.Namer.forType(type), factory);
}
 
Example 16
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param namer The naming strategy to use
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, Namer<? super T> namer, NamedDomainObjectFactory<T> factory) {
    super(type, instantiator, namer);
    this.factory = factory;
}
 
Example 17
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container (must implement {@link Named})
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, NamedDomainObjectFactory<T> factory) {
    this(type, instantiator, Named.Namer.forType(type), factory);
}
 
Example 18
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param namer The naming strategy to use
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, Namer<? super T> namer, NamedDomainObjectFactory<T> factory) {
    super(type, instantiator, namer);
    this.factory = factory;
}
 
Example 19
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container (must implement {@link Named})
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, NamedDomainObjectFactory<T> factory) {
    this(type, instantiator, Named.Namer.forType(type), factory);
}
 
Example 20
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param namer The naming strategy to use
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, Namer<? super T> namer, NamedDomainObjectFactory<T> factory) {
    super(type, instantiator, namer);
    this.factory = factory;
}
 
Example 21
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container (must implement {@link Named})
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, NamedDomainObjectFactory<T> factory) {
    this(type, instantiator, Named.Namer.forType(type), factory);
}
 
Example 22
/**
 * <p>Creates a container that instantiates using the given factory.<p>
 *
 * @param type The concrete type of element in the container
 * @param instantiator The instantiator to use to create any other collections based on this one
 * @param namer The naming strategy to use
 * @param factory The factory responsible for creating new instances on demand
 */
public FactoryNamedDomainObjectContainer(Class<T> type, Instantiator instantiator, Namer<? super T> namer, NamedDomainObjectFactory<T> factory) {
    super(type, instantiator, namer);
    this.factory = factory;
}