mojohaus / mojohaus/exec-maven-plugin
addResourcesToClasspath adds src/main/resources to module path
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 191
- Forks
- 111
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 4
Description
Given a configuration like this:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>run-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>--module-path</argument>
<modulepath/>
<argument>${codegen.folder}/mypackage/GenerateMyCode.java</argument>
<argument>${project.basedir}</argument>
</arguments>
<longModulepath>false</longModulepath>
<classpathScope>provided</classpathScope>
<addResourcesToClasspath>true</addResourcesToClasspath>
<sourceRoot>${project.build.directory}/generated-sources/myproject</sourceRoot>
<useMavenLogger>true</useMavenLogger>
</configuration>
</plugin>
...the exec maven plugin adds the src/main/resources folder to the module path. At first I thought that made sense, but I quickly found out that it's actually not very helpful, as the src/main/resources folder typically does not contain a module-info.class file and is also not a jar, and therefor will be ignored by module resolution.
As a workaround, I now added
<argument>-classpath</argument>
<argument>${project.basedir}/src/main/resources</argument>
...which works. But perhaps it would be good to make this the default behavior, i.e., to always add it to the class path (even when using the module path for everything else).
Tested with exec-maven-plugin 3.6.3.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how addResourcesToClasspath contributes resources when the exec-maven-plugin configuration uses --module-path and modulepath. Verify the generated Java command separates src/main/resources onto the classpath while preserving other module-path entries; done means resources are available without requiring a module-info.class or JAR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100