CodexBloom - Programming Q&A Platform

Maven scenarios to execute plugin goals due to classpath issues in a multi-module project

πŸ‘€ Views: 0 πŸ’¬ Answers: 1 πŸ“… Created: 2025-07-07
maven multi-module plugin-development Java

I've been banging my head against this for hours. I'm relatively new to this, so bear with me. This might be a silly question, but I'm experiencing an scenario with my multi-module Maven project where certain plugin goals unexpected result to execute properly... Specifically, when I try to run `mvn clean install` on the parent module, I get the following behavior: ``` [behavior] Failed to execute goal com.mycompany.plugins:my-custom-plugin:1.0:my-goal (default-cli) on project my-parent: Execution default-cli of goal com.mycompany.plugins:my-custom-plugin:1.0:my-goal failed: Class not found: com.example.MyClass ``` The plugin is defined in the parent POM like this: ```xml <plugin> <groupId>com.mycompany.plugins</groupId> <artifactId>my-custom-plugin</artifactId> <version>1.0</version> <executions> <execution> <goals> <goal>my-goal</goal> </goals> </execution> </executions> </plugin> ``` The behavior suggests that a class required by the plugin is missing from the classpath during execution. I have ensured that the dependency for `com.example.MyClass` is declared in the child module's POM: ```xml <dependency> <groupId>com.example</groupId> <artifactId>my-library</artifactId> <version>2.3</version> </dependency> ``` This dependency is marked as provided scope in the child module, as it’s supposed to be provided by the server runtime. However, I suspect that this might be causing the class not to be available when the plugin runs. I've tried changing the scope to compile and running `mvn clean install`, but that doesn't seem to help either. I've also checked if the plugin itself is packaged correctly, and it appears to be fine. The `my-library` is included in the child module's package, but I'm unsure how to make it available to the plugin execution context. Is there a recommended approach to resolve this scenario? Should I be adjusting the way I specify dependencies in my multi-module setup, or is there something else that might be causing this classpath scenario? This is part of a larger web app I'm building. I'd really appreciate any guidance on this. Has anyone else encountered this? For context: I'm using Java on Debian. Is there a simpler solution I'm overlooking? This is for a web app running on Ubuntu 22.04. Could this be a known issue?