change directory (CD) using ant script - ant

How to change directory (CD) using ant script?Is there any task in ant which does:
cd

There is no way to do this in Java.
See Changing the current working directory in Java?
So ant can't do it either.
Current dir can only be changed for nested tasks like java forked in separate process with fork="yes".

Related

workflow for xpages installation

I am trying to install prerequisties for workflow for xpages.I could not pass the below requirement. I installed ant, set the home pates, it works for a simple echo like "ant -build c:\test.xml"
Where is the setup folder to run "ant setup.activiti" command? it is not in ant"apache-ant-1.9.2" folder?
Make sure Apache Ant installed in the system, go to setup folder and run command(This
will download Activiti libraries needed in our project): ant setup.activiti
In setup there is the build.xml file ant uses. setup.activiti is a target inside that ant file. You only need to do that when you want to mess with the source build from source / contribute

using ant script to exceute a batch file

this is a batch file that i have. It is located in C:\Work\6.70_Extensions\Lab Tools\ folder.
ANT.BAT:
set CLASSPATH=%CLASSPATH%;.;c:\JavaMail\javamail-1.3\mail.jar;c:\JavaMail\javamail-1.3\mailapi.jar;c:\JavaMail\javamail-1.3\pop3.jar;c:\JavaMail\javamail-1.3\smtp.jar;c:\JavaMail\jaf-1.0.2\activation.jar
CALL "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
#echo on
%ANT_HOME%\bin\ant -logger org.apache.tools.ant.listener.MailLogger -q -buildfile "Master Build.xml"
pause
along with ant.bat, i have a Master Build.xml file located inside the same folder.
When i double click on ant.bat, it will execute the Master Build.xml ant script properly.
However, whenever i try to use another application to open the batch file's absolute path, it always state that Master Build.xml file does not exist!
I tried to open the absolute path using both console application and another ANT Script(via Cruisecontrol framework) but both gives the same error. What is the error here?
for your information here is what ive done with cruisecontrol:
create config.xml (to set intervals for builds)
create nightbuild.xml (so that config.xml will go into it to perform required tasks)
nightbuild.xml will run several console applications to sort files, checkout files from version control etc
lastly, nightbuild.xml will execute ant.bat file to execute the build
These files, config.xml and nightbuild.xml are found in C:\build
When you execute from a directory other than the one containing Master Build.xml, Ant will fail to find the build file, which it expects to be in the current working directory.
You could set an additional environment variable to specify the path to the build file, e.g.
%ANT_HOME%\bin\ant -buildfile "%MASTER_BUILD%\Master Build.xml"
If you set your variable to an absolute path (e.g. C:\Work\6.70_Extensions\Lab Tools) then it will always work. If you use a relative path (e.g. .\Lab Tools), then it will only work if executed from the relative root dir.
(BTW, life will probably be easier if you use buildfiles without spaces in their names, e.g. master_build.xml rather than Master Build.xml).

Is there a way to use just build command instead of ant build while using ant scripts?

I am using Apache Ant scripts for building a web application. I have written some targets in the build.xml file and the script is running fine. I remember using just "build" command to run ant build instead of "ant build". Can anyone tell me how is that achieved? I was a bit curious on this.
There's no built in "build" command. You could create a simple script file called "build" in the same directory that launched the ant build.
Create a text file with this as the contents:
ant build
In windows save this as a file called build.bat then you can just type build from the command line to start your build.
On unix or linux, save the file as build, then make it executable (with chmod +x build). You'll need to type ./build to get it to run.
I don't think there's a lot of value doing this to replace the simple case of ant build, but if you have to regularly run a build that has multiple targets, or need to pass in certain system variables then it could come in useful.
Maybe your are remembering typing "ant" instead of "ant build" in the past. This is possible to setup. You just need to set default attribute on the root project element in your Ant script to the name of the target you want invoked when an explicit target isn't specified.
For instance...
<project name="myproj" default="build">
...
</project>

Using ant to add directories to CVS

How do I add a new directory into my CVS repository using Ant? From all that I've read, it appears that I have to cd to the parent directory and call the cvs command. How do I do that in Ant? I've seen approaches where an to cd is called in Ant; is that the best approach?
Eg of what I am trying to do:
Let's say I have a module Test_Module with directories "A", "B" and "C". Under each of these directories, there are directories for "Jan", "June", "Sept" and I want to create a "Alpha" directory under Test_Module-> C -> Sept.
So, I create a "Alpha" directory on my local system and run the cvs add command from Root and I get the following errror:
cvs add: in directory .:
cvs [add aborted]: there is no version here; do 'cvs checkout' first
I get the same error when I run this using Ant or from command line.
Now, if I cd to the Test_Module/C/Sept directory and run "cvs add Alpha" it creates the directory and everything is fine. So, how do I do the same in Ant? Are there any ant-contrib tasks that are out there that I could possibly use or even a built-in ant task that I am missing?
Thanks in Advance!!
did you look at the Ant CVS task?
I haven't used CVS for a while but since it's possible to manage a Subversion repository with Ant, I guess there should be no problem to do it for CVS

ANT job to invoke JDeveloper to create EAR file with specified deploy file

I was asked about the possibility of creating an ANT script that could be use to copy property files (associated to target environment), create an EAR file (perhaps using JDeveloper deploy file), and deploy that EAR file to target OC4J container.
I am asking if anyone ever successfully invoking JDeveloper automatically to create the EAR file by using specified 'deploy' file by using ANT? OR is it possible to by pass invoking JDeveloper at all. Is there any sample ANT code snippet to do so, or any information/hint that could be useful.
Thanks.
If you use ADF Business Components (BC) then you must use ojdeploy. Otherwise your BC will not get validated and your deployment will fail.
ojdeploy requires JDeveloper installation (ouch!) and will produce an EAR based on JDeveloper's deployment profiles .
(Although it's an old thread, I added something cos you never know.)
I would advise against using JDevelopers for creating an EAR file because I strongly believe that a build process must be autosufficient (i.e. as few external dependencies as possible).
Using Ant, you can simply use the Ear task (remember that the Ear task is a subtask of the Zip task, i.e. you can also use zipfileset inside the ear task).
I've never used OC4J but usually the deployment of an EAR file is just a matter of copying the file into the right directory (so a simple copy task would suffice).
Check out the ojdeploy command in the jdev\bin directory it will let you use JDeveloper's depoyment profiles from a command line.
I found that all the ant tasks used by jDeveloper are in the (default) directory: C:\Oracle\Middleware\jdeveloper\bin
I believe you can copy them to a build server and use them directly
They are the files it uses when you right click and select Deploy from the interface
You can build your own JDeveloper Deployment Profile Interpreter program and generate a Ant file from the Deployment Profile. I have done it before. Tim

Resources