use of org.gradle.groovy.scripts.ScriptSource in project gradle by gradle.
the class DefaultObjectConfigurationAction method applyScript.
private void applyScript(Object script) {
URI scriptUri = resolver.resolveUri(script);
ScriptSource scriptSource = new UriScriptSource("script", scriptUri);
ClassLoaderScope classLoaderScopeChild = classLoaderScope.createChild("script-" + scriptUri.toString());
ScriptHandler scriptHandler = scriptHandlerFactory.create(scriptSource, classLoaderScopeChild);
ScriptPlugin configurer = configurerFactory.create(scriptSource, scriptHandler, classLoaderScopeChild, classLoaderScope, false);
for (Object target : targets) {
configurer.apply(target);
}
}
use of org.gradle.groovy.scripts.ScriptSource in project gradle by gradle.
the class DefaultExceptionAnalyser method transform.
public Throwable transform(Throwable exception) {
Throwable actualException = findDeepestRootException(exception);
if (actualException instanceof LocationAwareException) {
return actualException;
}
ScriptSource source = null;
Integer lineNumber = null;
// TODO: remove these special cases
if (actualException instanceof ScriptCompilationException) {
ScriptCompilationException scriptCompilationException = (ScriptCompilationException) actualException;
source = scriptCompilationException.getScriptSource();
lineNumber = scriptCompilationException.getLineNumber();
}
if (source == null) {
for (Throwable currentException = actualException; currentException != null; currentException = currentException.getCause()) {
for (StackTraceElement element : currentException.getStackTrace()) {
if (element.getLineNumber() >= 0 && scripts.containsKey(element.getFileName())) {
source = scripts.get(element.getFileName());
lineNumber = element.getLineNumber();
break;
}
}
}
}
return new LocationAwareException(actualException, source, lineNumber);
}
use of org.gradle.groovy.scripts.ScriptSource in project gradle by gradle.
the class ScriptEvaluatingSettingsProcessor method applySettingsScript.
private void applySettingsScript(SettingsLocation settingsLocation, final SettingsInternal settings) {
ScriptSource settingsScriptSource = settingsLocation.getSettingsScriptSource();
ClassLoaderScope settingsClassLoaderScope = settings.getClassLoaderScope();
ScriptHandler scriptHandler = scriptHandlerFactory.create(settingsScriptSource, settingsClassLoaderScope);
ScriptPlugin configurer = configurerFactory.create(settingsScriptSource, scriptHandler, settingsClassLoaderScope, settings.getRootClassLoaderScope(), true);
configurer.apply(settings);
}
use of org.gradle.groovy.scripts.ScriptSource in project gradle by gradle.
the class ScriptUsageLocationReporter method reportStackTraceElement.
private void reportStackTraceElement(StackTraceElement stackTraceElement, StringBuilder target) {
ScriptSource scriptSource = scripts.get(stackTraceElement.getFileName());
target.append(StringUtils.capitalize(scriptSource.getDisplayName()));
if (stackTraceElement.getLineNumber() > 0) {
target.append(": line ");
target.append(stackTraceElement.getLineNumber());
}
}
use of org.gradle.groovy.scripts.ScriptSource in project gradle by gradle.
the class ProjectFactory method createProject.
public DefaultProject createProject(ProjectDescriptor projectDescriptor, ProjectInternal parent, GradleInternal gradle, ClassLoaderScope selfClassLoaderScope, ClassLoaderScope baseClassLoaderScope) {
File buildFile = projectDescriptor.getBuildFile();
ScriptSource source = UriScriptSource.file("build file", buildFile);
DefaultProject project = instantiator.newInstance(DefaultProject.class, projectDescriptor.getName(), parent, projectDescriptor.getProjectDir(), source, gradle, gradle.getServiceRegistryFactory(), selfClassLoaderScope, baseClassLoaderScope);
if (parent != null) {
parent.addChildProject(project);
}
projectRegistry.addProject(project);
return project;
}
Aggregations