Skip to content

Commit

Permalink
[issue-30] Using a descriptor file to indicate the module dependencie…
Browse files Browse the repository at this point in the history
…s need to be added to the module deployment
  • Loading branch information
gaol committed Nov 5, 2024
1 parent 15bf6e0 commit fcf7e83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<module name="org.wildfly.subsystem"/>
<module name="org.jboss.as.weld.common"/>
<module name="org.jboss.jandex"/>
<module name="org.jboss.vfs"/>
<module name="io.vertx.core" />
<module name="io.smallrye.common.annotation" />
<module name="io.smallrye.reactive.mutiny.vertx-core" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
*/
package org.wildfly.extension.vertx.processors;

import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.Phase;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.as.server.deployment.module.ResourceRoot;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.DotName;
import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.Type;
import org.jboss.vfs.VirtualFile;

import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -49,11 +52,23 @@ public class VerticleDeploymentMarkerProcessor implements DeploymentUnitProcesso
public void deploy(DeploymentPhaseContext context) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = context.getDeploymentUnit();
final CompositeIndex index = deploymentUnit.getAttachment(COMPOSITE_ANNOTATION_INDEX);
if (annotated(index, DOT_NAME_INJECTION)) {
if (annotated(index, DOT_NAME_INJECTION) || descriptorExists(deploymentUnit)) {
VertxDeploymentAttachment.attachVertxDeployments(deploymentUnit);
}
}

private boolean descriptorExists(DeploymentUnit deploymentUnit) {
ResourceRoot deploymentRoot = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT);
if (deploymentRoot != null && deploymentRoot.getRoot() != null) {
VirtualFile vertxDeploymentFile = deploymentRoot.getRoot().getChild("WEB-INF/vertx.json");
if (vertxDeploymentFile == null || !vertxDeploymentFile.exists()) {
vertxDeploymentFile = deploymentRoot.getRoot().getChild("META-INF/vertx.json");
}
return vertxDeploymentFile != null && vertxDeploymentFile.exists() && vertxDeploymentFile.isFile();
}
return false;
}

private boolean annotated(CompositeIndex index, DotName injectAnnotationName) {
final List<AnnotationInstance> resourceAnnotations = index.getAnnotations(injectAnnotationName);
for (AnnotationInstance annotation : resourceAnnotations) {
Expand Down

0 comments on commit fcf7e83

Please sign in to comment.