added module version to module.xml when applicable

This commit is contained in:
2023-02-19 10:56:10 -05:00
parent 8e761710ac
commit c6144b131d
3 changed files with 14 additions and 6 deletions

View File

@@ -47,7 +47,7 @@ public class GenerateModuleXmlGoal extends AbstractModuleGoal {
@Override @Override
protected void executePre() throws MojoExecutionException { protected void executePre() throws MojoExecutionException {
try { try {
this.moduleXmlBuilder = new ModuleXmlBuilder(this.moduleId, this.moduleSchemaVersion); this.moduleXmlBuilder = new ModuleXmlBuilder(this.moduleId, this.moduleSchemaVersion, this.moduleVersion);
} catch (ParserConfigurationException pce) { } catch (ParserConfigurationException pce) {
throw new MojoExecutionException("This should never happen", pce); throw new MojoExecutionException("This should never happen", pce);
} }

View File

@@ -24,8 +24,8 @@ import org.w3c.dom.Element;
*/ */
public class DeploymentXmlBuilder extends AbstractXmlBuilder { public class DeploymentXmlBuilder extends AbstractXmlBuilder {
public DeploymentXmlBuilder(String version) throws ParserConfigurationException { public DeploymentXmlBuilder(String schemaVersion) throws ParserConfigurationException {
super("urn:jboss:deployment-structure:" + version); super("urn:jboss:deployment-structure:" + schemaVersion);
Element deploymentElement = this.xmldoc.createElementNS(this.ns, "deployment"); Element deploymentElement = this.xmldoc.createElementNS(this.ns, "deployment");
deploymentElement.appendChild(this.dependenciesElement); deploymentElement.appendChild(this.dependenciesElement);

View File

@@ -28,13 +28,21 @@ public class ModuleXmlBuilder extends AbstractXmlBuilder {
private final Element resourcesElement; private final Element resourcesElement;
public ModuleXmlBuilder(String id, String version) throws ParserConfigurationException { public ModuleXmlBuilder(String id, String schemaVersion) throws ParserConfigurationException {
super("urn:jboss:module:" + version); this(id, schemaVersion, null);
}
public ModuleXmlBuilder(String id, String schemaVersion, String moduleVersion) throws ParserConfigurationException {
super("urn:jboss:module:" + schemaVersion);
this.resourcesElement = this.xmldoc.createElementNS(this.ns, "resources"); this.resourcesElement = this.xmldoc.createElementNS(this.ns, "resources");
String name = id;
if (moduleVersion != null)
name += ":" + moduleVersion;
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module"); Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
moduleElement.setAttribute("name", id); moduleElement.setAttribute("name", name);
moduleElement.appendChild(this.resourcesElement); moduleElement.appendChild(this.resourcesElement);
moduleElement.appendChild(this.dependenciesElement); moduleElement.appendChild(this.dependenciesElement);