maven - Is there a Java Class that generates a POM.xml file? -


In my job project, I have recently been asked to create PO files through a Java class. The problem is that I am very, very new to Maven (since last December).

Whatever I need is a code that generates an XML file (a palm file, but if I can configure any XML code that will be okay) give all the necessary data So, they do not have to write it manually. I do not know if I am explaining myself, but the question is whether there is a library or class that produces a POM file with any data Training does? If this is not good, then I do not want to search for a little more time which I do not know whether it is also present or if the POM object is as simple as declaration and then a trivial document d = generatePom (POM) Is doing p). Since it is difficult to write any POM files because I think it should be an easy way of doing it but I think I have lost too many API in Javadoc and I can not find my own way.

I think that there is no code for this, then to find the POM dictionary (to cover all the elements) and to create an XML file with a PM object (which I previously provided XML generators such as Jodom, XOM or Xstream

PS: I have read that the Eclipse Project is doing some Mewen things, any thoughts about this would be appreciated if a group that first Does this from (Eg, "Hey! You're doing it wrong"). And it has an API that generates a pom.xml file for the actual project you have. If I can overload input data or some things, then this would be a good thing.

Thanks for all!

It depends on you what you are trying to do. If you definitely want to create a POM for a new type of new projects, then the best way is to create Maven antiquity (you can create your own nature with your desired templates).

If you really 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.

Javadoc is here:

To access this API, you should add this dependency:

  & lt; Dependency & gt; & Lt; Group & gt; Org.apache.maven & lt; / Group & gt; & Lt; ArtifactId & gt; Maven model & lt; / ArtifactId> & Lt; Version & gt; 2.2.1 & lt; / Edition & gt; & Lt; / Dependencies & gt;  

There is also a similar read API, but keep in mind that it does not perform malware operations such as herpes and projection (to do so which requires more advanced API usage).


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -