Java Code Examples for org.gradle.internal.reflect.ObjectInstantiationException#getCause()

The following examples show how to use org.gradle.internal.reflect.ObjectInstantiationException#getCause() . 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
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 3
public <T extends Plugin<?>> T loadPlugin(Class<T> pluginClass) {
    if (!Plugin.class.isAssignableFrom(pluginClass)) {
        throw new InvalidUserDataException(String.format(
                "Cannot create plugin of type '%s' as it does not implement the Plugin interface.",
                pluginClass.getSimpleName()));
    }
    try {
        return instantiator.newInstance(pluginClass);
    } catch (ObjectInstantiationException e) {
        throw new PluginInstantiationException(String.format("Could not create plugin of type '%s'.",
                pluginClass.getSimpleName()), e.getCause());
    }
}
 
Example 4
public <T extends Plugin> T loadPlugin(Class<T> pluginClass) {
    if (!Plugin.class.isAssignableFrom(pluginClass)) {
        throw new InvalidUserDataException(String.format(
                "Cannot create plugin of type '%s' as it does not implement the Plugin interface.",
                pluginClass.getSimpleName()));
    }
    try {
        return instantiator.newInstance(pluginClass);
    } catch (ObjectInstantiationException e) {
        throw new PluginInstantiationException(String.format("Could not create plugin of type '%s'.",
                pluginClass.getSimpleName()), e.getCause());
    }
}
 
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
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 8
public <T extends Plugin<?>> T loadPlugin(Class<T> pluginClass) {
    if (!Plugin.class.isAssignableFrom(pluginClass)) {
        throw new InvalidUserDataException(String.format(
                "Cannot create plugin of type '%s' as it does not implement the Plugin interface.",
                pluginClass.getSimpleName()));
    }
    try {
        return instantiator.newInstance(pluginClass);
    } catch (ObjectInstantiationException e) {
        throw new PluginInstantiationException(String.format("Could not create plugin of type '%s'.",
                pluginClass.getSimpleName()), e.getCause());
    }
}
 
Example 9
public <T extends Plugin> T loadPlugin(Class<T> pluginClass) {
    if (!Plugin.class.isAssignableFrom(pluginClass)) {
        throw new InvalidUserDataException(String.format(
                "Cannot create plugin of type '%s' as it does not implement the Plugin interface.",
                pluginClass.getSimpleName()));
    }
    try {
        return instantiator.newInstance(pluginClass);
    } catch (ObjectInstantiationException e) {
        throw new PluginInstantiationException(String.format("Could not create plugin of type '%s'.",
                pluginClass.getSimpleName()), e.getCause());
    }
}