In my job project I have recently been asked to generate POM files via a java class. The problem is that I am very, very new to Maven (like since last December).
Wha
It depends on what you are trying to do. If you just want to create POMs for new projects of a certainly type, the best way is through Maven archetypes (you can create your own archetypes with the templates you want).
If you really have a need to programmatically write a POM, you can use the following:
import org.apache.maven.model.*;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
...
Model model = new Model();
model.setGroupId( "some.group.id" );
...
new MavenXpp3Writer().write( w, model );
... where w is a java.io.Writer and you add all the necessary exception handling.
The Javadoc is here: http://maven.apache.org/ref/2.2.1/maven-model/apidocs/index.html
To access this API, you should add this dependency:
org.apache.maven
maven-model
2.2.1
There is a corresponding read API as well, but bear in mind that it won't do all the Maven operations such as inheritence and interpolation (to do that requires more advanced API usage).