Re: Crazy Jelly scripting in maven.xml
1. ${antbasename} doesn't change with the iterations. Don't forget that you are using ant to set this, not jelly. Ant only sets a property once and does not ever overwrite it. OK. Thanks. 2. The various ${namlen} variables mostly don't work. What do you mean. 'namelen 1 2' look ok, at 18. 'namelen 5 6 look ok at 18', and 'namelen 7' looks ok at 18. When do any of the namelen variables have wrong values? I set these namlenX's, and then try to USE is in ${dirname.substring(namlenX). That is what does not work and don't know why. 3. But sometimes do. Both variables (ext and namlen7) work when was set by some sort of string indexOf() function (??). Etc. What on earth is going on? It's only a couple of examples, I have others, too. Am I missing something very obvious? incze incze - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crazy Jelly scripting in maven.xml
Incze Lajos wrote: 1. ${antbasename} doesn't change with the iterations. Don't forget that you are using ant to set this, not jelly. Ant only sets a property once and does not ever overwrite it. OK. Thanks. 2. The various ${namlen} variables mostly don't work. What do you mean. 'namelen 1 2' look ok, at 18. 'namelen 5 6 look ok at 18', and 'namelen 7' looks ok at 18. When do any of the namelen variables have wrong values? I set these namlenX's, and then try to USE is in ${dirname.substring(namlenX). That is what does not work and don't know why. 3. But sometimes do. Both variables (ext and namlen7) work when was set by some sort of string indexOf() function (??). Etc. What on earth is going on? It's only a couple of examples, I have others, too. Am I missing something very obvious? incze It may be related to Longs vs Ints, and coercion of arguments, take a look at this: goal name=test1 j:set var=srcbase value=/opt/data/archive / echosrcbase ${srcbase}/echo j:set var=source value=/opt/data/archive/jav/08/01jav.sgm/ echosource ${source}/echo j:set var=dirname value=/opt/data/archive/jav/08/ echodirname ${dirname}/echo j:set var=namlen5 value=${srcbase.length()+1} / j:set var=namlen6 value=${size(srcbase)+1} / echonamlen 5 6 . ${namlen5} ${namlen6}/echo echonamlen 5 6 classes. ${namlen5.getClass()} ${namlen6.getClass()}/echo j:set var=reldir5 value=${dirname.substring(namlen5)}/ echoreldir5 ${reldir5}/echo j:set var=reldir6 value=${dirname.substring(namlen6)}/ echoreldir6 ${reldir6}/echo j:set var=namlen7 value=${source.toString().indexOf('j')} / echonamlen 7 ... ${namlen7}/echo echonamlen 7 class... ${namlen7.getClass()}/echo j:set var=reldir7 value=${dirname.substring(namlen7)}/ echoreldir7 ${reldir7}/echo /goal and the output: test1: [echo] srcbase /opt/data/archive [echo] source /opt/data/archive/jav/08/01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] namlen 5 6 . 18 18 [echo] namlen 5 6 classes. class java.lang.Long class java.lang.Long [echo] reldir5 [echo] reldir6 [echo] namlen 7 ... 18 [echo] namlen 7 class... class java.lang.Integer [echo] reldir7 jav/08 As you can see, namelen 7 is an Integer, while namelen 5 and 6 are Longs. Now substring takes an int, and I would guess that maybe jelly is silently failing due to an exception trying to pass a long to a method expecting an int. As to why those vars are Longs and not Ints, I would guess it is as a result of the addition operation, where the 1 is treated as a long, and so coerces the entire result to Long. This is not how java works, but jelly expressions don't necessarilly follow correct java rules. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crazy Jelly scripting in maven.xml
Colin Sampaleanu wrote: Incze Lajos wrote: 1. ${antbasename} doesn't change with the iterations. Don't forget that you are using ant to set this, not jelly. Ant only sets a property once and does not ever overwrite it. OK. Thanks. 2. The various ${namlen} variables mostly don't work. What do you mean. 'namelen 1 2' look ok, at 18. 'namelen 5 6 look ok at 18', and 'namelen 7' looks ok at 18. When do any of the namelen variables have wrong values? I set these namlenX's, and then try to USE is in ${dirname.substring(namlenX). That is what does not work and don't know why. 3. But sometimes do. Both variables (ext and namlen7) work when was set by some sort of string indexOf() function (??). Etc. What on earth is going on? It's only a couple of examples, I have others, too. Am I missing something very obvious? incze It may be related to Longs vs Ints, and coercion of arguments, take a look at this: goal name=test1 j:set var=srcbase value=/opt/data/archive / echosrcbase ${srcbase}/echo j:set var=source value=/opt/data/archive/jav/08/01jav.sgm/ echosource ${source}/echo j:set var=dirname value=/opt/data/archive/jav/08/ echodirname ${dirname}/echo j:set var=namlen5 value=${srcbase.length()+1} / j:set var=namlen6 value=${size(srcbase)+1} / echonamlen 5 6 . ${namlen5} ${namlen6}/echo echonamlen 5 6 classes. ${namlen5.getClass()} ${namlen6.getClass()}/echo j:set var=reldir5 value=${dirname.substring(namlen5)}/ echoreldir5 ${reldir5}/echo j:set var=reldir6 value=${dirname.substring(namlen6)}/ echoreldir6 ${reldir6}/echo j:set var=namlen7 value=${source.toString().indexOf('j')} / echonamlen 7 ... ${namlen7}/echo echonamlen 7 class... ${namlen7.getClass()}/echo j:set var=reldir7 value=${dirname.substring(namlen7)}/ echoreldir7 ${reldir7}/echo /goal and the output: test1: [echo] srcbase /opt/data/archive [echo] source /opt/data/archive/jav/08/01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] namlen 5 6 . 18 18 [echo] namlen 5 6 classes. class java.lang.Long class java.lang.Long [echo] reldir5 [echo] reldir6 [echo] namlen 7 ... 18 [echo] namlen 7 class... class java.lang.Integer [echo] reldir7 jav/08 As you can see, namelen 7 is an Integer, while namelen 5 and 6 are Longs. Now substring takes an int, and I would guess that maybe jelly is silently failing due to an exception trying to pass a long to a method expecting an int. As to why those vars are Longs and not Ints, I would guess it is as a result of the addition operation, where the 1 is treated as a long, and so coerces the entire result to Long. This is not how java works, but jelly expressions don't necessarilly follow correct java rules. And in fact, in the above, if you change the definition of namlen 5 to j:set var=namlentemp value=${srcbase.length()+1} / j:set var=namlen5 value=${namlentemp.intValue()} / Then the output becomes test1: [echo] srcbase /opt/data/archive [echo] source /opt/data/archive/jav/08/01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] namlen 5 6 . 18 18 [echo] namlen 5 6 classes. class java.lang.Integer class java.lang.Long [echo] reldir5 jav/08 [echo] reldir6 [echo] namlen 7 ... 18 [echo] namlen 7 class... class java.lang.Integer [echo] reldir7 jav/08 BUILD SUCCESSFUL So indeed, this is a long vs. int issue, where there is a silent failure. As far as I can tell though, this is in no way a maven issue, but rather a jelly issue. Generally, I do find that jelly error checking and reporting is very weak at this point... - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crazy Jelly scripting in maven.xml
On Wed, Mar 05, 2003 at 05:46:40PM -0500, Colin Sampaleanu wrote: It may be related to Longs vs Ints, and coercion of arguments, take a look at this: goal name=test1 j:set var=srcbase value=/opt/data/archive / echosrcbase ${srcbase}/echo j:set var=source value=/opt/data/archive/jav/08/01jav.sgm/ echosource ${source}/echo j:set var=dirname value=/opt/data/archive/jav/08/ echodirname ${dirname}/echo j:set var=namlen5 value=${srcbase.length()+1} / j:set var=namlen6 value=${size(srcbase)+1} / echonamlen 5 6 . ${namlen5} ${namlen6}/echo echonamlen 5 6 classes. ${namlen5.getClass()} ${namlen6.getClass()}/echo j:set var=reldir5 value=${dirname.substring(namlen5)}/ echoreldir5 ${reldir5}/echo j:set var=reldir6 value=${dirname.substring(namlen6)}/ echoreldir6 ${reldir6}/echo j:set var=namlen7 value=${source.toString().indexOf('j')} / echonamlen 7 ... ${namlen7}/echo echonamlen 7 class... ${namlen7.getClass()}/echo j:set var=reldir7 value=${dirname.substring(namlen7)}/ echoreldir7 ${reldir7}/echo /goal and the output: test1: [echo] srcbase /opt/data/archive [echo] source /opt/data/archive/jav/08/01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] namlen 5 6 . 18 18 [echo] namlen 5 6 classes. class java.lang.Long class java.lang.Long [echo] reldir5 [echo] reldir6 [echo] namlen 7 ... 18 [echo] namlen 7 class... class java.lang.Integer [echo] reldir7 jav/08 As you can see, namelen 7 is an Integer, while namelen 5 and 6 are Longs. Now substring takes an int, and I would guess that maybe jelly is silently failing due to an exception trying to pass a long to a method expecting an int. As to why those vars are Longs and not Ints, I would guess it is as a result of the addition operation, where the 1 is treated as a long, and so coerces the entire result to Long. This is not how java works, but jelly expressions don't necessarilly follow correct java rules. Colin, many-many thanks. It drove me already crazy, and I tried to digging into some magic istring interference in forehead-jelly-jexl-introspection Bermuda triangle. What you've found is bad news but MUCH better news than what I was after. I've filed this as critical bug in jira and if you don't mind update it with your findings and lessen the level to ... something not critical. incze - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Crazy Jelly scripting in maven.xml
Incze Lajos wrote: I simply can't believe that it's just me. Below is a sample jelly script extracted from my maven.xml. At the moment I don't know to how extent is that maven, jelly, ant or my stupidity. Here is the script: project default=java:jar xmlns:j=jelly:core xmlns:x=jelly:xml xmlns:jsl=jelly:jsl xmlns:ant=jelly:ant xmlns:log=jelly:log goal name=emnl:test description=Test string manipulations j:set var=srcbase value=${emnl.data.archive.dir} / echosrcbase ${srcbase}/echo j:set var=namlen1 value=${srcbase.length()+1} / j:set var=namlen2 value=${size(srcbase)+1} / echonamlen 1 2 . ${namlen1} ${namlen2}/echo fileScanner var=sources fileset dir=${srcbase} include name=**/*.sgm / /fileset /fileScanner j:forEach items=${sources.iterator()} var=source echosource . ${source}/echo j:set var=filename value=${source.getName()}/ echofilename ... ${filename}/echo basename property=antbasename file=${source} / echoantbasename ${antbasename}/echo j:set var=dirname value=${source.getParent().toString()}/ echodirname ${dirname}/echo j:set var=ext value=${filename.lastIndexOf('.')}/ echoext ${ext}/echo j:set var=basename value=${filename.substring(0,ext)} / echobasename ... ${basename}/echo j:set var=basename2 value=${filename.substring(0,filename.lastIndexOf( '.'))} / echobasename2 .. ${basename2}/echo j:set var=reldir_18 value=${dirname.substring(18)}/ echoreldir_18 .. ${reldir_18}/echo j:set var=reldir1 value=${dirname.substring(namlen1)}/ echoreldir1 ${reldir1}/echo j:set var=reldir2 value=${dirname.substring(namlen2)}/ echoreldir2 ${reldir2}/echo j:set var=reldirJoke value=${dirname.substring(ext)}/ echoreldirJoke . ${reldirJoke}/echo j:set var=reldir3 value=${dirname.substring(srcbase.length())}/ echoreldir3 ${reldir3}/echo j:set var=reldir4 value=${dirname.substring(srcbase.length()+1)}/ echoreldir4 ${reldir4}/echo j:set var=namlen5 value=${srcbase.length()+1} / j:set var=namlen6 value=${size(srcbase)+1} / echonamlen 5 6 . ${namlen5} ${namlen6}/echo j:set var=reldir5 value=${dirname.substring(namlen5)}/ echoreldir5 ${reldir5}/echo j:set var=reldir6 value=${dirname.substring(namlen6)}/ echoreldir6 ${reldir6}/echo j:set var=namlen7 value=${source.toString().indexOf('j')} / echonamlen 7 ... ${namlen7}/echo j:set var=reldir7 value=${dirname.substring(namlen7)}/ echoreldir7 ${reldir7}/echo /j:forEach /goal /project == And here is a sample run: [EMAIL PROTECTED] emnl-transform]$ maven emnl:test __ __ | \/ |__ Jakarta _ ___ | |\/| / _` \ V / -_) ' \ ~ intelligent projects ~ |_| |_\__,_|\_/\___|_||_| v. 1.0-beta-9 Attempting to download commons-jelly-SNAPSHOT.jar. Attempting to download commons-jelly-tags-xml-SNAPSHOT.jar. Attempting to download commons-jelly-tags-jsl-SNAPSHOT.jar. emnl:test: [echo] srcbase /opt/data/archive [echo] namlen 1 2 . 18 18 [echo] source . /opt/data/archive/jav/08/01jav.sgm [echo] filename ... 01jav.sgm [echo] antbasename 01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] ext 5 [echo] basename ... 01jav [echo] basename2 .. 01jav [echo] reldir_18 .. jav/08 [echo] reldir1 [echo] reldir2 [echo] reldirJoke . data/archive/jav/08 [echo] reldir3 /jav/08 [echo] reldir4 [echo] namlen 5 6 . 18 18 [echo] reldir5 [echo] reldir6 [echo] namlen 7 ... 18 [echo] reldir7 jav/08 [echo] source . /opt/data/archive/jav/08/02jav.sgm [echo] filename ... 02jav.sgm [echo] antbasename 01jav.sgm [echo] dirname /opt/data/archive/jav/08 [echo] ext 5 [echo] basename ... 02jav [echo] basename2 .. 02jav [echo] reldir_18 .. jav/08 [echo] reldir1 [echo] reldir2 [echo] reldirJoke . data/archive/jav/08 [echo] reldir3 /jav/08 [echo] reldir4 [echo] namlen 5 6 . 18 18 [echo] reldir5 [echo] reldir6 [echo] namlen 7 ... 18 [echo] reldir7 jav/08 etc. BUILD SUCCESSFUL Total time: 17 seconds == Observations: 1. ${antbasename} doesn't change with the iterations. Don't forget that you are using ant to set this, not jelly. Ant only sets a property once and does not ever overwrite it. 2. The various ${namlen} variables mostly don't work. What do you mean. 'namelen 1 2' look ok, at 18. 'namelen 5 6 look ok at 18', and 'namelen 7' looks ok at 18. When do any of the namelen variables have wrong