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
  • PrintPrint
Share this Page URL
Help

15. OSGi and Scala > 15.5. Building the Scala Module

15.5. Building the Scala Module

Next, we’ll build the Scala module. This can easily be done by using the scalac 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 Scala library is on our build classpath. Then, we’ll define an Ant task for the compilation step. Listing 15.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 15.6. Scala Calculator Build Script


<path id="scala.class.path">
   <pathelement path="${scala.library.jar}"/>
   <pathelement path="${scala.compiler.jar}"/>
</path>

<taskdef resource="scala/tools/ant/antlib.xml"
         classpathref="scala.class.path"/>

<target name="compile" depends="init">
   <scalac srcdir="${scala.src}" destdir="${scala.build}">
      <classpath refid="project.class.path"/>
   </scalac>
</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 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint