how to add new domElement to maven dom?
Answered
hello, I'm trying to modify the pom.xml when creating new Project, I manage to get the pom model like this :
MavenDomProjectModel model = MavenDomUtil.getMavenDomProjectModel(project, pomFile);
but when I try to get the element of Build-Plugin-Configuration-Exclueds, there is no get-method to this element, here is the code:
public void addPomBuild(MavenDomBuild mavenDomBuild, DomManager domManager) {
MavenDomResources resources = mavenDomBuild.getResources();
MavenDomResource addResource = resources.addResource();
addResource.getDirectory().setStringValue("src/main/config");
addResource = resources.addResource();
addResource.getDirectory().setStringValue("src/main/resources");
MavenDomPlugins plugins = mavenDomBuild.getPlugins();
MavenDomPlugin addPlugin = plugins.addPlugin();
addPlugin.getGroupId().setStringValue("org.apac-he.maven.plugins");
addPlugin.getArtifactId().setStringValue("maven-jar-plugin");
addPlugin.getVersion().setStringValue("2.3.2");
MavenDomConfiguration configuration = addPlugin.getConfiguration();
Key<MavenDomExcludes> excludes = new Key<>("excludes");
configuration.putUserData(excludes, null);
configuration.getUserData(excludes);
}
How can I get the configuration's child element's implemention ? or should I create an implemention through some api ?
Please sign in to leave a comment.
I use the XmlTag to solve this. code like:
notify that the add method will change the xml immediately. So if you got a hierarchy like A->B->C, you have to add B->C first and then add A->B.