ANT how to fork task execution? - ant

I need to fork a new process for a specific ant task. I dont see a fork attribute in the taskdef how do I do it ?
I should be clearer, I am not talking about executing ANT in a forked process:
I have an ant task X, which I need to run in a forked process. Its some third party task which i use with taskdef X and then use this way
Is there anyway to tell any that anytime i use that task please fork the process and run ?

See Running Ant via Java in the Ant manual.

Related

Ant task imported from build.xml in Gradle script is running automatically

I have this Java project there I import an Ant build.xml file with some tasks, like this:
ant.importBuild 'build.xml'
task myTaskA(dependsOn: ':Modules:MyModule:assemble') << {
// do stuff here...
}
compileJava.dependsOn(myTaskA)
configure(jar) {
include 'classes.dex'
}
jar.dependsOn(antCompile)
The task antCompile comes from the Ant build.xml script. However, for some reason, this task is being called at start up when invoke gradlew assemble, it doesn't even wait for the jar task to start.
Also, the antCompile task is defined as the following target in build.xml:
<target name="antCompile" depends="-setup">
</target>
That Ant target, -compile is always the first task to be executed when I invoke gradlew assemble. This doesn't make any sense. That task is never invoked anywhere, it's only a dependency of antCompile. Why is it being executed?
This is, obviously, not what I want... How can I prevent such behaviors?
Seems to work as expected. The build script makes jar depend on antCompile, which according to your words depends on -compile. assemble depends on jar, so executing gradle assembmle should run -compile first.
In any case, it should be said that ant.importBuild has known limitations, and can result in differences in behavior compared to running the Ant build directly. Also you'll lose many of Gradle's advantages when not describing the build in terms of Gradle's own abstractions. Therefore I recommend to port the build to Gradle, rather than using ant.importBuild (which isn't used that often in the real world). Note that it's perfectly fine to reuse Ant tasks in cases where Gradle doesn't provide any equivalent.

Grails clean/ build tasks from ant

Is it possible to run
grails clean
grails build
ect
tasks from ant script?
Thanks!
Try this macro. Though it gives pretty much what the ANT exec task would give you.

How to backport SShSession to Ant 1.7.1

I am stuck with Ant 1.7.1 for the moment for reasons I wont get into. I'd like to be able to use the SshSession Ant task to create SSH tunnels to some of my servers. But SshSession was introduced only in Ant 1.8.0.
I have no experience with custom Ant tasks. Would it be difficult to backport this task from 1.8.0 to 1.7.1 ? Where should I go to learn more on how to do that ?
Thanks for your help !
It looks like the source for the SShSession task is compatible with ant 1.7. Get the source for this task, and compile against ant 1.7 and the jsch jar. Then create a taskdef pointing to the class you've just created (jsch.jar will need to be in the ant lib dir or specified using the -lib option) and you should be good to go.

groovy ant task

I'm using the groovy ant task to compile my groovy files, but it seems like groovy locks the jar file so it can't be moved, deleted, signed, etc. Has anyone run into this bug before and have a workaround? Seems weird that if I run the groovy ant task and compile to a jar file that groovy doesn't release that jar file.
thanks,
Jeff
Does the file get released once the ant build is complete? If this is the case try setting fork="true" on the groovy task so that another JVM is created, rather than Groovy sharing Ant's JVM. This means once Groovy is complete the forked JVM will be disposed and the lock should be freed.
If the lock persists after the Ant build completes, could you provide a bit more detail on what you're doing with Groovy?

ANT & MSBUILD - build process won't fail if errors

When running msbuild.exe with ANT's exec task, errors in the .net code do not result in the build process failing.
Why would this be?
I use Nant to run some MSBuild tasks. Every time I use the failonbuild attribute of that task, it fails for me. Looking at Apache's documentation for Ant, it would appear the same attribute is there as well. Are you using this attribute?
I arrived at a solution and used Exec's failonerror, works like a charm.
What do you let the msbuild task do ?
When I used NAnt previously, I used the task to build a VS.NET solution.
Right now, I'm not using NAnt anymore, I use msbuild instead. :)

Resources