Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

16. OSGi and Groovy > 16.5. Building the Groovy Module

16.5. Building the Groovy Module

Next, we’ll have to build the Groovy module. This can easily be done by using the groovyc compiler and packaging the code into a bundle, just like we did when building the Java version of the calculator. First, we must ensure that the Groovy library is on our build classpath. Then, we’ll define an Ant task for the compilation step. Listing 16.6 illustrates the snippets of the build file that perform these tasks for us. Once the code is compiled, it can be packaged into a bundle using the same mechanisms as the Java code.

Listing 16.6. Groovy Calculator Build Script


<path id="groovy.class.path">
   <pathelement path="${groovy.library.jar}"/>
   <pathelement path=
                "${groovy.dir}/lib/commons-cli-1.2.jar"/>
   <pathelement path="${groovy.dir}/lib/asm-3.2.jar"/>
   <pathelement path="${groovy.dir}/lib/antlr-2.7.7.jar"/>
</path>

<taskdef name="groovyc"
         classname="org.codehaus.groovy.ant.Groovyc"
         classpathref="groovy.class.path"/>

<target name="compile" depends="init">
   <groovyc srcdir="${groovy.src}"
            destdir="${groovy.build}">
      <classpath refid="project.class.path"/>
   </groovyc>
</target>


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial