How do I access maven properties defined in the pom in a normal maven project, and in a maven plugin project?
Use the properties-maven-plugin to write specific pom properties to a file at compile time, and then read that file at run time.
In your pom.xml:
${project.name}
${project.version}
bar
org.codehaus.mojo
properties-maven-plugin
1.0.0
generate-resources
write-project-properties
${project.build.outputDirectory}/my.properties
And then in .java:
java.io.InputStream is = this.getClass().getResourceAsStream("my.properties");
java.util.Properties p = new Properties();
p.load(is);
String name = p.getProperty("name");
String version = p.getProperty("version");
String foo = p.getProperty("foo");