[jboss-user] [Beginners Corner] - Re: A true newbie -- Please help!
PeterJ
do-not-reply at jboss.com
Wed Mar 11 16:26:59 EDT 2009
Change your jar task, the part for including persistence.xml, as follows:
<fileset dir="${basedir}">
| <include name="META-INF/*.xml"/>
| </fileset>
Your build directory layout has room for improvement. Personally, I prefer the directory structured enforced by Maven (or a slightly-modified version of that stucture). This structure clearly separates source, build and built/created artifacts. Your current layout has all of these artifacts mixed together into a single directory which makes setting up filesets for various ant tasks more complex than what is necessary.
I also highly recommend that you add package declarations into your Java source files. I have seen issues with using package-less classes and chasing down such an issue is something that you should not have to worry about. Also, I don't want to have to research if package-less classes are an issue in EJB.
Here are my recommendations:
1) Add the following line as the first line to each of your Java source files:
package org.rij;
2) Change your directory structure so that it looks like this:
build.xml
src/main/java/org/rij/*.java (all your source code goes here)
src/main/resources/META-INF/persistence.xml
src/main/resources/jndi.properties (see note below)
3) After the build is done, it should generate these artifacts:
target/classes/org/rij/*.class (all of the class files)
target/classes/META-INF/persistence.xml
target/mojo.jar
4) Change your build.xml to reflect the above inputs and outputs. I think you will find that the task definitions become much easier. For example, the jar task, which runs after the javac task which compiles the src/main/java source files to target/classes, and the copy task which copies the contents of src/main/resources to target/class becomes simply:
<jar jarfile="target/mojo.jar" basedir="target/classes" />
No messy includes or excludes!
Here are excerpts for the javac and copy task mentioned above, showing the correct directory references (I hard-coded them, you will of course want to set properties and use those)
<javac srcdir="src/main/java" destdir="target/classes" ... />
|
| <copy todir="target/classes">
| <fileset dir="src/main/resources" />
| </copy>
P.S. I hope I don't have too many typos in my code examples...
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4217162#4217162
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4217162
More information about the jboss-user
mailing list