Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in making jar and war based on the 'src' package hierarchy!

 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello all,

I have the package hierarchy like this,

src
- com.test.servlets -> contains all the servlet sources (*.java).
- com.test.beans -> contains all the bean sources (*.java).

with 'ant' build tool, i compiled all the files and store the class files in the 'build' folder. Then the build folder will be,

build
- com.test.servlets -> contains all the class files of servlets (*.class).
- com.test.beans -> contains all the class files of beans (*.class).

What i need to do,
I need to fetch the class files from the build folder and bundle the web contents(servlets, jsp, images) in the web archive (.war)
and
I need to bundle the beans(core business classes and interfaces) in generic archive (.jar).

[Note: In both archives, the package hierarchy should be the same (in the above) ]

How it can be done?


Thank You!

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yuvaraj,
What do you have so far? What problem are you running into?
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir,

problem means, In what way i can write an Ant Task to build the war and jar from the 'build'(which has the compiled class files) folder. that is,


build
---------- servlet classes --------> to war
---------- bean classes --------> to jar.

I think it might be clear!

Thank You for your Reply
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne was asking you to post the Ant tasks that you have so far to build your WAR and JAR (see NotACodeMill). And asking you to say why those tasks were not behaving as you expected.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34229
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Peter: Right.

Yuvaraj: Note that Jeanne is a female name.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello sir/madam,






My code here is,



here i need to bundle the bean classes only into the jar file!



sorry if i pasted a long code here!
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What have you tried for line 50? Hint: make use of the "includes" and/or "excludes" properties to select only the "com.testbean.beans" classes.

And now for another hint:
By the way, you should also change line 31 to only copy the com.testbean.servlets classes to the WAR:



You might have to try different "includes" settings, the one I gave should work but I didn't try it out so I cannot guarantee it.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello peter,
Already I have tried the thing you have mentioned!

If we use, includes='com/testbean/servlets/**/*.class' -> It will fetch the class files from the given path (not the entire package hierarchy i think) and will store them in the war.

But, for example,

if i include the war file(we have created in the previous step) in my application, can i use like,

import com.testbean.servlets.TestServlet;

(this statement might show some error about the path(com.testbean.servlets) we have specified)


Thank You for your reply peter!
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If we use, includes='com/testbean/servlets/**/*.class' -> It will fetch the class files from the given path (not the entire package hierarchy i think) and will store them in the war.

I disagree.

My simple build.xml file:


My file structure:


The ant run:


The contents of the two JAR files:


I assume that this is what you wanted to do.
 
yuvaraj KumarAmudhan
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes! This one! I'll try this.


Thank You Peter and All!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic