| Author |
Ant: How to place resource files into bottom of package level structure?
|
James Dekker
Ranch Hand
Joined: Dec 09, 2006
Posts: 215
|
|
Title: Ant: How to place resource files into bottom of package level structure?
Hello,
Have the following sample project structure:
Wrote an Ant build script which does this:
(1) Creates a build directory
(2) Compiles the Java code into the build directory
(3) Packages the compiled code into a war file
(4) Moves the war file into $TOMCAT_HOME/webapps
Ant build script:
When I run this build script, it places the mysite.war file under $TOMCAT_HOME/webapps,
which, in turn, unpacks itself like this:
$TOMCAT_HOME/webapps/mysite/WEB-INF/classes/example/HelloWorld.class
What I need is the english.properties (located inside the resources folder) to be parallel with HelloWorld.class.
Am manually doing this by explicitly putting in the directory name inside my compile target:
As you can see this will introduce problems because I am setting the directory structure manually.
What would happen if my package changed to com.mycompany?
I would need the english.properties files to be placed like this:
$TOMCAT_HOME/webapps/mysite/WEB-INF/classes/com/mycompany/english.properties
I have already tried using an asterisk wildcard:
But, that broke the build (causing errors while running Ant)!
Would appreciate it if someone can help me with this issue.
Happy programming...
|
 |
Misha Ver
Ranch Hand
Joined: Mar 03, 2008
Posts: 470
|
|
James Dekker wrote:Title: Ant: How to place resource files into bottom of package level structure?
...
As you can see this will introduce problems because I am setting the directory structure manually.
What would happen if my package changed to com.mycompany?
I would need the english.properties files to be placed like this:
$TOMCAT_HOME/webapps/mysite/WEB-INF/classes/com/mycompany/english.properties
Any good reasons that you do not want to put the resource file like WEB-INF/english.properties or even better WEB-INF/config/english.properties?
|
 |
James Dekker
Ranch Hand
Joined: Dec 09, 2006
Posts: 215
|
|
Per your suggestion, I did change my build script to make a WEB-INF/config directory and move the properties files into that directory.
The same thing happens! They are not loaded by the JSP...
Excerpts from build.xml:
My HelloWorld.jsp (located under webapps/mysite/example/):
Properties files which reside under resources dir and are moved into WEB-INF/config:
package_es.properties:
package.properties:
(1) How can I just make them go to the most bottom level folder under $TOMCAT_HOME/webapps/mysite/classes/example/ ?
What would happen if I refactored this package to something else:
com.mycompany.hello
(2) How could the Ant build script know to place them inside:
$TOMCAT_HOME/webapps/mysite/classes/com/mycompany/hello
(3) Otherwise, how would I use your suggestion (make the web page look under WEB-INF/config)?
Happy programming.
|
 |
 |
|
|
subject: Ant: How to place resource files into bottom of package level structure?
|
|
|