I have created a jar file using ant. I want the jar file to take input from a external file.
How can we achieve this?
The java task has an input attribute that specifies the file that should be used as stdin.
Related
I need to create a war file through ant build without a manifest file. I want the war to me created without the manifest file.
I am using tag in build.xml to create the war.
you can use <zip/> task with .war extension for destfile attribute to achieve the same result as the <war/> task (without manifest.mf).
<zip destfile="..\...\WarFile.war"basedir="..\basedir" update="true"/>
in case WarFile.war already exists, although you've written I need to create a war file , the attribute update="true" will be of use (by only updating and not overwriting the file).
All a war file is is a zip file in a specific format. That is libraries go in a particular place, class files go elsewhere, etc. The <war> task has sub-entities like <classes/> and <lib> that make configuring a war file correctly without knowing exactly where everything has to go.
However, you can correctly format the war yourself, and use <zip/>.
Why don't you want a manifest file? A manifest, if you don't specify anything, will contain nothing but the Java version used for the build, and the Ant version and won't affect the execution of your war at all.
What you can do is put useful information into the manifest. For example, we use Jenkins for our builds, and we put in the Jenkins project name and the build number which helps us understand what was included in the war.
There's no reason not to use a manifest file. And, a manifest file can contain useful information (which is accessible to the Java program too).
i have a Apache Ant build.xml to create a simple executeable jar file, but this file is very big.
Now i have the idea to build a executeable jar file with my code and have a directory named "lib" with all external jar files.
I think this will reduce the size of my application to 3%.
Thanks for your help.
How to Extract the .rar files through ANT script and multiple files?
I don't think there's anything native in ant or Java to handle RAR files. Maybe you can <exec> the unrar command from here?
I am reworking a build, and notice that the ear file contains a Service archive file (sar). I'd like to build the sar file in Ant. I suspect I could probably use the ear or zip task to do this, and simply name the file as *.sar. However, I want to be sure that this will work.
What task would I use in Ant to create a SAR file?
It seems you should use the standard JAR task in ANT. According to the JBoss documentation, SAR files contain an extra file:
META-INF/jboss-service.xml
The following "hello world" example has a sample project attached:
https://community.jboss.org/wiki/ExampleHelloWorldService
A sar file is a special kind of jar file (with certain files in WEB-INF, etc.). So you can use the jar task, e.g.:
<jar destfile="${sar.filename}">...</jar>
I want to delete the generated files (".tmp" and ".bak") in the build directory when the source file (".xml)" is modified with Apache Ant. All files have the same name, but different extentions.
I'm not able to create the fileset to do this.
You can use a file mapper in place of a fileset.