- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Problems with scalascript ant task
Wed, 2009-08-19, 06:09
Can someone explain to me why the scalascript ant task is prefixing my relative classpath entries with the current basedir? I don't seem to have this problem when building scala or sbaz from source, both of which use this tag; however, when I try executing a custom script similar to the following:
<project name="example" default="go">
<property name="scala.home" value="${user.home}/lib/scala"/>
<property name="scala.lib.dir" value="${scala.home}/lib"/>
<property name="scala.comp.jar" value="${scala.lib.dir}/scala-compiler.jar"/>
<property name="scala.lib.jar" value="${scala.lib.dir}/scala-library.jar"/>
<property name="build.dir" value="${basedir}/build"/>
<target name="go">
<mkdir dir="${build.dir}"/>
<!-- Setup sbaz task for ant -->
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.comp.jar}"/>
<pathelement location="${scala.lib.jar}"/>
</classpath>
</taskdef>
<!-- Generate bin scripts -->
<scalascript
file="${build.dir}/myBuggyScript"
classpath="$SCALA_HOME/lib/scala-library.jar"
class="com.example.Main"
javaFlags="-Djava.util.logging.config.file=$SCALA_HOME/meta/logging.properties"
/>
</target>
</project>
I end up with a script having a classpath like the following:
TOOL_CLASSPATH="/home/matlikj/sources/packaging/java/$SCALA_HOME/lib/scala-library.jar"
I've tried looking at the scala.tools.ant.ScalaTool source code, but if there is any configuration there to make this kind of prefixing optionally available, I'm not seeing it. I'm guessing this is some feature that is native to Ant, but haven't found anything yet confirming this. Any suggestions?
Thanks,
James
<project name="example" default="go">
<property name="scala.home" value="${user.home}/lib/scala"/>
<property name="scala.lib.dir" value="${scala.home}/lib"/>
<property name="scala.comp.jar" value="${scala.lib.dir}/scala-compiler.jar"/>
<property name="scala.lib.jar" value="${scala.lib.dir}/scala-library.jar"/>
<property name="build.dir" value="${basedir}/build"/>
<target name="go">
<mkdir dir="${build.dir}"/>
<!-- Setup sbaz task for ant -->
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.comp.jar}"/>
<pathelement location="${scala.lib.jar}"/>
</classpath>
</taskdef>
<!-- Generate bin scripts -->
<scalascript
file="${build.dir}/myBuggyScript"
classpath="$SCALA_HOME/lib/scala-library.jar"
class="com.example.Main"
javaFlags="-Djava.util.logging.config.file=$SCALA_HOME/meta/logging.properties"
/>
</target>
</project>
I end up with a script having a classpath like the following:
TOOL_CLASSPATH="/home/matlikj/sources/packaging/java/$SCALA_HOME/lib/scala-library.jar"
I've tried looking at the scala.tools.ant.ScalaTool source code, but if there is any configuration there to make this kind of prefixing optionally available, I'm not seeing it. I'm guessing this is some feature that is native to Ant, but haven't found anything yet confirming this. Any suggestions?
Thanks,
James
Sat, 2009-08-22, 15:57
#2
Re: Problems with scalascript ant task
Hm.. I just realized I failed to reply to all. Here my update that I had intended for everyone to see...
I do have SCALA_HOME set in the environment and was able to access it with the 'env' prefix after adding the line:
<property environment="env"/>
I don't, however, want $SCALA_HOME to be translated into the environment variable's value, as the script should retain the '$SCALA_HOME' text, allowing the script to use relative paths. Otherwise the script can only work on my machine or other machines who's directory structure is identical. If I've misunderstood your suggestion, please clarify. Thanks for the response.
On Wed, Aug 19, 2009 at 5:20 AM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
I do have SCALA_HOME set in the environment and was able to access it with the 'env' prefix after adding the line:
<property environment="env"/>
I don't, however, want $SCALA_HOME to be translated into the environment variable's value, as the script should retain the '$SCALA_HOME' text, allowing the script to use relative paths. Otherwise the script can only work on my machine or other machines who's directory structure is identical. If I've misunderstood your suggestion, please clarify. Thanks for the response.
On Wed, Aug 19, 2009 at 5:20 AM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Check that SCALA_HOME is defined in the environment when you run ant
On Wed, Aug 19, 2009 at 6:09 AM, James Matlik <james.matlik@gmail.com> wrote:
Can someone explain to me why the scalascript ant task is prefixing my relative classpath entries with the current basedir? I don't seem to have this problem when building scala or sbaz from source, both of which use this tag; however, when I try executing a custom script similar to the following:
<project name="example" default="go">
<property name="scala.home" value="${user.home}/lib/scala"/>
<property name="scala.lib.dir" value="${scala.home}/lib"/>
<property name="scala.comp.jar" value="${scala.lib.dir}/scala-compiler.jar"/>
<property name="scala.lib.jar" value="${scala.lib.dir}/scala-library.jar"/>
<property name="build.dir" value="${basedir}/build"/>
<target name="go">
<mkdir dir="${build.dir}"/>
<!-- Setup sbaz task for ant -->
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.comp.jar}"/>
<pathelement location="${scala.lib.jar}"/>
</classpath>
</taskdef>
<!-- Generate bin scripts -->
<scalascript
file="${build.dir}/myBuggyScript"
classpath="$SCALA_HOME/lib/scala-library.jar"
class="com.example.Main"
javaFlags="-Djava.util.logging.config.file=$SCALA_HOME/meta/logging.properties"
/>
</target>
</project>
I end up with a script having a classpath like the following:
TOOL_CLASSPATH="/home/matlikj/sources/packaging/java/$SCALA_HOME/lib/scala-library.jar"
I've tried looking at the scala.tools.ant.ScalaTool source code, but if there is any configuration there to make this kind of prefixing optionally available, I'm not seeing it. I'm guessing this is some feature that is native to Ant, but haven't found anything yet confirming this. Any suggestions?
Thanks,
James
Sat, 2009-08-22, 16:17
#3
Re: Problems with scalascript ant task
It appears that my results with sbaz were misleading, and the scalatools ant task is basically broken. The sbaz and sbaz.bat scripts that are included with the distribution are stored in SVN, and the ant task that generates these files never realy does anything because the clean target doesn't delete these.
After realizing this, I removed the existing files to force a regeneration of the script files, and the behavior is identical to my minimal ant script example provided in this thread. I will be submitting a Trac ticket some time later this weekend after a little more exploration.
On Sat, Aug 22, 2009 at 10:49 AM, James Matlik <james.matlik@gmail.com> wrote:
After realizing this, I removed the existing files to force a regeneration of the script files, and the behavior is identical to my minimal ant script example provided in this thread. I will be submitting a Trac ticket some time later this weekend after a little more exploration.
On Sat, Aug 22, 2009 at 10:49 AM, James Matlik <james.matlik@gmail.com> wrote:
Hm.. I just realized I failed to reply to all. Here my update that I had intended for everyone to see...
I do have SCALA_HOME set in the environment and was able to access it with the 'env' prefix after adding the line:
<property environment="env"/>
I don't, however, want $SCALA_HOME to be translated into the environment variable's value, as the script should retain the '$SCALA_HOME' text, allowing the script to use relative paths. Otherwise the script can only work on my machine or other machines who's directory structure is identical. If I've misunderstood your suggestion, please clarify. Thanks for the response.
On Wed, Aug 19, 2009 at 5:20 AM, Kevin Wright <kev.lee.wright@googlemail.com> wrote:
Check that SCALA_HOME is defined in the environment when you run ant
On Wed, Aug 19, 2009 at 6:09 AM, James Matlik <james.matlik@gmail.com> wrote:
Can someone explain to me why the scalascript ant task is prefixing my relative classpath entries with the current basedir? I don't seem to have this problem when building scala or sbaz from source, both of which use this tag; however, when I try executing a custom script similar to the following:
<project name="example" default="go">
<property name="scala.home" value="${user.home}/lib/scala"/>
<property name="scala.lib.dir" value="${scala.home}/lib"/>
<property name="scala.comp.jar" value="${scala.lib.dir}/scala-compiler.jar"/>
<property name="scala.lib.jar" value="${scala.lib.dir}/scala-library.jar"/>
<property name="build.dir" value="${basedir}/build"/>
<target name="go">
<mkdir dir="${build.dir}"/>
<!-- Setup sbaz task for ant -->
<taskdef resource="scala/tools/ant/antlib.xml">
<classpath>
<pathelement location="${scala.comp.jar}"/>
<pathelement location="${scala.lib.jar}"/>
</classpath>
</taskdef>
<!-- Generate bin scripts -->
<scalascript
file="${build.dir}/myBuggyScript"
classpath="$SCALA_HOME/lib/scala-library.jar"
class="com.example.Main"
javaFlags="-Djava.util.logging.config.file=$SCALA_HOME/meta/logging.properties"
/>
</target>
</project>
I end up with a script having a classpath like the following:
TOOL_CLASSPATH="/home/matlikj/sources/packaging/java/$SCALA_HOME/lib/scala-library.jar"
I've tried looking at the scala.tools.ant.ScalaTool source code, but if there is any configuration there to make this kind of prefixing optionally available, I'm not seeing it. I'm guessing this is some feature that is native to Ant, but haven't found anything yet confirming this. Any suggestions?
Thanks,
James
On Wed, Aug 19, 2009 at 6:09 AM, James Matlik <james.matlik@gmail.com> wrote: