Movatterモバイル変換


[0]ホーム

URL:


This page is no longer maintained — Please continue to the home page atwww.scala-lang.org

Home

Scala Main Menu

Scala Ant Tasks

Created by admin on 2008-07-04. Updated: 2009-11-30, 20:06

The Scala distribution contains several tasks for building software projects usingApache Ant, a Java-based build tool. The tasks described below require Apache Ant version 1.6 or newer.

The Scala tasks are:scalac,fsc andscaladoc

scalac
Description

Compiles a Scala source tree.

The source and destination directory will be recursively scanned for Scala source files to compile. Only Scala files that have no corresponding.class file or where the class file is older than the.scala file will be compiled.

Note: Ant uses only the names of the source and class files to find the classes that need a rebuild. It will not scan the source and therefore will have no knowledge about nested classes, classes that are named different from the source file, and so on.

It is possible to refine the set of files that are being compiled. This can be done with theincludes,includesfile,excludes, andexcludesfile attributes. With theincludesorincludesfile attribute, you specify the files you want to have included. Theexclude orexcludesfile attribute is used to specify the files you want to have excluded. In both cases, the list of files can be specified by either the filename, relative to the directory(s) specified in thesrcdir attribute or nested<src> element(s), or by using wildcard patterns. See the Ant documentation on directory-based tasks, for information on how the inclusion/exclusion of files works, and how to write wildcard patterns.

Parameters
AttributeDescriptionRequired
srcdirLocation of the Scala files.Yes, unless nested<src>elements or srcref are present.
srcrefLocation of the Scala files, given as a reference to a path defined elsewhere.Yes, unless nested<src>elements or srcdir are present.
destdirLocation to store the class files.No
classpathThe classpath to use.No
classpathrefThe classpath to use, given as a reference to a path defined elsewhere.No
sourcepathThe sourcepath to use; defaults to the value of the srcdir attribute (or nested<src> elements). To suppress the sourcepath switch, use sourcepath="".No
sourcepathrefThe sourcepath to use, given as a reference to a path defined elsewhere.No
bootclasspathLocation of bootstrap class files.No
bootclasspathrefLocation of bootstrap class files, given as a reference to a path defined elsewhere.No
extdirsLocation of installed extensions.No
extdirsrefLocation of installed extensions, given as a reference to a path defined elsewhere.No
targetSpecifies which backend to use; defaults tojvm-1.4 (accepted values are:jvm-1.5,jvm-1.4,msil).No
deprecationIndicates whether source should be compiled with deprecation information; defaults tono (accepted values are:on,off,yes andno).
Available since Scala version 2.3.
No
uncheckedIndicates whether source should be compiled with unchecked information; defaults tono (accepted values are:on,off,yesandno).
Available since Scala version 2.3.
No
encodingEncoding of source files.No
loggingAsks the compiler for verbose output; defaults tonone (accepted values are:none,verbose, anddebug).No
usepredefsAsks the compiler to use predefined values for compilation; defaults toyes.No
forceWhether to force the compilation of all files; possible values arefalse (only compile modified files), andtrue (always recompile all files); defaults tofalse.No
addparamsSpecifies additional command line arguments to be passed to the Scala tool.
The user may for example specify advanced options (eg.-Xresident) as well as private options (eg.-Ydebug) not available as Ant attributes.
No
failonerrorIndicates whether compilation errors will fail the build; defaults totrue.
Available since Scala version 2.6.
No
scalacdebuggingIf set totrue, the scalac Ant taks will print the filenames being compiled, instead of only the number of files.No
assemnameThe assembly name. Only relevant if the target is "msil".No
assemrefsReferences to external assemblies. Only relevat if the target is "msil"No
Parameters specified as nested elements

This task forms an implicit FileSet and supports all attributes of<fileset> (dir becomessrcdir) as well as the nested<include>,<exclude> and<patternset> elements.

src,classpath,sourcepath,bootclasspath andextdirs

