java - Accessing a Properties File From a Different Project -
i developing custom maven plugin. when read properties file of custom plugin when run @ different project plugin how can projects properties file, looks @ resources directory of usual because of:
i have that:
properties allproperties = new properties(); allproperties.load(this.getclass().getresourceasstream("/tokens.properties"));
and tried that:
properties allproperties = new properties(); classloader loader = thread.currentthread().getcontextclassloader(); allproperties.load(loader.getresourceasstream("/tokens.properties"));
but didn't work. ideas?
ps: when run it reads plugins properties file. properties files under
src/main/resources
i utilize @ poms:
<build> ... <resources> <resource> <directory>src/main/resources/</directory> <filtering>true</filtering> </resource> </resources> ... </build>
and properties file:
project.version = ${project.version}
properties allproperties = new properties(); classloader loader = thread.currentthread().getcontextclassloader(); allproperties.load(loader.getresourceasstream("/tokens.properties"));
you close. that's indeed right class loader, wrong path. remove leading slash.
allproperties.load(loader.getresourceasstream("tokens.properties"));
java properties maven-plugin-development
No comments:
Post a Comment