• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 110
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!

 
author & internet detective
Posts: 42109
935
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 42109
935
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes! This one! I'll try this.


Thank You Peter and All!
reply
    Bookmark Topic Watch Topic
  • New Topic