Thanks a lot. I was looking for a separate branch for sbt and forgot that
this has been merged to master some time ago.

hubert
On Monday, October 22, 2012 6:24:02 PM UTC+2, Fluffy wrote:

IF you look in Scala's SBT build, we exposed the raw files used by
ScalaTool ant task so that you can do everything you need to.

https://github.com/scala/scala/blob/master/project/ScalaToolRunner.scala

and

https://github.com/scala/scala/blob/master/project/Packaging.scala#L17

https://github.com/scala/scala/blob/master/project/Packaging.scala#L81


It's not the cleanest of builds, which I keep meaning to clean up, but
it's all in there. Hope that helps!

- Josh

On Mon, Oct 22, 2012 at 9:20 AM, Mark Harrah <dmha...@gmail.com<javascript:>
wrote:
On Mon, 22 Oct 2012 04:37:12 -0700 (PDT)
Hubert Plociniczak <hubert.pl...@gmail.com <javascript:>> wrote:
Hi all,

I want to define a task which basically calls some existing *ant* task from
scala compiler (scala.tools.ant.ScalaTool).
My build file in project/Build.scala looks like this:
import sbt._
import Keys._

import scala.tools.ant.ScalaTool
//import org.apache.tools.ant.taskdefs.MatchingTask

object SomeBuild extends Build {

val exSettings = Defaults.defaultSettings ++ Seq(
organization := "examples",
name := "ant-task-executor",
version := "0.1",
scalaVersion := "2.9.1",
scalacOptions in Compile ++= Seq("-unchecked", "-deprecation",
"-feature", "-Yoverride-objects"),
javacOptions += "-Xss2M",
resolvers ++= Seq("snapshots" at
"https://oss.sonatype.org/content/repositories/snapshots/")
//logLevel := Level.Debug
)


val generateScripts = TaskKey[Unit]("generate-scripts", "Generate
scripts")
val generateScriptsTask = generateScripts <<= (baseDirectory) map {(base)
=>
val task: ScalaTool = new ScalaTool()
}

lazy val root =
Project("testing",file (".")).settings((exSettings ++
List(generateScriptsTask)):_*)
}


and dependencies file in project/buildSettings.sbt is this:
libraryDependencies += "org.scala-lang" % "scala-compiler" % "2.9.2"

libraryDependencies += "org.apache.ant" % "ant" % "1.8.2"

Now, compiling the project is fine, but it fails when running the
'generate-scripts' task with:
sing /home/hubert/.sbt/0.12.1 as sbt dir, -sbt-dir to override.
[info] Loading project definition from
/home/hubert/tmp/repos/sbt-playground/project
[info] Updating
{file:/home/hubert/tmp/repos/sbt-playground/project/}default-113487...
[info] Resolving org.scala-sbt#precompiled-2_10_0-m7;0.12.1 ...
[info] Done updating.
[info] Set current project to ant-task-executor (in build
file:/home/hubert/tmp/repos/sbt-playground/)
generate-scripts
[trace] Stack trace suppressed: run last *:generate-scripts for the full
output.
[error] (*:generate-scripts) java.lang.NoClassDefFoundError:
org/apache/tools/ant/taskdefs/MatchingTask
[error] Total time: 0 s, completed Oct 22, 2012 1:31:00 PM
last
[debug] Running task... Cancelable: false, check cycles: false
java.lang.NoClassDefFoundError:
org/apache/tools/ant/taskdefs/MatchingTask
at java.lang.ClassLoader.defineClass1(Native Method)
...
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at SomeBuild$$anonfun$8.apply(Build.scala:23)


which looks like it just doesn't add ant jar to the classpath but well that
was done in project/buildSettings.sbt.
I am probably getting it wrong but I would appreciate any hints.
The Scala class loader is an ancestor of the class loader for the build
definition, so the Scala ant tasks can't see the ant classes. Ideally, the
ant tasks would be in a separate library that you could add as a
dependency, but obviously that isn't the case here. I'm not sure if there
is a better solution than copying the ant tasks under a different package
name and using those.

-Mark
Thanks,
hubert

--
You received this message because you are subscribed to the Google
Groups "simple-build-tool" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/simple-build-tool/-/xSXGTUvnUoYJ.
To post to this group, send email to simple-b...@googlegroups.com<javascript:> .
To unsubscribe from this group, send email to
simple-build-t...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/simple-build-tool?hl=en.
--
You received this message because you are subscribed to the Google Groups
"simple-build-tool" group.
To post to this group, send email to simple-b...@googlegroups.com<javascript:>
.
To unsubscribe from this group, send email to
simple-build-t...@googlegroups.com <javascript:>.
For more options, visit this group at
http://groups.google.com/group/simple-build-tool?hl=en.
--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/2QMUoTEf3DcJ.
To post to this group, send email to simple-build-tool@googlegroups.com.
To unsubscribe from this group, send email to simple-build-tool+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Search Discussions

Discussion Posts

Previous

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 4 of 4 | next ›
Discussion Overview
groupsimple-build-tool @
categoriesscala
postedOct 22, '12 at 11:37a
activeOct 23, '12 at 9:53a
posts4
users3
websitescala-sbt.org
irc#scala

People

Translate

site design / logo © 2022 Grokbase