Java Code Examples for org.gradle.internal.reflect.Instantiator#newInstance()

The following examples show how to use org.gradle.internal.reflect.Instantiator#newInstance() . 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: BaseBinarySpec.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T extends BaseBinarySpec> T create(Class<T> type, BinaryNamingScheme namingScheme, Instantiator instantiator) {
    if (type.equals(BaseBinarySpec.class)) {
        throw new ModelInstantiationException("Cannot create instance of abstract class BaseBinarySpec.");
    }
    nextBinaryInfo.set(new BinaryInfo(namingScheme, type.getSimpleName()));
    try {
        try {
            return instantiator.newInstance(type);
        } catch (ObjectInstantiationException e) {
            throw new ModelInstantiationException(String.format("Could not create binary of type %s", type.getSimpleName()), e.getCause());
        }
    } finally {
        nextBinaryInfo.set(null);
    }
}
 
Example 2
Source File: JvmComponentPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Mutate
public void createJavaPlatforms(PlatformContainer platforms, ServiceRegistry serviceRegistry) {
    final Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    //Create default platforms available for Java
    for (JavaVersion javaVersion: JavaVersion.values()) {
        DefaultJavaPlatform javaPlatform = instantiator.newInstance(DefaultJavaPlatform.class, javaVersion);
        platforms.add(javaPlatform);
    }
}
 
Example 3
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 4
Source File: VisualStudioPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Model
public static VisualStudioExtensionInternal visualStudio(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    ProjectLocator projectLocator = serviceRegistry.get(ProjectLocator.class);
    FileResolver fileResolver = serviceRegistry.get(FileResolver.class);

    return instantiator.newInstance(DefaultVisualStudioExtension.class, instantiator, projectLocator, fileResolver);
}
 
Example 5
Source File: CompareGradleBuilds.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public CompareGradleBuilds() {
    FileResolver fileResolver = getFileResolver();
    Instantiator instantiator = getInstantiator();
    sourceBuild = instantiator.newInstance(DefaultGradleBuildInvocationSpec.class, fileResolver, getProject().getRootDir());
    sourceBuild.setTasks(DEFAULT_TASKS);
    targetBuild = instantiator.newInstance(DefaultGradleBuildInvocationSpec.class, fileResolver, getProject().getRootDir());
    targetBuild.setTasks(DEFAULT_TASKS);

    // Never up to date
    getOutputs().upToDateWhen(new Spec<Task>() {
        public boolean isSatisfiedBy(Task element) {
            return false;
        }
    });
}
 
Example 6
Source File: Copy.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
protected CopySpecInternal createRootSpec() {
    Instantiator instantiator = getInstantiator();
    FileResolver fileResolver = getFileResolver();

    return instantiator.newInstance(DestinationRootCopySpec.class, fileResolver, super.createRootSpec());
}
 
Example 7
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 8
Source File: DefaultDependencyManagementServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
DependencyHandler createDependencyHandler(Instantiator instantiator, ConfigurationContainerInternal configurationContainer, DependencyFactory dependencyFactory,
                                          ProjectFinder projectFinder, ComponentMetadataHandler componentMetadataHandler, ComponentModuleMetadataHandler componentModuleMetadataHandler, ArtifactResolutionQueryFactory resolutionQueryFactory) {
    return instantiator.newInstance(DefaultDependencyHandler.class,
            configurationContainer,
            dependencyFactory,
            projectFinder,
            componentMetadataHandler,
            componentModuleMetadataHandler,
            resolutionQueryFactory);
}
 
Example 9
Source File: NativeComponentModelPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Model
BuildTypeContainer buildTypes(ServiceRegistry serviceRegistry) {
    Instantiator instantiator = serviceRegistry.get(Instantiator.class);
    return instantiator.newInstance(DefaultBuildTypeContainer.class, instantiator);
}
 
Example 10
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 11
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> NamedDomainObjectContainer<T> container(Class<T> type, Closure factoryClosure) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer(), factoryClosure);
}
 
Example 12
Source File: AbstractClassGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> T newInstance(Class<T> type, Object... parameters) {
    Instantiator instantiator = new DirectInstantiator();
    return instantiator.newInstance(generate(type), parameters);
}
 
Example 13
Source File: DefaultDependencyManagementServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
RepositoryHandler createRepositoryHandler(Instantiator instantiator, BaseRepositoryFactory baseRepositoryFactory) {
    return instantiator.newInstance(DefaultRepositoryHandler.class, baseRepositoryFactory, instantiator);
}
 
Example 14
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> NamedDomainObjectContainer<T> container(Class<T> type) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer());
}
 
Example 15
Source File: GenerateBuildDashboard.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Inject
public GenerateBuildDashboard(Instantiator instantiator) {
    reports = instantiator.newInstance(DefaultBuildDashboardReports.class, this);
    reports.getHtml().setEnabled(true);
}
 
Example 16
Source File: DefaultDependencyManagementServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public RepositoryHandler createRepositoryHandler() {
    Instantiator instantiator = services.get(Instantiator.class);
    BaseRepositoryFactory baseRepositoryFactory = services.get(BaseRepositoryFactory.class);
    return instantiator.newInstance(DefaultRepositoryHandler.class, baseRepositoryFactory, instantiator);
}
 
Example 17
Source File: AbstractClassGenerator.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> T newInstance(Class<T> type, Object... parameters) {
    Instantiator instantiator = new DirectInstantiator();
    return instantiator.newInstance(generate(type), parameters);
}
 
Example 18
Source File: DefaultDependencyManagementServices.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
DefaultComponentMetadataHandler createComponentMetadataHandler(Instantiator instantiator) {
    return instantiator.newInstance(DefaultComponentMetadataHandler.class, instantiator);
}
 
Example 19
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> NamedDomainObjectContainer<T> container(Class<T> type) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer());
}
 
Example 20
Source File: AbstractProject.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public <T> NamedDomainObjectContainer<T> container(Class<T> type, NamedDomainObjectFactory<T> factory) {
    Instantiator instantiator = getServices().get(Instantiator.class);
    return instantiator.newInstance(FactoryNamedDomainObjectContainer.class, type, instantiator, new DynamicPropertyNamer(), factory);
}