title: How to run a groovy script from gradle that depends on another script
body: <p>I'm playing around with the samples directory that comes with Gradle and trying to create a simple task that runs a groovy script which depends on another script. </p>
  
  <p>The structure of the project looks like this:</p>
  
  <pre><code>.
  ├── build.gradle
  └── src
      ├── main
      │   ├── groovy
      │   │   └── org
      │   │       └── gradle
      │   │           └── Person.groovy
      │   └── resources
      │       ├── resource.txt
      │       └── script.groovy
      └── test
          ├── groovy
          │   └── org
          │       └── gradle
          │           └── PersonTest.groovy
          └── resources
              ├── testResource.txt
              └── testScript.groovy
  </code></pre>
  
  <p>I've added the following task in <code>build.gradle</code></p>
  
  <pre><code>task runScript &lt;&lt; {
    new GroovyShell().run(file('src/main/resources/script.groovy'))
  }
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>FAILURE: Build failed with an exception.
  
  * Where:
  Build file '/gradle/gradle-1.0/samples/groovy/quickstart/build.gradle' line: 13
  
  * What went wrong:
  Execution failed for task ':runScript'.
  Cause: No such property: person for class: script
  </code></pre>
  
  <p>contents of <code>script.groovy</code> are:</p>
  
  <pre><code>person.name = person.name[0].toUpperCase() + person.name[1..-1]
  </code></pre>
  
  <p>contents of <code>Person.groovy</code> are:
      package org.gradle</p>
  
  <pre><code>class Person {
      String name
  
      def Person() {
          getClass().getResourceAsStream('/resource.txt').withStream {InputStream str -&gt;
              name = str.text.trim()
          }
          getClass().getResourceAsStream('/script.groovy').withStream {InputStream str -&gt;
              def shell = new GroovyShell()
              shell.person = this
              shell.evaluate(str.text)
          }
      }
  }
  </code></pre>
  
  <p><strong>Question</strong>
  How can I add a task that would simply run <code>script.groovy</code> which makes use of another groovy class (<code>Person</code>)</p>