Permalink
Browse files

closes #80: Add setting for different target directories

  • Loading branch information...
1 parent 19a7238 commit b4a291319f9af0c1e593229728d6fca030ce1bac Heiko Seeberger committed Mar 2, 2012
@@ -110,7 +110,7 @@ private object Eclipse {
name(ref) |@|
buildDirectory |@|
baseDirectory(ref) |@|
- mapConfigs(configs, srcDirectories(ref, createSrc(ref))) |@|
+ mapConfigs(configs, srcDirectories(ref, createSrc(ref), eclipseOutput(ref))) |@|
scalacOptions(ref) |@|
mapConfigs(configs, externalDependencies(ref, withSourceArg getOrElse withSource(ref))) |@|
mapConfigs(configs, projectDependencies(ref, project))
@@ -201,7 +201,7 @@ private object Eclipse {
projectDependencies: Seq[String],
jreContainer: String)(
implicit state: State) = {
- val srcEntriesIoSeq = for ((dir, output) <- srcDirectories) yield srcEntry(baseDirectory, output)(dir)
+ val srcEntriesIoSeq = for ((dir, output) <- srcDirectories) yield srcEntry(baseDirectory, dir, output)
for (srcEntries <- srcEntriesIoSeq.sequence) yield {
val entries = srcEntries ++
(externalDependencies map libEntry(buildDirectory, baseDirectory, relativizeLibs)) ++
@@ -212,10 +212,13 @@ private object Eclipse {
}
}
- def srcEntry(baseDirectory: File, classDirectory: File)(srcDirectory: File)(implicit state: State) =
+ def srcEntry(baseDirectory: File, srcDirectory: File, classDirectory: File)(implicit state: State) =
io {
if (!srcDirectory.exists()) srcDirectory.mkdirs()
- EclipseClasspathEntry.Src(relativize(baseDirectory, srcDirectory), output(baseDirectory, classDirectory))
+ EclipseClasspathEntry.Src(
+ relativize(baseDirectory, srcDirectory),
+ relativize(baseDirectory, classDirectory)
+ )
}
def libEntry(
@@ -262,11 +265,15 @@ private object Eclipse {
def srcDirectories(
ref: Reference,
- createSrc: EclipseCreateSrc.ValueSet)(
+ createSrc: EclipseCreateSrc.ValueSet,
+ eclipseOutput: Option[String])(
configuration: Configuration)(
implicit state: State) = {
import EclipseCreateSrc._
- val classDirectory = setting(Keys.classDirectory in (ref, configuration))
+ val classDirectory = eclipseOutput match {
+ case Some(name) => baseDirectory(ref) map (new File(_, name))
+ case None => setting(Keys.classDirectory in (ref, configuration))
+ }
def dirs(values: ValueSet, key: SettingKey[Seq[File]]) =
if (values subsetOf createSrc)
(setting(key in (ref, configuration)) <**> classDirectory)((sds, cd) => sds map (_ -> cd))
@@ -385,6 +392,9 @@ private object Eclipse {
def createSrc(ref: Reference)(implicit state: State) =
setting(EclipseKeys.createSrc in ref).fold(_ => EclipseCreateSrc.Default, id)
+ def eclipseOutput(ref: ProjectRef)(implicit state: State) =
+ setting(EclipseKeys.eclipseOutput in ref).fold(_ => None, id)
+
def preTasks(ref: ProjectRef)(implicit state: State) =
setting(EclipseKeys.preTasks in ref).fold(_ => Seq.empty, _.zipAll(Seq.empty, null, ref))
@@ -418,8 +428,6 @@ private object Eclipse {
// Utilities
def relativize(baseDirectory: File, file: File) = IO.relativize(baseDirectory, file).get
-
- def output(baseDirectory: File, classDirectory: File) = relativize(baseDirectory, classDirectory)
}
private case class Content(
@@ -85,6 +85,11 @@ trait EclipsePlugin {
"The source kinds to be included."
)
+ val eclipseOutput: SettingKey[Option[String]] =
+ SettingKey[Option[String]](
+ prefix("eclipse-output"),
+ "The optional output for Eclipse.")
+
val preTasks: SettingKey[Seq[TaskKey[_]]] =
SettingKey[Seq[TaskKey[_]]](
prefix("pre-tasks"),
@@ -141,6 +141,10 @@ TaskKey[Unit]("verify-classpath-xml-subb") <<= baseDirectory map { dir =>
TaskKey[Unit]("verify-classpath-xml-subc") <<= baseDirectory map { dir =>
val classpath = XML.loadFile(dir / "sub" / "subc" / ".classpath")
if ((classpath \ "classpathentry") != (classpath \ "classpathentry").distinct)
+ error("Expected .classpath of subc project not to contain duplicate entries: %s" format classpath)
+ // src entries
+ if (!(classpath.child contains <classpathentry kind="src" path="src/main/scala" output=".target" />))
+ error("""Expected .classpath of subc project to contain <classpathentry kind="src" path="src/main/scala" output=".target" /> """)
// lib entries with absolute paths
if (!(classpath.child contains <classpathentry kind="lib" path={ "%s/lib_managed/jars/biz.aQute/bndlib/bndlib-1.50.0.jar".format(dir.getCanonicalPath) } />))
error("""Expected .classpath of subc project to contain <classpathentry kind="lib" path="%s/lib_managed/jars/biz.aQute/bndlib/bndlib-1.50.0.jar" />: %s""".format(dir.getCanonicalPath, classpath))
@@ -73,7 +73,8 @@ object Build extends Build {
"biz.aQute" % "bndlib" % "1.50.0"
),
retrieveManaged := true,
- EclipseKeys.relativizeLibs := false
+ EclipseKeys.relativizeLibs := false,
+ EclipseKeys.eclipseOutput := Some(".target")
)
)
}

0 comments on commit b4a2913

Please sign in to comment.