Skip to content

addResourcesToClasspath adds src/main/resources to module path #534

Closed

Description

@inaldt

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.

Activity

  1. added
    enhancement
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions