You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Peter Reilly <pe...@gmail.com> on 2006/11/28 00:00:55 UTC

javax scripting for ant 1.7.0

As java6 will be released shortly (I think in december)
it would be nice to allow ant to use javax.scripting
for a script engine. I would allow oob (out of the box)
usage of a scripting language with ant on java6 and
allow scripting with languages that only have javax.scripting
engines (F3 for example - I think).

I had proposed before to use the convention
language="jsr:javascript" to denote the jaxax.scripting
engine, and language="bsf:javascript" to denote the
bsf engine with language="javascript" to denote seaching
for the first implementation.

I would like to propose to have an initial implemenation
with language="javascript" just using the bsf engine.
and "jsr:javascript" to denote the javax.script.

This will I think allow use of javax.scripting without
having a negative impact on the current scripting code.

The changes are very small the the current scripting classes.

three new classes are added:
  ScriptRunnerCreator: a class to create a scriptRunner based on
                                 the lanuage and reflection.
  JsrScriptRunner       : an extension of ScriptRunnerBase that
                                  uses javax.scripting.* via reflection
  Reflector                 : a helper class for reflection.

Peter

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Peter Reilly <pe...@gmail.com>.
On 11/29/06, Steve Loughran <st...@apache.org> wrote:
> Jesse Glick wrote:
> > Peter Reilly wrote:
> >> If the attribute is not specified a default path will be used - all
> >> the scriptapi's that ant known about. - bsf, jsr.
> >
> > So why add the API attribute at all? Just do the right thing without
> > having to be told. Legacy scripts will expect to use BSF and they will
> > get it. New scripts wishing to use BSF can add it to the Ant classpath.
> > The behavior of a clean Ant installation in a clean JDK 6 installation
> > will be correct.
>
>
> So if I have java6 then there's no way to get the javax stuff is bsf is
> on the classpath. Dubious. i'd need some way of selecting an engine

exactly.
One may want to use the bsf javascript - it can use a more up-to-date
version of rhino that that in the used by javax.
The same ant build may want to use the javax javascript.

> engine=bsf : bsf is mandatory
> engine=javax: javax is mandatory
> engine=auto :javax if found, fallback to bsf on older systems.  (default)

This is my current thinking (except)

auto: bsf if found in the classpath, otherwise fallback to javax. (default)
  the reason is that the user will have configured up bsf,
  and every thing works, then update to java6 and the
  script tasks stop working.

> This may be a 1.7.1 level change, if its done with a new attribute and
> not a new language string.

Maybe, but I would still like it for 1.7.0.

> This gives us a chance to look at other
> aspects of scripting, to make it more useful.
>   -better fault handing
>   -better default values
>   -ways of passing params to <scriptcondition> conditions (and for reuse)

These could be added in incrementally in the 1.7.* series.
One thing that is needed is evaluation support;
   something like:

  <property name="path" language="beanshell" eval='System.getenv("path")'/>

>
> PS, script performance tests from the netkernel team:
> http://www.mail-archive.com/jruby-devel@lists.sourceforge.net/msg01110.html
>
> conclusion: use jython if you want speed.

Mmmm ...
jython has its own problems....

Peter

>
>
> >
> >> the 1.7.0 behaviour would be to find the first script manager in the
> >> classpath and to use that one. Later versions of ant could check if a
> >> particular script manager supported a particular language and use the
> >> first that "reported" that it did.
> >
> > Why not just make that enhancement now? Shouldn't be complicated, right?
> >
> >> If asked for, future versions of ant could use custom defined script
> >> managers - using a JAR service specification - or an ant task.
> >
> > The purpose of the JSR is to ensure that there is a standard for Java so
> > that no one will need to create a new script manager in the future, and
> > ideally that usage of BSF will monotonically decrease, so I hope Ant
> > would not need to change its behavior again.
> >
> > -J.
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Steve Loughran <st...@apache.org>.
Jesse Glick wrote:
> Peter Reilly wrote:
>> If the attribute is not specified a default path will be used - all 
>> the scriptapi's that ant known about. - bsf, jsr.
> 
> So why add the API attribute at all? Just do the right thing without 
> having to be told. Legacy scripts will expect to use BSF and they will 
> get it. New scripts wishing to use BSF can add it to the Ant classpath. 
> The behavior of a clean Ant installation in a clean JDK 6 installation 
> will be correct.


So if I have java6 then there's no way to get the javax stuff is bsf is 
on the classpath. Dubious. i'd need some way of selecting an engine

engine=bsf : bsf is mandatory
engine=javax: javax is mandatory
engine=auto :javax if found, fallback to bsf on older systems.  (default)

This may be a 1.7.1 level change, if its done with a new attribute and 
not a new language string.  This gives us a chance to look at other 
aspects of scripting, to make it more useful.
  -better fault handing
  -better default values
  -ways of passing params to <scriptcondition> conditions (and for reuse)

PS, script performance tests from the netkernel team:
http://www.mail-archive.com/jruby-devel@lists.sourceforge.net/msg01110.html

conclusion: use jython if you want speed.


> 
>> the 1.7.0 behaviour would be to find the first script manager in the
>> classpath and to use that one. Later versions of ant could check if a
>> particular script manager supported a particular language and use the
>> first that "reported" that it did.
> 
> Why not just make that enhancement now? Shouldn't be complicated, right?
> 
>> If asked for, future versions of ant could use custom defined script
>> managers - using a JAR service specification - or an ant task.
> 
> The purpose of the JSR is to ensure that there is a standard for Java so 
> that no one will need to create a new script manager in the future, and 
> ideally that usage of BSF will monotonically decrease, so I hope Ant 
> would not need to change its behavior again.
> 
> -J.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Jesse Glick <je...@sun.com>.
Peter Reilly wrote:
> If the attribute is not specified a default path will be used - all 
> the scriptapi's that ant known about. - bsf, jsr.

So why add the API attribute at all? Just do the right thing without 
having to be told. Legacy scripts will expect to use BSF and they will 
get it. New scripts wishing to use BSF can add it to the Ant classpath. 
The behavior of a clean Ant installation in a clean JDK 6 installation 
will be correct.

> the 1.7.0 behaviour would be to find the first script manager in the
> classpath and to use that one. Later versions of ant could check if a
> particular script manager supported a particular language and use the
> first that "reported" that it did.

Why not just make that enhancement now? Shouldn't be complicated, right?

> If asked for, future versions of ant could use custom defined script
> managers - using a JAR service specification - or an ant task.

The purpose of the JSR is to ensure that there is a standard for Java so 
that no one will need to create a new script manager in the future, and 
ideally that usage of BSF will monotonically decrease, so I hope Ant 
would not need to change its behavior again.

-J.

-- 
jesse.glick@sun.com  x22801  netbeans.org  ant.apache.org
       http://google.com/search?q=e%5E%28pi*i%29%2B1


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Peter Reilly <pe...@gmail.com>.
On 11/28/06, Dominique Devienne <dd...@gmail.com> wrote:
> On 11/27/06, Peter Reilly <pe...@gmail.com> wrote:
> > As java6 will be released shortly (I think in december)
> > it would be nice to allow ant to use javax.scripting
> > for a script engine. I would allow oob (out of the box)
> > usage of a scripting language with ant on java6 and
> > allow scripting with languages that only have javax.scripting
> > engines (F3 for example - I think).
>
> +1 to oob.
>
> > I had proposed before to use the convention
> > language="jsr:javascript" to denote the jaxax.scripting
> > engine, and language="bsf:javascript" to denote the
> > bsf engine with language="javascript" to denote seaching
> > for the first implementation.
>
> I'd prefer we make it more explicit. Using a prefix is shorter of
> course, but I don't feel confortable using an XML namespace
> like notation without the need for an XML namespace.
>
> Couldn't we use an explicit 'engine' or 'scriptapi' new attribute,
> that would default to bsf, but would accept jsr (or jdk1.6) in a
> future release? Or even an engine "path", like "bsf, jsr" to
> specify a given search order?

I would rather have the prefix in the language attribute, however
an explicit attribute could be acceptable as well.

If the attribute is not specified a default path will be used - all
the scriptapi's that ant known about. - bsf, jsr.
the 1.7.0 behaviour would be to find the first
script manager in the classpath and to use that
one.

Later versions of ant could check if a particular script manager
supported a particular language and use the first that "reported"
that it did.

If asked for, future versions of ant could use custom defined
script managers - using a JAR service specification - or an ant
task.

Peter
>
> > The changes are very small the the current scripting classes.
>
> Hopefully what I propose above doesn't make it too complex. --DD
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Dominique Devienne <dd...@gmail.com>.
On 11/27/06, Peter Reilly <pe...@gmail.com> wrote:
> As java6 will be released shortly (I think in december)
> it would be nice to allow ant to use javax.scripting
> for a script engine. I would allow oob (out of the box)
> usage of a scripting language with ant on java6 and
> allow scripting with languages that only have javax.scripting
> engines (F3 for example - I think).

+1 to oob.

> I had proposed before to use the convention
> language="jsr:javascript" to denote the jaxax.scripting
> engine, and language="bsf:javascript" to denote the
> bsf engine with language="javascript" to denote seaching
> for the first implementation.

I'd prefer we make it more explicit. Using a prefix is shorter of
course, but I don't feel confortable using an XML namespace
like notation without the need for an XML namespace.

Couldn't we use an explicit 'engine' or 'scriptapi' new attribute,
that would default to bsf, but would accept jsr (or jdk1.6) in a
future release? Or even an engine "path", like "bsf, jsr" to
specify a given search order?

> The changes are very small the the current scripting classes.

Hopefully what I propose above doesn't make it too complex. --DD

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0/ release of ant 1.7.0

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Peter, and others

I am thinking of building Ant 1.7.0 on Sunday, December 10. This  
would mean a release date for the public of Sunday, December 17.

Would this fit with the work to add this scripting support ?

Concerning the contents of the scripting support, I trust you. :-)

Regards,

Antoine


On Nov 27, 2006, at 6:00 PM, Peter Reilly wrote:

> As java6 will be released shortly (I think in december)
> it would be nice to allow ant to use javax.scripting
> for a script engine. I would allow oob (out of the box)
> usage of a scripting language with ant on java6 and
> allow scripting with languages that only have javax.scripting
> engines (F3 for example - I think).
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Kevin Jackson <fo...@gmail.com>.
Hi all,

Having just got back from hols and getting up to speed on this, my
initial thoughts are -1 for including this in 1.7.0, given that we are
in the release candidate stage and Antoine wants to do the full
release in 9 days.

I know it's bad form to veto when I may not be 100% sure of all the
details, and I'd be happy to change this to +0 for ant 1.7.1, but for
now until Antoine weighs in with his ideas, I'd like to hold my veto
(although you could twist my arm with some persuasive arguing :)

Thanks,
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Stefan Bodewig <bo...@apache.org>.
On Mon, 27 Nov 2006, Peter Reilly <pe...@gmail.com> wrote:

> I would like to propose to have an initial implemenation
> with language="javascript" just using the bsf engine.
> and "jsr:javascript" to denote the javax.script.
> 
> This will I think allow use of javax.scripting without
> having a negative impact on the current scripting code.

+1 on making the script manager configurable, +0 on supporting
javax.scripting in 1.7.0.  And I'm in the
use-a-separate-attribute-instead-of-a-prefix camp.

Stefan

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Re: javax scripting for ant 1.7.0

Posted by Steve Loughran <st...@apache.org>.
Peter Reilly wrote:
> As java6 will be released shortly (I think in december)
> it would be nice to allow ant to use javax.scripting
> for a script engine. I would allow oob (out of the box)
> usage of a scripting language with ant on java6 and
> allow scripting with languages that only have javax.scripting
> engines (F3 for example - I think).
> 
> I had proposed before to use the convention
> language="jsr:javascript" to denote the jaxax.scripting
> engine, and language="bsf:javascript" to denote the
> bsf engine with language="javascript" to denote seaching
> for the first implementation.

+1 for having this option and implementing it in 1.7.0, so that all 
1.7.0 runtimes support the bsf:javascript syntax

If we stick it in in a 1.7.x release it will only cause confusion and 
incompatibilities of build files.

> I would like to propose to have an initial implemenation
> with language="javascript" just using the bsf engine.
> and "jsr:javascript" to denote the javax.script.

+1 to having all existing bsf stuff supported under bsf:

0 towards javax.scripting support in 1.7.0


> 
> This will I think allow use of javax.scripting without
> having a negative impact on the current scripting code.
> 
> The changes are very small the the current scripting classes.
> 
> three new classes are added:
>  ScriptRunnerCreator: a class to create a scriptRunner based on
>                                 the lanuage and reflection.
>  JsrScriptRunner       : an extension of ScriptRunnerBase that
>                                  uses javax.scripting.* via reflection
>  Reflector                 : a helper class for reflection.
> 
> Peter
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
> For additional commands, e-mail: dev-help@ant.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org