Java Code Examples for org.gradle.platform.base.ModelInstantiationException

The following examples show how to use org.gradle.platform.base.ModelInstantiationException. 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
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
private BaseBinarySpec(BinaryInfo info) {
    if (info == null) {
        throw new ModelInstantiationException("Direct instantiation of a BaseBinarySpec is not permitted. Use a BinaryTypeBuilder instead.");
    }
    this.typeName = info.typeName;
    this.namingScheme = info.namingScheme;
}
 
Example 3
public static <T extends BaseComponentSpec> T create(Class<T> type, ComponentSpecIdentifier identifier, FunctionalSourceSet mainSourceSet, Instantiator instantiator) {
    if (type.equals(BaseComponentSpec.class)) {
        throw new ModelInstantiationException("Cannot create instance of abstract class BaseComponentSpec.");
    }
    nextComponentInfo.set(new ComponentInfo(identifier, type.getSimpleName(), mainSourceSet));
    try {
        try {
            return instantiator.newInstance(type);
        } catch (ObjectInstantiationException e) {
            throw new ModelInstantiationException(String.format("Could not create component of type %s", type.getSimpleName()), e.getCause());
        }
    } finally {
        nextComponentInfo.set(null);
    }
}
 
Example 4
private BaseComponentSpec(ComponentInfo info) {
    if (info == null) {
        throw new ModelInstantiationException("Direct instantiation of a BaseComponentSpec is not permitted. Use a ComponentTypeBuilder instead.");
    }

    this.identifier = info.componentIdentifier;
    this.typeName = info.typeName;
    this.mainSourceSet = info.sourceSets;
    sourceSets.addMainSources(this.mainSourceSet);
}
 
Example 5
public static <T extends LanguageSourceSet> T create(Class<? extends LanguageSourceSet> publicType, Class<T> implementationType, ComponentSpecIdentifier componentId, SourceDirectorySetFactory sourceDirectorySetFactory) {
    NEXT_SOURCE_SET_INFO.set(new SourceSetInfo(componentId, publicType, sourceDirectorySetFactory));
    try {
        try {
            return DirectInstantiator.INSTANCE.newInstance(implementationType);
        } catch (ObjectInstantiationException e) {
            throw new ModelInstantiationException(String.format("Could not create LanguageSourceSet of type %s", publicType.getSimpleName()), e.getCause());
        }
    } finally {
        NEXT_SOURCE_SET_INFO.set(null);
    }
}
 
Example 6
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 7
private BaseBinarySpec(BinaryInfo info) {
    if (info == null) {
        throw new ModelInstantiationException("Direct instantiation of a BaseBinarySpec is not permitted. Use a BinaryTypeBuilder instead.");
    }
    this.typeName = info.typeName;
    this.namingScheme = info.namingScheme;
}
 
Example 8
public static <T extends BaseComponentSpec> T create(Class<T> type, ComponentSpecIdentifier identifier, FunctionalSourceSet mainSourceSet, Instantiator instantiator) {
    if (type.equals(BaseComponentSpec.class)) {
        throw new ModelInstantiationException("Cannot create instance of abstract class BaseComponentSpec.");
    }
    nextComponentInfo.set(new ComponentInfo(identifier, type.getSimpleName(), mainSourceSet));
    try {
        try {
            return instantiator.newInstance(type);
        } catch (ObjectInstantiationException e) {
            throw new ModelInstantiationException(String.format("Could not create component of type %s", type.getSimpleName()), e.getCause());
        }
    } finally {
        nextComponentInfo.set(null);
    }
}
 
Example 9
private BaseComponentSpec(ComponentInfo info) {
    if (info == null) {
        throw new ModelInstantiationException("Direct instantiation of a BaseComponentSpec is not permitted. Use a ComponentTypeBuilder instead.");
    }

    this.identifier = info.componentIdentifier;
    this.typeName = info.typeName;
    this.mainSourceSet = info.sourceSets;
    sourceSets.addMainSources(this.mainSourceSet);
}
 
Example 10
private static SourceSetInfo validate(SourceSetInfo info) {
    if (info == null) {
        throw new ModelInstantiationException("Direct instantiation of a BaseLanguageSourceSet is not permitted. Use a @ComponentType rule instead.");
    }
    return info;
}