summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/Scalac.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2008-09-02 09:11:38 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2008-09-02 09:11:38 +0000
commitf765ef4c20386469a8c7ad077f186b30d1301b5f (patch)
treead778a59682ec7b6823c447d346ab1bb819c33c0 /src/compiler/scala/tools/ant/Scalac.scala
parentcfe1ba4c34795b190a8610889c822d782aa8b1ed (diff)
downloadscala-f765ef4c20386469a8c7ad077f186b30d1301b5f.tar.gz
scala-f765ef4c20386469a8c7ad077f186b30d1301b5f.tar.bz2
scala-f765ef4c20386469a8c7ad077f186b30d1301b5f.zip
fixed #1267
Diffstat (limited to 'src/compiler/scala/tools/ant/Scalac.scala')
-rw-r--r--src/compiler/scala/tools/ant/Scalac.scala41
1 files changed, 23 insertions, 18 deletions
diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala
index 2559ef503b..c15b45f091 100644
--- a/src/compiler/scala/tools/ant/Scalac.scala
+++ b/src/compiler/scala/tools/ant/Scalac.scala
@@ -455,7 +455,6 @@ class Scalac extends MatchingTask {
** Hooks for variants of Scala **
\*============================================================================*/
- protected val sourceEnding = ".scala"
protected def newSettings(error: String=>Unit): Settings =
new Settings(error)
protected def newGlobal(settings: Settings, reporter: Reporter) =
@@ -467,7 +466,7 @@ class Scalac extends MatchingTask {
\*============================================================================*/
/** Initializes settings and source files */
- protected def initialize: (Settings, List[File]) = {
+ protected def initialize: (Settings, List[File], Boolean) = {
// Tests if all mandatory attributes are set and valid.
if (origin.isEmpty) error("Attribute 'srcdir' is not set.")
if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.")
@@ -477,7 +476,9 @@ class Scalac extends MatchingTask {
val mapper = new GlobPatternMapper()
mapper.setTo("*.class")
- mapper.setFrom("*" + sourceEnding)
+ mapper.setFrom("*.scala")
+
+ var javaOnly = true
// Scans source directories to build up a compile lists.
// If force is false, only files were the .class file in destination is
@@ -485,14 +486,16 @@ class Scalac extends MatchingTask {
val sourceFiles: List[File] =
for {
val originDir <- getOrigin
- val originFile <- {
- var includedFiles =
- getDirectoryScanner(originDir).getIncludedFiles()
+ val originFiles <- {
+ val includedFiles = getDirectoryScanner(originDir).getIncludedFiles()
+ var scalaFiles = includedFiles.filter(_.endsWith(".scala"))
+ val javaFiles = includedFiles.filter(_.endsWith(".java"))
if (!force) {
- includedFiles = new SourceFileScanner(this).
- restrict(includedFiles, originDir, destination.get, mapper)
+ scalaFiles = new SourceFileScanner(this).
+ restrict(scalaFiles, originDir, destination.get, mapper)
}
- val list = List.fromArray(includedFiles)
+ javaOnly = javaOnly && (scalaFiles.length == 0)
+ val list = scalaFiles.toList ::: javaFiles.toList
if (scalacDebugging && list.length > 0)
log(
list.mkString(
@@ -504,19 +507,21 @@ class Scalac extends MatchingTask {
)
else if (list.length > 0)
log(
- "Compiling " + list.length + " source file" +
- (if (list.length > 1) "s" else "") +
- (" to " + getDestination.toString)
+ "Compiling " + (
+ if (javaFiles.length > 0)
+ (scalaFiles.length +" scala and "+ javaFiles.length +" java source files")
+ else
+ (list.length +" source file"+ (if (list.length > 1) "s" else ""))
+ ) +" to "+ getDestination.toString
)
else
log("No files selected for compilation", Project.MSG_VERBOSE)
-
list
}
}
yield {
- log(originFile, Project.MSG_DEBUG)
- nameToFile(originDir)(originFile)
+ log(originFiles, Project.MSG_DEBUG)
+ nameToFile(originDir)(originFiles)
}
// Builds-up the compilation settings for Scalac with the existing Ant
@@ -551,13 +556,13 @@ class Scalac extends MatchingTask {
log("Scalac params = '" + addParams + "'", Project.MSG_DEBUG)
settings.parseParams(addParams, error)
- (settings, sourceFiles)
+ (settings, sourceFiles, javaOnly)
}
/** Performs the compilation. */
override def execute() {
- val (settings, sourceFiles) = initialize
- if (sourceFiles.isEmpty) {
+ val (settings, sourceFiles, javaOnly) = initialize
+ if (sourceFiles.isEmpty || javaOnly) {
return
}