You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Steinar Bang <sb...@dod.no> on 2025/05/02 11:25:23 UTC

exec:java of exec-maven-plugin requires compile scope project dependency to run

Platform: debian 12.10 "bookworm", amd64, java 21.0.4, maven 3.8.7, exec-maven-plugin 3.5.0

If I add the jar file containing the mainClass as a compile scope
dependency on the project:
 https://gist.github.com/steinarb/d177a1c1146fedf374608390fbbe4841#file-pom-xml-L119

Then this exec-maven-plugin runs (and does its thing, which is convert
an XSD schema to a Relax-NG XML Notation schema):
 https://gist.github.com/steinarb/d177a1c1146fedf374608390fbbe4841#file-pom-xml-L168

But having a compile scope dependency on the project adds
msg-rngconverter as a transitive dependency on the project, and that has
many undesirable effects for me (specifically it becomes a runtime
dependency for the OSGi bundle the pom file is a part of).

So I tried reducing the scope to test, which the exec-maven-plugn
documentation says should be sufficient:
 https://www.mojohaus.org/exec-maven-plugin/java-mojo.html

But using test scope for the dependenct gives me this error:
 https://gist.github.com/steinarb/d0abfd4c8497ae5c6b5ef4c70001fa7e#file-gistfile1-txt-L25

So I tried following this documentation
 https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-using-plugin-dependencies.html
and removed the project dependency and changed the config to this:
 https://gist.github.com/steinarb/7521ccc87c2e843aa7ee80f23df24911#file-pom-xml-L163

But that gets the same build error as test scope dependency:
 https://gist.github.com/steinarb/956af653af12919e256593ab4688ba98#file-gistfile1-txt-L21

Ideas? Tips? Something wrong in my config?

Thanks!


- Steinar


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: exec:java of exec-maven-plugin requires compile scope project dependency to run

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Steinar Bang <sb...@dod.no>:
>>>>> Stanimir Stamenkov <s7...@aim.com.INVALID>:

>> Did you have <classpathScope>test</classpathScope> in the exec plugin
>> configuration?

> Ah, no. I did not. I will try with that in place (and a test scope
> project dependency).

Using <classpathScope>test</classpathScope> and <scope>test</scope> on
the project dependency worked:
 https://gist.github.com/steinarb/e63a8219cb49ffadb43e9a5d5d3baf7c#file-pom-xml-L119
 https://gist.github.com/steinarb/e63a8219cb49ffadb43e9a5d5d3baf7c#file-pom-xml-L174

Thanks!


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: exec:java of exec-maven-plugin requires compile scope project dependency to run

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Stanimir Stamenkov <s7...@aim.com.INVALID>:

> O.k.  Looking back I couldn't see any of the gists with a test scope
> "msv-rngconverter" – am I missing it?

No that's correct. I did not make a gist of that, since what I tried was
just the same as the compile scope one, with <scope> of the depedency
changed.

> Did you have <classpathScope>test</classpathScope> in the exec plugin
> configuration?

Ah, no. I did not. I will try with that in place (and a test scope
project dependency).

> You wrote it is working when "msv-rngconverter" is a compile project
> dependency.

Yes, that's the only thing that has worked for me so far.

> Sorry, I'm not able to help more – just making sure you're not missing
> some more obvious detail.

Thanks! You have given me something new to try and I will try that and
report back.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: exec:java of exec-maven-plugin requires compile scope project dependency to run

Posted by Stanimir Stamenkov <s7...@aim.com.INVALID>.
Tue, 06 May 2025 17:01:02 +0200, /Steinar Bang/:

>> Does it work adding the dependency to the plugin dependencies, instead?
> 
> No, that gave me the same error was when changing the scope to test:
>   https://gist.github.com/steinarb/7521ccc87c2e843aa7ee80f23df24911#file-pom-xml-L163
> 
> Ie. unable to find the mainClass specified.

O.k.  Looking back I couldn't see any of the gists with a test scope 
"msv-rngconverter" – am I missing it?  Did you have 
<classpathScope>test</classpathScope> in the exec plugin configuration? 
You wrote it is working when "msv-rngconverter" is a compile project 
dependency.

Sorry, I'm not able to help more – just making sure you're not missing 
some more obvious detail.

-- 
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: exec:java of exec-maven-plugin requires compile scope project dependency to run

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Stanimir Stamenkov <s7...@aim.com.INVALID>:

> Does it work adding the dependency to the plugin dependencies, instead?

>     <plugin>
>         <groupId>org.codehaus.mojo</groupId>
>         <artifactId>exec-maven-plugin</artifactId>
>         <version>3.5.0</version>
>         <dependencies>
>             <dependency>
>                 <groupId>net.java.dev.msv</groupId>
>                 <artifactId>msv-rngconverter</artifactId>
>                 <version>2022.7</version>
>             </dependency>
>         </dependencies>
>         <executions>
>             ...
>         </executions>
>     </plugin>

No, that gave me the same error was when changing the scope to test:
 https://gist.github.com/steinarb/7521ccc87c2e843aa7ee80f23df24911#file-pom-xml-L163

Ie. unable to find the mainClass specified.

I have tried both with just adding the dependency as in your example, as
well as with adding executableDependency in the above example (with the
executableDependency it was necessary to have the dependency on the top
level to set the <version>, so I know that something was picked up).


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: exec:java of exec-maven-plugin requires compile scope project dependency to run

Posted by Stanimir Stamenkov <s7...@aim.com.INVALID>.
[Re-sending from my subscribed address.]

Fri, 02 May 2025 13:25:23 +0200, /Steinar Bang/:

> Platform: debian 12.10 "bookworm", amd64, java 21.0.4, maven 3.8.7, exec-maven-plugin 3.5.0
> 
> If I add the jar file containing the mainClass as a compile scope 
> dependency on the project:
>   https://gist.github.com/steinarb/d177a1c1146fedf374608390fbbe4841#file-pom-xml-L119
> 
> Then this exec-maven-plugin runs (and does its thing, which is convert 
> an XSD schema to a Relax-NG XML Notation schema):
>   https://gist.github.com/steinarb/d177a1c1146fedf374608390fbbe4841#file-pom-xml-L168
> 
> But having a compile scope dependency on the project adds 
> msg-rngconverter as a transitive dependency on the project
> [...]
> 
> Ideas? Tips? Something wrong in my config?

Does it work adding the dependency to the plugin dependencies, instead?

     <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>exec-maven-plugin</artifactId>
         <version>3.5.0</version>
         <dependencies>
             <dependency>
                 <groupId>net.java.dev.msv</groupId>
                 <artifactId>msv-rngconverter</artifactId>
                 <version>2022.7</version>
             </dependency>
         </dependencies>
         <executions>
             ...
         </executions>
     </plugin>

-- 
Stanimir

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org