added module versioning support
This commit is contained in:
9
pom.xml
9
pom.xml
@@ -42,10 +42,16 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.8</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.8</maven.compiler.target>
|
||||||
<maven.version>3.6.3</maven.version>
|
<maven.version>3.9.0</maven.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<!-- needs to be explicitly included, due to v3.9.0 packaging bug -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
|
<artifactId>plexus-utils</artifactId>
|
||||||
|
<version>3.5.0</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-plugin-api</artifactId>
|
<artifactId>maven-plugin-api</artifactId>
|
||||||
@@ -66,6 +72,7 @@
|
|||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-core</artifactId>
|
<artifactId>maven-core</artifactId>
|
||||||
<version>${maven.version}</version>
|
<version>${maven.version}</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven.plugin-testing</groupId>
|
<groupId>org.apache.maven.plugin-testing</groupId>
|
||||||
|
@@ -18,6 +18,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.building.DefaultModelBuildingRequest;
|
import org.apache.maven.model.building.DefaultModelBuildingRequest;
|
||||||
import org.apache.maven.model.building.ModelBuildingException;
|
import org.apache.maven.model.building.ModelBuildingException;
|
||||||
@@ -53,6 +54,7 @@ public class ModuleArtifactExtractor {
|
|||||||
if (artifact.getProperty("id", null) != null) {
|
if (artifact.getProperty("id", null) != null) {
|
||||||
Module module = new Module();
|
Module module = new Module();
|
||||||
module.id = artifact.getProperty("id", null);
|
module.id = artifact.getProperty("id", null);
|
||||||
|
module.version = artifact.getProperty("version", null);
|
||||||
module.exportMetaInf = Boolean.parseBoolean(artifact.getProperty("exportMetaInf", Boolean.FALSE.toString()));
|
module.exportMetaInf = Boolean.parseBoolean(artifact.getProperty("exportMetaInf", Boolean.FALSE.toString()));
|
||||||
module.exportServices = Boolean.parseBoolean(artifact.getProperty("exportServices", Boolean.FALSE.toString()));
|
module.exportServices = Boolean.parseBoolean(artifact.getProperty("exportServices", Boolean.FALSE.toString()));
|
||||||
module.exportAnnotations = Boolean.parseBoolean(artifact.getProperty("exportAnnotations", Boolean.FALSE.toString()));
|
module.exportAnnotations = Boolean.parseBoolean(artifact.getProperty("exportAnnotations", Boolean.FALSE.toString()));
|
||||||
@@ -81,8 +83,11 @@ public class ModuleArtifactExtractor {
|
|||||||
this.getLog().debug("No 'wildfly.module.id' property; not a Wildfly module project; adding as module resource: " + artifact);
|
this.getLog().debug("No 'wildfly.module.id' property; not a Wildfly module project; adding as module resource: " + artifact);
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
|
String moduleVersion = StringUtils.trimToNull(modelProps.getProperty("wildfly.module.version"));
|
||||||
|
|
||||||
Module module = new Module();
|
Module module = new Module();
|
||||||
module.id = moduleId;
|
module.id = moduleId;
|
||||||
|
module.version = moduleVersion;
|
||||||
module.exportMetaInf = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.meta"));
|
module.exportMetaInf = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.meta"));
|
||||||
module.exportServices = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.services"));
|
module.exportServices = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.services"));
|
||||||
module.exportAnnotations = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.annotations"));
|
module.exportAnnotations = Boolean.parseBoolean(modelProps.getProperty("wildfly.module.annotations"));
|
||||||
@@ -90,6 +95,7 @@ public class ModuleArtifactExtractor {
|
|||||||
|
|
||||||
Map<String, String> props = new HashMap<>();
|
Map<String, String> props = new HashMap<>();
|
||||||
props.put("id", module.id);
|
props.put("id", module.id);
|
||||||
|
props.put("version", module.version);
|
||||||
props.put("exportMetaInf", String.valueOf(module.exportMetaInf));
|
props.put("exportMetaInf", String.valueOf(module.exportMetaInf));
|
||||||
props.put("exportServices", String.valueOf(module.exportServices));
|
props.put("exportServices", String.valueOf(module.exportServices));
|
||||||
props.put("exportAnnotations", String.valueOf(module.exportAnnotations));
|
props.put("exportAnnotations", String.valueOf(module.exportAnnotations));
|
||||||
|
@@ -34,8 +34,8 @@ import org.apache.maven.plugins.annotations.Parameter;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractDeploymentGoal extends AbstractGoal {
|
public abstract class AbstractDeploymentGoal extends AbstractGoal {
|
||||||
|
|
||||||
@Parameter( property = "wildfly.deployment.version", required = true, defaultValue = "1.3" )
|
@Parameter( required = true, defaultValue = "1.3" )
|
||||||
protected String deploymentVersion;
|
protected String deploymentSchemaVersion;
|
||||||
|
|
||||||
@Parameter( property = "wildfly.deployment.outputDirectory", required = true, defaultValue = "${project.build.directory}/${project.build.finalName}" )
|
@Parameter( property = "wildfly.deployment.outputDirectory", required = true, defaultValue = "${project.build.directory}/${project.build.finalName}" )
|
||||||
protected File outputDirectory;
|
protected File outputDirectory;
|
||||||
|
@@ -26,7 +26,10 @@ public abstract class AbstractModuleGoal extends AbstractGoal {
|
|||||||
@Parameter( property = "wildfly.module.id", required = true )
|
@Parameter( property = "wildfly.module.id", required = true )
|
||||||
protected String moduleId;
|
protected String moduleId;
|
||||||
|
|
||||||
@Parameter( property = "wildfly.module.version", required = true, defaultValue = "1.9" )
|
@Parameter( required = true, defaultValue = "1.9" )
|
||||||
|
protected String moduleSchemaVersion;
|
||||||
|
|
||||||
|
@Parameter( property = "wildfly.module.version", required = true, defaultValue = "main" )
|
||||||
protected String moduleVersion;
|
protected String moduleVersion;
|
||||||
|
|
||||||
@Parameter( property = "wildfly.module.outputDirectory", required = true, defaultValue = "${project.build.directory}/wildfly-module" )
|
@Parameter( property = "wildfly.module.outputDirectory", required = true, defaultValue = "${project.build.directory}/wildfly-module" )
|
||||||
@@ -41,12 +44,12 @@ public abstract class AbstractModuleGoal extends AbstractGoal {
|
|||||||
throw new IllegalStateException("The formulated directory contains a file: " + directory);
|
throw new IllegalStateException("The formulated directory contains a file: " + directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
File mainDirectory = new File(directory, "main");
|
File versionDirectory = new File(directory, this.moduleVersion);
|
||||||
if (mainDirectory.exists() && !mainDirectory.isDirectory())
|
if (versionDirectory.exists() && !versionDirectory.isDirectory())
|
||||||
throw new IllegalStateException("The formulated directory contains a file: " + directory);
|
throw new IllegalStateException("The formulated directory contains a file: " + directory);
|
||||||
|
|
||||||
mainDirectory.mkdirs();
|
versionDirectory.mkdirs();
|
||||||
return mainDirectory;
|
return versionDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -49,7 +49,7 @@ public class EarGoal extends AbstractDeploymentGoal {
|
|||||||
@Override
|
@Override
|
||||||
protected void executePre() throws MojoExecutionException {
|
protected void executePre() throws MojoExecutionException {
|
||||||
try {
|
try {
|
||||||
this.deploymentXmlBuilder = new DeploymentXmlBuilder(this.deploymentVersion);
|
this.deploymentXmlBuilder = new DeploymentXmlBuilder(this.deploymentSchemaVersion);
|
||||||
} catch (ParserConfigurationException pce) {
|
} catch (ParserConfigurationException pce) {
|
||||||
throw new MojoExecutionException("This should never happen", pce);
|
throw new MojoExecutionException("This should never happen", pce);
|
||||||
}
|
}
|
||||||
|
@@ -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.moduleVersion);
|
this.moduleXmlBuilder = new ModuleXmlBuilder(this.moduleId, this.moduleSchemaVersion);
|
||||||
} catch (ParserConfigurationException pce) {
|
} catch (ParserConfigurationException pce) {
|
||||||
throw new MojoExecutionException("This should never happen", pce);
|
throw new MojoExecutionException("This should never happen", pce);
|
||||||
}
|
}
|
||||||
|
@@ -67,7 +67,7 @@ public class WarGoal extends AbstractDeploymentGoal {
|
|||||||
@Override
|
@Override
|
||||||
protected void executePre() throws MojoExecutionException {
|
protected void executePre() throws MojoExecutionException {
|
||||||
try {
|
try {
|
||||||
this.deploymentXmlBuilder = new DeploymentXmlBuilder(this.deploymentVersion);
|
this.deploymentXmlBuilder = new DeploymentXmlBuilder(this.deploymentSchemaVersion);
|
||||||
} catch (ParserConfigurationException pce) {
|
} catch (ParserConfigurationException pce) {
|
||||||
throw new MojoExecutionException("This should never happen", pce);
|
throw new MojoExecutionException("This should never happen", pce);
|
||||||
}
|
}
|
||||||
|
@@ -17,6 +17,7 @@ package com.inteligr8.wildfly.maven.model;
|
|||||||
public class Module {
|
public class Module {
|
||||||
|
|
||||||
public String id;
|
public String id;
|
||||||
|
public String version;
|
||||||
public boolean export;
|
public boolean export;
|
||||||
public boolean exportMetaInf;
|
public boolean exportMetaInf;
|
||||||
public boolean exportServices;
|
public boolean exportServices;
|
||||||
|
@@ -54,8 +54,12 @@ public abstract class AbstractXmlBuilder {
|
|||||||
public abstract String getXmlFilename();
|
public abstract String getXmlFilename();
|
||||||
|
|
||||||
public void addDependency(Module module, boolean isDeployment) {
|
public void addDependency(Module module, boolean isDeployment) {
|
||||||
|
String name = module.id;
|
||||||
|
if (module.version != null)
|
||||||
|
name += ":" + module.version;
|
||||||
|
|
||||||
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
|
Element moduleElement = this.xmldoc.createElementNS(this.ns, "module");
|
||||||
moduleElement.setAttribute("name", module.id);
|
moduleElement.setAttribute("name", name);
|
||||||
if (module.export)
|
if (module.export)
|
||||||
moduleElement.setAttribute("export", Boolean.TRUE.toString());
|
moduleElement.setAttribute("export", Boolean.TRUE.toString());
|
||||||
if (isDeployment && module.exportMetaInf)
|
if (isDeployment && module.exportMetaInf)
|
||||||
|
Reference in New Issue
Block a user