Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module path can't be defined #335

Open
Lawyer1990 opened this issue Sep 1, 2022 · 1 comment
Open

Module path can't be defined #335

Lawyer1990 opened this issue Sep 1, 2022 · 1 comment

Comments

@Lawyer1990
Copy link

Lawyer1990 commented Sep 1, 2022

Hello!
The problem is in module path. When plugin run main class, which is in module it defines the root path. Therefore, I can't use files in module because the path there isn't correct.
`
Main pom.xml


4.0.0

<groupId>org.example</groupId>
<artifactId>RunTestId</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<modules>
    <module>ModuleOne</module>
</modules>

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.6.1</version>
    </dependency>
    <dependency>
        <groupId>org.burningwave</groupId>
        <artifactId>core</artifactId>
        <version>12.59.0</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <skip>true</skip>
                    <mainClass>RunTests</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

----------------------------- module pom.xml -----------
`
RunTestId
org.example
1.0-SNAPSHOT

4.0.0

<artifactId>ModuleOne</artifactId>

<properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
</properties>
<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <configuration>
                    <skip>false</skip>
                    <mainClass>RunTestsModule</mainClass>
                    <classpathScope>test</classpathScope>
                    <cleanupDaemonThreads>false</cleanupDaemonThreads>
                    <workingDirectory>ModuleOne</workingDirectory>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>`

Actual result:
The path file in module is C:/RunTests/src/main/resources/text.txt

Expected result:
The path file in module is C:/RunTests/ModuleOne/src/main/resources/text.txt

@stanio
Copy link

stanio commented Nov 21, 2023

Not sure if it is possible, but I would like the possibility to define a specific execution ID in a submodule and then target that from the command line:

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>my-target</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>...</mainClass>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
> mvn exec:java@my-target

Currently exec:java is attempted for all modules, incl. the root reactor, and generally fails for not having mainClass defined:

The parameters 'mainClass' for goal org.codehaus.mojo:exec-maven-plugin:3.1.1:java are missing or invalid

Even when I define default <skip>true</skip> for my my-target execution in the root POM (then override for the submodule execution):

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>my-target</id>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

it fails for not having mainClass defined. I've worked it around by defining an empty default in the root POM:

    <properties>
        <exec.mainClass />
    </properties>

This could result in a suboptimal experience with other exec:java usages – confusing error message with mainClass really not defined.

See also:

stanio added a commit to stanio/xbrz-java that referenced this issue Nov 21, 2023
    mvn package -DskipTests exec:java@demo
    mvn package -DskipTests exec:java@demo -Dexec.args=write_obj

See also:

-   Plugin Goal Invocation from Command Line
    <https://maven.apache.org/docs/3.3.1/release-notes.html#plugin-goal-invocation-from-command-line>
-   mojohaus/exec-maven-plugin#335
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants