{"id":189,"date":"2009-09-25T19:36:52","date_gmt":"2009-09-26T02:36:52","guid":{"rendered":"http:\/\/www.onvural.net\/melih\/thoughts\/?p=189"},"modified":"2009-09-25T19:36:52","modified_gmt":"2009-09-26T02:36:52","slug":"fighting-java-ant-setting-params-in-a-foreach-loop","status":"publish","type":"post","link":"https:\/\/www.onvural.net\/melih\/thoughts\/2009\/09\/25\/fighting-java-ant-setting-params-in-a-foreach-loop\/","title":{"rendered":"Fighting Java Ant&#8230; Setting params in a foreach loop"},"content":{"rendered":"<p>It&#8217;s really frustrating to me that doing something ever so slightly differently leads to such drastically different results when dealing with software. It&#8217;s true that software <em>engineers<\/em> (if you&#8217;re curious about the treatment of the word engineer, then just call me on <a href=\"http:\/\/www.tokbox.com\/melih\">TokBox<\/a> me and I&#8217;ll explain) tend to be the harshest critics of software, and that it&#8217;s hard to impress someone who thinks that they know how to do it better. Every software <em>engineer<\/em> thinks that they know how to do it better. <\/p>\n<p>With that disclaimer, I want to complain a bit about some behavior that I found in working with <a href=\"http:\/\/ant.apache.org\/\">Ant<\/a>.<\/p>\n<p>I don&#8217;t know how to do Ant better than the creators of Ant have. It&#8217;s not my favorite tool, but if I had to use makefiles, then I would stop developing code. I don&#8217;t think whether I use hardtabs or softtabs should determine the validity of my code. That, however, is a different rant. However, I was very surprised to find that when using the &lt;foreach&gt; tag in an Ant script, that it doesn&#8217;t inherit the properties that have been set so far. Instead, you have to expressly define what properties to pass into the &lt;foreach&gt; tag. As an example:<br \/>\n<code><br \/>\ntarget: buildinfo<br \/>\n&lt;property name=\"tokbox.build.num\" value=\"${current.time}\"\/&gt;<\/p>\n<p>target: getcssfiles<br \/>\n&lt;foreach target=\"compile-css\" param=\"the_file\"&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;path&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fileset dir=\"${localedir}\"&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;include name=\"*.css\"\/&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/fileset&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/path&gt;<br \/>\n&lt;\/foreach&gt;<br \/>\n<\/code><br \/>\nThe &lt;foreach&gt; loop doesn&#8217;t know that the tokbox.build.num property exists. Every other target does, but the &lt;foreach&gt; doesn&#8217;t. However, if I were to add:<br \/>\n<code><br \/>\n&lt;param name=\"tokbox.build.num\" value=\"${tokbox.build.num}\" \/&gt;<br \/>\n<\/code><br \/>\ninto my &lt;foreach&gt; loop, then it not only knows the build number, but everything builds! The final code ends up looking like this:<\/p>\n<p><code><br \/>\n&lt;foreach target=\"compile-css\" param=\"the_file\"&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;param name=\"tokbox.build.num\" value=\"${tokbox.build.num}\" \/&gt;<br \/>\n<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;path&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;fileset dir=\"${localedir}\"&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;include name=\"*.css\"\/&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/fileset&gt;<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;&lt;\/path&gt;<br \/>\n&lt;\/foreach&gt;<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s really frustrating to me that doing something ever so slightly differently leads to such drastically different results when dealing with software. It&#8217;s true that software engineers (if you&#8217;re curious about the treatment of the word engineer, then just call me on TokBox me and I&#8217;ll explain) tend to be the harshest critics of software, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[2,1],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pQyAq-33","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":36,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2006\/11\/05\/random-findings-iii\/","url_meta":{"origin":189,"position":0},"title":"Random Findings III","date":"November 5, 2006","format":false,"excerpt":"\"The whale is endangered, while the ant continues to do just fine.\"\u00a0\u00a0\u00a0\u00a0\u00a0- Bill Vaughan","rel":"","context":"In &quot;random findings&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":84,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2008\/02\/04\/software-engineer-for-hire\/","url_meta":{"origin":189,"position":1},"title":"Software Engineer for Hire","date":"February 4, 2008","format":false,"excerpt":"Here is my cover letter to the world:==========You're probably familiar with the kid who sits in class and makes comments like, \"Java isn't a real programming language, you can't overload operators.\"Well that isn't me.You're probably also familiar with the kid who answers all of the easy questions to make it\u2026","rel":"","context":"In &quot;School Year 07-08&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":75,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2007\/11\/06\/bringing-computing-to-everyone\/","url_meta":{"origin":189,"position":2},"title":"Bringing Computing to Everyone","date":"November 6, 2007","format":false,"excerpt":"Amazon started a contest where a startup was to use their Amazon Web Services (AWS), such as storage, scaled computing, Mechanical Turk, to create a product. The winning entry will win $100,000. I had an idea for this, but I thought that the correct combination of hardware and software didn't\u2026","rel":"","context":"In &quot;just thinking out loud&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1038,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2014\/03\/25\/9-memorable-books\/","url_meta":{"origin":189,"position":3},"title":"9 memorable books","date":"March 25, 2014","format":false,"excerpt":"Gregory Fischer (who came into my life through Micky's dear friend Stephanie Grand Jacques) passed along one of these \"chain letters\" that makes the rounds on Facebook. I tend to ignore them, but I really liked the premise behind this one - List 9 books that touched me. I spent\u2026","rel":"","context":"In &quot;just thinking out loud&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1102,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2014\/04\/11\/mind-blown\/","url_meta":{"origin":189,"position":4},"title":"Mind blown...","date":"April 11, 2014","format":false,"excerpt":"This blog post is 7\u00c2\u00a0days late. It all started when I got sick, fell behind, and I\u00e2\u20ac\u2122ve been playing catch up ever since. Some of these catch up blog posts are relevant to the day. Others are just random musings. I'm reading Founders at Work, and I've just had my\u2026","rel":"","context":"In &quot;just thinking out loud&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1224,"url":"https:\/\/www.onvural.net\/melih\/thoughts\/2014\/06\/23\/6-years-later\/","url_meta":{"origin":189,"position":5},"title":"6 years later","date":"June 23, 2014","format":false,"excerpt":"I started at TokBox six years ago today. It's been an amazing journey to say the least. I interviewed with 20 companies my 5th year of college. I got a ton of first round interviews because I'd worked my ass off to build a killer internship resume. I just couldn't\u2026","rel":"","context":"In &quot;Becoming a PM&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts\/189"}],"collection":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":0,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.onvural.net\/melih\/thoughts\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}