Scalac'ssrcdir,classpath,sourcepath,bootclasspath, andextdirs attributes are path-like structures and can also be set via nested<src>,<classpath>,<sourcepath>,<bootclasspath> and<extdirs> elements, respectively.

Requirements
  • Ant 1.6 or higher
  • Scala 2.2 or higher
Example
<propertyname="sources.dir"value="${base.dir}/sources"   /><propertyname="build.dir"value="${base.dir}/build"   /><targetname="init"><propertyname="scala-library.jar"value="${scala.home}/lib/scala-library.jar"   /><pathid="build.classpath"><pathelementlocation="${scala-library.jar}"   /><!--<pathelementlocation="${your.path}"   />--><pathelementlocation="${build.dir}"   /></path><taskdefresource="scala/tools/ant/antlib.xml"><classpath><pathelementlocation="${scala.home}/lib/scala-compiler.jar"   /><pathelementlocation="${scala-library.jar}"   /></classpath></taskdef></target>

In the above target "init" the tasktaskdef defines the Scala ant tasksfsc,sbaz,scalac andscalascript.

<targetname="build"depends="init"><mkdirdir="${build.dir}"   /><scalacsrcdir="${sources.dir}"destdir="${build.dir}"classpathref="build.classpath"><includename="compile/**/*.scala"   /><excludename="forget/**/*.scala"   /></scalac></target>

Compiles all Scala files insources/compile/ (not insources/forget) tobuild/ with given classpath. Files insources/forget/ will not necessarily be compiled, but might be as they are in the sourcepath. All modified files are re-compiled.

fsc (fast Scala compiler)
Description

Compiles a Scala source tree.

Thefsc Ant task supports the same set of parameters as thescalac Ant task with the following additional parameters:

Parameters
AttributeDescriptionRequired
resetReset compile server caches.No
shutdownShutdown compile server.No
serverSpecify compile server host and port number. Usually this option is not needed. Note that the hostname must be for a host that shares the same filesystem.No
Requirements
  • Ant 1.6 or higher
  • Scala 2.2 or higher
scaladoc
Description

Generates the API documentation in HTML format for the given source files.

Thescaladoc Ant task supports the same set of parameters as thescalac Ant task with the following additional parameters:

Parameters
AttributeDescriptionRequired
windowtitleSpecify the text to appear in the window title.
Default value:"Scala 2".
No
doctitleSpecify the text to appear in the main frame title.
Default value:"Scala 2<br />API Specification"
No, HTML code is supported.
stylesheetfileFile to change style of the generated documentation.
NB. The file name is system-dependent.
Available since Scala version 2.5.
No
headerInclude header text for each page.
Available since Scala version 2.5.
No, HTML code is supported.
footerInclude footer text for each page.
Available since Scala version 2.5.
No, HTML code is supported.
topInclude top text for each page.
Available since Scala version 2.5.
No, HTML code is supported.
bottomInclude bottom text for each page.
Available since Scala version 2.5.
No, HTML code is supported.
Requirements
  • Ant 1.6 or higher
  • Scala 2.2 or higher
Example
<targetname="docs"depends="init"><mkdirdir="${docs.dir}"   /><scaladocsrcdir="${sources.dir}"destdir="${docs.dir}"deprecation="yes"unchecked="yes"windowtitle="liftweb Library Documentation"doctitle="&lt;div&gt;liftweb 0.1.0&lt;/div&gt;"classpathref="build.classpath"><includename="compile/**/*.scala"   /></scaladoc></target>
java (Ant core task)
Description

Executes a Java class within the running (Ant) VM or forks another VM if specified.

The taskjava belongs the core tasks of theAnt distribution.

Note: The Scala libraryscala-library.jar must be present in the Java class path. Theactors anddbc libraries are available as separate JAR files:scala-actors.jarandscala-dbc.jar.

Example
<targetname="run"depends="build"><javaclassname="examples.sort"classpathref="build.classpath"></java></target>

 

Scala Quick Links

Featured News

User login


will be sent securely

Create new account

Retrieve lost password

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland


[8]ページ先頭

©2009-2026 Movatter.jp