I have to automate quite a lot in my current project. For this, I use ANT as it provides quite some commands. However, I have to use ant-contrib as I need for loops and other additional parts.
I use a model driven approach and have to automate the whole chain containing several models until the final model is created.
Is there an alternative to ANT that also provides an easy way to specify task execution? Maybe a DSL for this purpose? Is there anything like this out there?
If you have a modern version of Ant (e.g. 1.8.1) you can use the scriptcondition task/element to run arbitrary scripts with all the control flow of a proper programming language in it.
Something like this:
<condition>
<scriptcondition language="javascript" value="true">
for(var i in self) { println(i); }
self.setValue('true');
</scriptcondition>
</condition>
See also: http://ant.apache.org/manual/index.html
You could use any scripting language that suits your requirements:
e.g.
Bash/Shell Scripting (or PowerShell I suppose)
Something a bit more cross platform and ubiquitous...
Perl
Python
Ruby
...or something more build oriented.
Make
Rake
I'd be interested in which bits of Ant you find useful - I presume it's the tasks and not the language itself, or the declarative bit of Ant. If that's true, I'd suggest Groovy, Jython or Jruby would let you wrap the Ant tasks in code that's more suitable for your needs, without a line of XML.
you can leverage existing ant scripts, and switch to groovy!
using http://groovy.codehaus.org/Using+Ant+from+Groovy
And there is always the shell ... sh, batch or WSH or Powershell or if you have it: Python, Perl etc. can get you quite far.
Related
I'd really like to be able to run some Rascal's program from outside the REPL (e.g. as part of a script, or called from another program). What I'm using Rascal for is and intermediate stage in a larger framework so I am wondering what the best way to go about integrating executing the Rascal code from another program.
Right now the best way is to package your code together with the Rascal shell executable jar. There is a convenience class JavaToRascal for calling into Rascal code. Sometimes it requires some thinking to add your own modules to the Rascal search path using IRascalSearchPathContributors, but if you include a RASCAL.MF file with the right properties it all should go automatically.
If you are thinking of an Eclipse plugin, then the best way is to let your plugin depend on the rascal-eclipse plugin and use ProjectEvaluatorFactory to get access to the interpreter.
Caveat: since we are moving to a compiled system, the code you write for this kind of integration will change. This is the reason we haven't documented the API for calling Rascal from Java yet.
As I was pondering the same question, this is the (maybe trivial) answer I came up with:
java -jar /path/to/rascal-shell-stable.jar path/to/myProgram.rsc
You have to be aware that Rascal calculates module names from the current directory (don't know if it supports something like Java's CLASS_PATH), so in the above example myProgram.rsc should have a module declaration of module path::to::myProgram. Calculated and declared module name have to match.
I am making use of a library project which uses ant to build. My project however is using SCons because I need a far more complex build setup. Now I would like to use ant via SCons but NOT impose the problematic CLASSPATH issues and installation that ant requires.
So I am currently thinking of writing a build.xml parser, which turns the ant into SCons tasks.
Does anyone know whether this has been done before?
As far as I can tell there is no such parser in existence, which I partly believe is because there is great difference in how SCons and ant work. Especially when it comes to dependency resolution. It should be possible, but the translated file output will be very little SCons like, quite unreadable and probably quite difficult to maintain. Which pretty much defeats the whole reason to use SCons in the first place.
Since the library already uses ant, it would probably be a good idea to just incorporate the running of ant into SCons. If SCons can use ant, then you won't have to maintain the library build script (unless it is you that maintain the ant also)
Have you seen this: http://geosoft.no/development/android.html? We're also looking at converting an ANT based android build into our over-arching SCONS build and this looks like a good starting point.
Do anybody know or heared from schmant?
See
http://www.stevevandermerwe.net/blog/wp-content/uploads/2009/12/build-system-evolution13.png
The picture mention schmant as an ant variant without xml.
http://www.schmant.org/
Took about 3 seconds to Google.
Schmant provides an environment for running build scripts and a set of
tools (tasks) that the scripts can use. Schmant can, and will probably
mostly, be used for building Java applications. The immediate goal for
Schmant is to be comparable to Apache Ant in features, but nicer and
easier to work with.
Hy there. I have a number of software projects (also iOS and OSX) which I build with Apache ant`.
Although I quite like Ant it is often too verbose and some things which should be easy are quite tricky or I have to use shell scripts along with ant.
Is there a good alternative for which is extensible, easy to use and should work well on my jenkins build server.
Thanks for your input.
Have a look at Gradle - it's quite different from Ant and may take a little while to get your head around, but I think it's going to be the new standard for build systems. One nice thing is that it has full Ant support under the hood, so you can easily get your existing Ant builds running and then port them to Gradle.
Gareth's answer of Gradle is a good one. But do take a look at what you are doing that is hard with Ant. In my experience, a fair portion of the time its "non-build" stuff. Perhaps leave Ant for the pure build stuff, and use an alternate tool for and deploy or test stuff that's snuck in there.
Although gradle looks very promising I decided to use Rake instead.
I should say that this is a biased decision since I am already using ruby for other parts in my build setup. I found a good Article by Martin Fowler
Another point is that by doing OSX development the platform-independence-aspect of Ant (or Gradle) does not have such a big weight for me.
BTW Besi's Rake answer:
JRuby's Rake+Ant integration seems like a really powerful combo:
http://www.engineyard.com/blog/2010/rake-and-ant-together-a-pick-it-n-stick-it-approach
One big advantange there, it fully supports integration with Ant, allowing step-by-step migration.. which IMHO is only viable strategy for large, existing projects.
Gradle seems similar and while it looks good; I think learning Rake could be a better investment as it's more universal outside of Java.
(The other thing I'm seriously considering is BuildR http://buildr.apache.org, but Jenkins doens't explicitly support it yet, so have to use scripted build steps, which seems less preferable. TODO: a BuildR plugin).
Is it possible to use ant's antlr task to do code generation with the stringtemplate library?
If not, is it better to just execute a java class from command line to code gen w/ stringtemplate?
I've found this link which is close to what I want, but I am having a hard time setting this up properly. That library is not able to see antlr for some reason. link text
It depends of the complexity of the code that you want to generate. In case of our company, we extended org.apache.tools.ant.Task with the generation logic for java code. After that, both ant task and template files were packaged in a jar file.