Mick Knutson-4 wrote: > > You mean like: > > classpath:someresource.properties > --- > Thank You… > > Mick Knutson, President > > On Fri, Feb 13, 2009 at 12:30 PM, Costin Caraivan > <[email protected]>wrote: >> Hello, >> >> This will be a newbie question, regarding resource relocation at build >> time. >> It goes like this: I code something, that maybe loads some .properties >> and >> some images. I need the paths to those files, so I hardcode them. Maybe I >> even use another .properties file to load these paths at runtime - but I >> still need to hardcode the path to this file (or give it as an command >> line >> option, let's say). >> >> Anyway, Maven wants a certain structure, it wants the resources in >> src/main/resources (I know it can be configured). But when it builds the >> project jar, the resources are moved from that folder. >> >> So: >> compile time (in an IDE for example, like Eclipse): >> src/main/java/classes >> src/main/resources/resources >> >> jar time: >> classes >> resources >> >> How do you cope with this relocation? If I move everything in >> src/main/resources, I'll break the code when compiling with something >> like >> Eclipse (while debugging for example). If I don't, I break Maven (the >> build >> is more complex, I can't really change the resource folder using >> <resources> >> for various reasons). >> >> How do you handle your resources when building with Maven? You just put >> the >> resources in src/main/resources... and what happens when you run your >> jar? >> >> Thank you for your answers, >> Costin. > So, basically, Maven adds src/main/resources to the classpath and I should add it too while running Eclipse (or maven-eclipse-plugin does it for me, I haven't checked - I don't have access to a Maven project right now). The bad news is that I'm not sure how the resources are loaded, they may be loaded the wrong way (aka not like this: http://jaredtech.blogspot.com/2005/05/loading-properties-with-classpath.html) :(
Thank you, Costin. -- View this message in context: http://www.nabble.com/src-main-resources-and-hardcoded-paths-tp22001032p22001724.html Sent from the Maven - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
