Package org.gradle.groovy.scripts

Examples of org.gradle.groovy.scripts.ScriptSource


    public DefaultExceptionAnalyser(ListenerManager listenerManager) {
        listenerManager.addListener(this);
    }

    public void beforeScript(Script script) {
        ScriptSource source = script.getScriptSource();
        scripts.put(source.getFileName(), source);
    }
View Full Code Here


        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;
View Full Code Here

    private ScriptSource scriptSource() {
        return scriptSource(scriptText);
    }

    private ScriptSource scriptSource(final String scriptText) {
        final ScriptSource source = context.mock(ScriptSource.class, scriptText);
        context.checking(new Expectations(){{
            Resource resource = context.mock(Resource.class, scriptText + "resource");

            allowing(source).getClassName();
            will(returnValue(scriptClassName));
View Full Code Here

        evaluateScript(script);
    }

    @Test
    public void testCompileScriptToDirWithPackageDeclaration() throws Exception {
        final ScriptSource scriptSource = scriptSource("package org.gradle.test\n" + scriptText);

        try {
            scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);
            fail();
        } catch (UnsupportedOperationException e) {
View Full Code Here

        }
    }

    @Test
    public void testCompileScriptToDirWithWhitespaceOnly() throws Exception {
        final ScriptSource scriptSource = scriptSource("// ignore me\n");
        scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);

        checkEmptyScriptInCache();

        Script script = scriptCompilationHandler.loadFromDir(scriptSource, classLoader, scriptCacheDir,
View Full Code Here

        assertThat(script, isA(expectedScriptClass));
    }

    @Test
    public void testCompileScriptToDirWithEmptyScript() throws Exception {
        final ScriptSource scriptSource = scriptSource("");
        scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);

        checkEmptyScriptInCache();

        Script script = scriptCompilationHandler.loadFromDir(scriptSource, classLoader, scriptCacheDir,
View Full Code Here

        assertThat(script, isA(expectedScriptClass));
    }

    @Test
    public void testCompileScriptToDirWithClassDefinitionOnlyScript() throws Exception {
        final ScriptSource scriptSource = scriptSource("class SomeClass {}");
        scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);

        checkEmptyScriptInCache();

        Script script = scriptCompilationHandler.loadFromDir(scriptSource, classLoader, scriptCacheDir,
View Full Code Here

        assertThat(script, isA(expectedScriptClass));
    }

    @Test
    public void testCompileScriptToDirWithMethodOnlyScript() throws Exception {
        final ScriptSource scriptSource = scriptSource("def method() { println 'hi' }");
        scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);

        checkScriptClassesInCache();

        Script script = scriptCompilationHandler.loadFromDir(scriptSource, classLoader, scriptCacheDir,
View Full Code Here

        assertThat(script, isA(expectedScriptClass));
    }

    @Test
    public void testCompileScriptToDirWithPropertiesOnlyScript() throws Exception {
        final ScriptSource scriptSource = scriptSource("String a");
        scriptCompilationHandler.compileToDir(scriptSource, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);

        checkScriptClassesInCache();

        Script script = scriptCompilationHandler.loadFromDir(scriptSource, classLoader, scriptCacheDir,
View Full Code Here

        }
    }

    @Test
    public void testCompileToDirWithSyntaxError() {
        ScriptSource source = new StringScriptSource("script.gradle", "\n\nnew HHHHJSJSJ jsj");
        try {
            scriptCompilationHandler.compileToDir(source, classLoader, scriptCacheDir, null, expectedScriptClass, verifier);
            fail();
        } catch (ScriptCompilationException e) {
            assertThat(e.getScriptSource(), sameInstance(source));
View Full Code Here

TOP

Related Classes of org.gradle.groovy.scripts.ScriptSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.