How to write this Ant script?

Hello experts,

I must tell that I am not good at Ant script. This is my first time to work on it. Following is a piece of build script. Can anybody help to convert it to Ant script?
set jdk=C:\jdk1.8.0_20
set meap_sdk=C:\cannon\canon\MEAP_SDK
set meap_login_sdk=C:\cannon\canon\MEAP_Login

%jdk%\bin\javac -d build -classpath %meap_sdk%\MEAP\DistributableSoftware.jar;login.jar;json.jar;%meap_sdk%\MEAP\Environment_on_PC\lib\meap.jar;%meap_sdk%\MEAP\Environment_on_PC\lib\osgi.jar;.-sourcepath src/com/nq/boot/*.java src/com/nq/utilities/*.java src/com/nq/boot/*.java  src/com/nq/nativecanon/fax/*.java -target 1.1 -source 1.2
pause

%jdk%\bin\jar cfm0 Canon_3_Dev.jar META-INF\MANIFEST.MF -C build com bundle.permissions DistributableSoftware.jar .\json.jar .\BC.jar .\image\*.png .\jregex1.2_01.jar .\res\en\*.htm .\res\*.properties

pause

Open in new window

Today is my due date for this script. So please help.
Thanks so much!
Wendyu66Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Wendyu66Author Commented:
I will work on the javac part. Can anybody help me with the 2nd part? That is
%jdk%\bin\jar cfm0 Canon_3_Dev.jar META-INF\MANIFEST.MF -C build com bundle.permissions DistributableSoftware.jar .\json.jar .\BC.jar .\image\*.png .\jregex1.2_01.jar .\res\en\*.htm .\res\*.properties

Open in new window

Thanks so much.
0
Wendyu66Author Commented:
Actually... I am working on the first part now.
0
Wendyu66Author Commented:
Here is what I have -
	<target name="build-jar" depends="compile">
		<echo> check class dir: "${classes.dir}/boot"  </echo>
	        <jar destfile="${final.jar}" >
	        	
	         	<fileset dir="${classes.dir}/boot"/>
	        	<fileset dir="${classes.dir}/comm/cache"/>
	        	<fileset dir="${classes.dir}/comm/service"/>
	        	        			
	        	<fileset dir="${classes.dir}/configuration"/>
	        	<fileset dir="${classes.dir}/data"/>
	        	
	<manifest>
	        	    <attribute name="Built-By" value="${user.name}"/>
	        	    <section name="common">
	        	      	<attribute name="Manifest-Version" value="${version}"/>
	        	      	<attribute name="Bundle-Vendor" value="nQueue Billback"/>	        	     
	        	      	<attribute name="Bundle-ClassPath" value="DistributableSoftware.jar ./json.jar ./BC.jar ./image/*.png ./jregex1.2_01.jar  ./login.jar ./commons-lang-2.6.jar ./meap.jar"/>
	        	      	<attribute name="Applet-Name" value="Canon_3_Dev"/>
	        	      	<attribute name="Import-Package" value="./res/en/*.htm"/> 
	        	      	<attribute name="Application-Id" value="./res/*.properties"/>
	        	    </section>
	        	    
	        	  </manifest>
	        </jar>
	</target>

Open in new window

============================
Above piece of script runs smoothly and creates a jar file, however the jar file misses a lot of content that is class files. What's wrong with this script?  Can anybody look into it?

Thanks so much.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CEHJCommented:
Here is what I have -
But that's incomplete and therefore useless to post. You are aware it's incomplete? If not, then that's why it doesn't work properly ;)
0
Wendyu66Author Commented:
Thanks CEHI for your reply. That was correct. I only posted a part of my ant file.

Now that my ant script works and creates jar file, however I found something that was strange. I developed my ant script and ran it on Eclipse on Windows. With this script I created a jar file. When I used 7-Zip to review its contents, I found that one of the properties of the jar file was "Host OS" and its value was "Unix".  I had expected this value to be "FAT" ("Windows"). Do you know where I can control this value in an ant file?

Thanks
0
Wendyu66Author Commented:
I searched online but I did not find that Ant had an attribute to specify "Host OS".
0
CEHJCommented:
I found that one of the properties of the jar file was "Host OS" and its value was "Unix".  I had expected this value to be "FAT" ("Windows").
I've never heard of such a property. FAT in any case is a type of file system and only incidentally associated with Windows. Sounds like something you don't need to worry about.
0
Wendyu66Author Commented:
Hi CEHI,

 Following is a bat file. How can I include the "bundle.permissioins" and ".\res\*.properties" in my Ant script?
%jdk%\bin\jar cfm0 Canon_3_Dev.jar META-INF\MANIFEST.MF -C build com bundle.permissions DistributableSoftware.jar .\json.jar  .\res\en\*.htm .\res\*.properties

Open in new window


I did following

<jar destfile="${final.jar}" basedir="${build.dir}" compress="false" keepcompression="false">
                     
                     <property file="res\LoginSetting.properties"/>
                     <loadfile property="permissions" srcFile="bundle.permissions"/>
 </jar>

Open in new window


but failed. Any ideas how to this?
0
Wendyu66Author Commented:
just found it...   using "includes" seems to

 <jar destfile="${final.jar}" basedir="${build.dir}" compress="false" keepcompression="false" includes="res\LoginSetting.properties;bundle.permissions">

Open in new window

0
CEHJCommented:
You need to use a fileset inside jar. Try

<fileset dir="." includes="bundle.permissions"/>

<fileset dir="." includes="res/**.properties"/>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
You can but using fileset elements makes the code more flexible and readable
0
Wendyu66Author Commented:
Yes, that works. Thanks a lot.

Here comes another question. Do you know how the bat command
 
%jdk%\bin\jar cfm0 Canon_3_Dev.jar META-INF\MANIFEST.MF -C build com bundle.permissions DistributableSoftware.jar .\json.jar .\BC.jar .\image\*.png .\jregex1.2_01.jar .\res\en\*.htm .\res\*.properties

Open in new window


works? I mean, how the "bundle.permissions" and ".\res\en\*.htm .\res\*.properties" work here?

What I feel strange is that I can not find files of "bundle.permissions" and ".\res\en\*.htm .\res\*.properties" in the jar file created with this jar bat command.  On the other hand, with "<fileset dir .../>", I can find these files in the jar created with my ant script.

Any ideas why the jar file created with the jar bat command does not have these files?
0
Wendyu66Author Commented:
I read this on Oracle's website
 
 
jar cf jar-file input-file(s)
The input-file(s) argument is a space-separated list of one or more files that you want to include in your JAR file.

Open in new window


but why I could not find those files in the jar file created with the bat command?
0
CEHJCommented:
Any ideas why the jar file created with the jar bat command does not have these files?
Because it's ... wrong? ;)
0
Wendyu66Author Commented:
>>> Because it's ... wrong? ;)

Absolutely! I ran the bat script a moment ago and this time it created those files in the jar file! I do not know why but this is really crazy!
0
CEHJCommented:
a. is this issue with the batch file just of academic interest or is it practical?
b. i hope you're not confusing the batch file's creation of the jar with Ant's when you said the batch file worked ;)
0
Wendyu66Author Commented:
to answer your questions -
a. it's practical
b. no, I did not confuse one with the other.

I go to close this thread. I assign the points to you.

Thanks so much for your time!
0
CEHJCommented:
:)

Actually the command line version looks right to me. Try it after making sure you completely deleted earlier versions
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.