weird error - property substitution not working

2024-05-09 Thread Siddharth Jain
Hello,

I have a property defined in parent pom:

1.17.3

I have project A that has following:


com.microsoft.onnxruntime
onnxruntime
${onnxruntime.version}


it installs fine.

I have project B that has following:


com.example
projectA
${project.version}
test


this give me this bizarre error on test-compile:

Could not resolve dependencies for project
xxx:xxx-xxx-xxx:jar:1.0.0-SNAPSHOT: The following artifacts could not be
resolved: com.microsoft.onnxruntime:onnxruntime_gpu:jar:${onnxruntime.version}
(absent), com.microsoft.onnxruntime:onnxruntime:jar:${onnxruntime.version}
(absent): Could not find artifact
com.microsoft.onnxruntime:onnxruntime_gpu:jar:${onnxruntime.version} in
central (https://repo.maven.apache.org/maven2)

it does not substitute ${onnxruntime.version} with the value from
parent pom. how can I fix this? I have never seen anything like this before.


Re: How does maven resolve inter-module dependencies in a multi-module build?

2024-02-15 Thread Siddharth Jain
thanks all. this is helpful info to know.

On Thu, Feb 15, 2024 at 1:22 PM Tamás Cservenák  wrote:

> Howdy,
>
> usually you should consider maven build (in case maven, session == cli
> invocation) as this hierarchy:
> * remote repositories:
> * * local repository:
> * * * session
>
> Maven will prefer things "most specific" if present:
> - if is in reactor (current session), will use that
> - if is in local repository (and all things like expiration etc passes)
> will use that
> - otherwise it goes to remote
>
> This also implies if you want to build A and then B from _same multi module
> build_ (that has let's assume modules A, B and C), ideally you
> * maven install all the reactor
> * maven -f A compile
> etc
>
>
> On Thu, Feb 15, 2024 at 9:28 PM Francois Marot 
> wrote:
>
> > to add on Joseph answer: if you are in the B directory, then only B is in
> > the reactor (more or less meaning "the list of project being built by
> this
> > Maven invocation").
> > My rule of thumb is to never do that and always run from the root. If you
> > want to speedup the build and you know that only B has been modified, you
> > can use maven options such as:
> >
> > - mvn test -pl :B // it will only build/test the B module
> > - mvn test -pl :B -am// it will build B and all the modules B
> > depends onto
> > - mvn test -rf :B// it resumes the build from B in case B's
> > tests failed , so it will also build modules after B
> >
> > you can note that I add a semi-column before the module name because in
> > case the module is a sub-module (or sub-sub-sub...module), not directly
> at
> > the parent's root, then it is required.
> > Hope this helps
> >
> >
> > Le jeu. 15 févr. 2024 à 20:55, Joseph Leonard <
> > joseph.leon...@alfasystems.com> a écrit :
> >
> > > Builds in the reactor are always favoured over the m2 repo because the
> > > builds in the reactor will be up-to-date whereas the jar in the repo
> may
> > be
> > > out of date.
> > >
> > > If you run mvn compile in directory B then you will not be running a
> > multi
> > > module build - and therefore module A will not be in the reactor. This
> is
> > > why the m2 repo will always be used for module A in this scenario.
> > >
> > > Joe
> > >
> > > -Original Message-
> > > From: Siddharth Jain 
> > > Sent: Thursday, February 15, 2024 7:50 PM
> > > To: Maven Users List 
> > > Subject: Re: How does maven resolve inter-module dependencies in a
> > > multi-module build?
> > >
> > > External Email: Please be vigilant and check the contents and source
> for
> > > signs of malicious activity.
> > >
> > > thanks Joe. but then if classes are available both in the target
> > directory
> > > of module A as well as a jar file in M2 repository which takes
> > precedence?
> > >
> > > also i have noticed that while running mvn compile from the root works,
> > > running mvn compile from the directory of B does not pick up classes
> from
> > > A's target directory. it only picks up from M2 repo in that case.
> > >
> > > On Thu, Feb 15, 2024 at 11:28 AM Joseph Leonard <
> > > joseph.leon...@alfasystems.com> wrote:
> > >
> > > > Hi Sid,
> > > > It will resolve the classes directory of module A that will have been
> > > > populated during module A's 'compile' build.
> > > > Joe
> > > >
> > > > On 2024/02/15 17:50:44 Siddharth Jain wrote:
> > > > > Hello,
> > > > >
> > > > > I am working on a multi-module Maven build. e.g., I have a root
> > > > > directory containing 3 sub-projects A, B, C and a parent pom
> defined
> > > > > in the root directory. I notice that I can run mvn compile from the
> > > > > root directory
> > > > and
> > > > > it will build the 3 projects. The projects may have
> > > > > inter-dependencies e.g., B depends on A and let's say C depends on
> > > both A and B.
> > > > >
> > > > > My question is while building B how does maven locate the compiled
> > > > > code
> > > > of
> > > > > A (the dependency) since maven compile by itself does not install
> > > > > the
> > > > built
> > > > > artifact into M2 repository?
> > > > >
> > > > > Sid
> > > > >
> > > >
> > >
> >
>


Re: How does maven resolve inter-module dependencies in a multi-module build?

2024-02-15 Thread Siddharth Jain
thanks Joe. but then if classes are available both in the target directory
of module A as well as a jar file in M2 repository which takes precedence?

also i have noticed that while running mvn compile from the root works,
running mvn compile from the directory of B does not pick up classes from
A's target directory. it only picks up from M2 repo in that case.

On Thu, Feb 15, 2024 at 11:28 AM Joseph Leonard <
joseph.leon...@alfasystems.com> wrote:

> Hi Sid,
> It will resolve the classes directory of module A that will have been
> populated during module A's 'compile' build.
> Joe
>
> On 2024/02/15 17:50:44 Siddharth Jain wrote:
> > Hello,
> >
> > I am working on a multi-module Maven build. e.g., I have a root directory
> > containing 3 sub-projects A, B, C and a parent pom defined in the root
> > directory. I notice that I can run mvn compile from the root directory
> and
> > it will build the 3 projects. The projects may have inter-dependencies
> > e.g., B depends on A and let's say C depends on both A and B.
> >
> > My question is while building B how does maven locate the compiled code
> of
> > A (the dependency) since maven compile by itself does not install the
> built
> > artifact into M2 repository?
> >
> > Sid
> >
>


How does maven resolve inter-module dependencies in a multi-module build?

2024-02-15 Thread Siddharth Jain
Hello,

I am working on a multi-module Maven build. e.g., I have a root directory
containing 3 sub-projects A, B, C and a parent pom defined in the root
directory. I notice that I can run mvn compile from the root directory and
it will build the 3 projects. The projects may have inter-dependencies
e.g., B depends on A and let's say C depends on both A and B.

My question is while building B how does maven locate the compiled code of
A (the dependency) since maven compile by itself does not install the built
artifact into M2 repository?

Sid


Re: MAVEN_OPTS on Windows does not behave correctly

2024-01-29 Thread Siddharth Jain
Thanks Alex. Removing the double-quotes worked.

On Sun, Jan 28, 2024 at 4:40 PM Alexander Kriegisch <
alexan...@kriegisch.name> wrote:

> It is not a Maven problem, but a shell usage one.
>
> UNIX-like shells like Git Bash:
> export MAVEN_OPTS="-Doption1=value1 -Doption2=value2"
>
> Windows Cmd.exe:
> set MAVEN_OPTS=-Doption1=value1 -Doption2=value2
>
> Just do not use the double quotes there. They are used for arguments
> which actually contain spaces.
>
> --
> Alexander Kriegisch
> https://scrum-master.de
>
>
> Siddharth Jain schrieb am 29.01.2024 06:37 (GMT +07:00):
>
> > Hello,
> >
> > I have:
> >>mvn -v
> > Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
> > Maven home: C:\Program Files\apache-maven-3.9.6
> > Java version: 21.0.2, vendor: Oracle Corporation, runtime: C:\Program
> > Files\jdk-21.0.2
> > Default locale: en_US, platform encoding: UTF-8
> > OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"
> >
> > When I try to run a program as follows:
> > set MAVEN_OPTS="-Doption1=value1 -Doption2=value2"
> > mvn exec:java -Dexec.mainClass=com.example.Foo
> >
> > Expected:
> >
> > Two JVM options should be set as follows:
> >
> >- option1=value1
> >- option2=value2
> >
> >
> > Observed:
> >
> > One JVM option is set as follows:
> >
> >-  option1=value1 -Doption2=value2
> >
> > does anyone reproduce this? is there any workaround for this?
> >
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


MAVEN_OPTS on Windows does not behave correctly

2024-01-28 Thread Siddharth Jain
Hello,

I have:
>mvn -v
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: C:\Program Files\apache-maven-3.9.6
Java version: 21.0.2, vendor: Oracle Corporation, runtime: C:\Program
Files\jdk-21.0.2
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 11", version: "10.0", arch: "amd64", family: "windows"

When I try to run a program as follows:
set MAVEN_OPTS="-Doption1=value1 -Doption2=value2"
mvn exec:java -Dexec.mainClass=com.example.Foo

Expected:

Two JVM options should be set as follows:

   - option1=value1
   - option2=value2


Observed:

One JVM option is set as follows:

   -  option1=value1 -Doption2=value2

does anyone reproduce this? is there any workaround for this?


how to use maven exec plugin with modules?

2023-10-18 Thread Siddharth Jain
I am developing an application using Java modules. when i try to run it
using exec:java it seems the exec-plugin adds all dependencies to the
classpath. i verified this using the -X option. the behavior expected is
the modularized dependencies should be added to the module path. i am using
plugin version 3.1.0.

how its impacting me: I am using ServiceLoader to load some services and it
cannot find any services because the dependencies end up on classpath
instead of modulepath.

according to this post:
https://github.com/mojohaus/exec-maven-plugin/issues/90

the plugin should support modulepath but it does not seem like so.

I also tried using exec:exec with -Dexec.args="%modulepath" as described
here

but that gives exception.

also read this:
https://stackoverflow.com/questions/70250835/maven-exec-plugins-modulepath-does-not-appear-to-work

can someone explain me how to run a modularized application using the exec
plugin?

also related: https://issues.apache.org/jira/browse/MNG-7855 (this is for
the compiler plugin but mentioning fyi)


Re: maven-compiler-plugin adds all dependencies to the module-path when executing test-compile when it shouldn't

2023-10-12 Thread Siddharth Jain
Hi Martin,

Thanks for your response. please see inline:


> Which approach did you choose for the tests? One approach is to
> duplicate the module-info.java file in the test directory [1], but this
> is not the only way.
>

Yes, that is the approach I took. Basically, the test code is put in its
own module and namespace (package name) with dependencies on the main
module and junit etc.

>
>
> > I see during the test-compile phase the plugin is putting all the
> > dependencies on the module-path whereas during the main compilation it
> > only puts those dependencies on the module-path that are declared in
> > module-info.java; the rest are on the classpath (which is the correct
> > behavior).
> >
> Indeed this is the correct behaviour in a lot of cases, but not always.
> Sometime we really want non-modular dependencies to nevertheless be on
> the module-path. So we need a way to give control to developers about
> which dependencies to put on the module-path versus class-path. This is
> the topic of JIRA issue MNG-7855 [2]. We had a little bit of discussion
> about that during the "Community Over Code" meeting (formerly
> "ApacheCon") that just finished two days ago. A proposal was to create a
> wiki page for designing a short-term fix.
>

IIUC, this is a separate issue. At minimum we need to make the behavior of
compile vs. testCompile consistent. Currently it is not. To repeat: I see
during the test-compile phase the plugin is putting all the dependencies on
the module-path whereas during the main compilation it only puts those
dependencies on the module-path that are declared in module-info.java; the
rest are on the classpath (which is the correct behavior).

>
>
> > Is this a known issue? Is there any fix? Without it, how can we use JPMS?
> >
> I think that MNG-7855 is a blocker issue. Without a fix, doing gradual
> migration to JPMS with Maven (i.e. being in a situation where we have a
> mix of JPMS and non-JPMS modules) is difficult except in some special
> cases.
>
>  Martin
>
> [1]
> https://maven.apache.org/surefire/maven-surefire-plugin/examples/jpms.html
> [2]https://issues.apache.org/jira/browse/MNG-7855
>


maven-compiler-plugin adds all dependencies to the module-path when executing test-compile when it shouldn't

2023-10-12 Thread Siddharth Jain
Hello,

I am building a project that uses modules (JPMS)

I have observed the maven-compiler-plugin behaves differently for test vs.
main compilation. I have a project and the main compilation works but the
test code does not compile. when i looked at the logs, i see during the
test-compile phase the plugin is putting all the dependencies on the
module-path whereas during the main compilation it only puts those
dependencies on the module-path that are declared in module-info.java; the
rest are on the classpath (which is the correct behavior). I am using
latest version of the plugin 3.11.0. Is this a known issue? Is there any
fix? Without it, how can we use JPMS?

S.


maven-javadoc-plugin cannot find symbol in another module while building a multi-module project

2023-10-03 Thread Siddharth Jain
Hello,

I am compiling a multi-module project with Maven. When I run maven clean
install the compilation succeeds on a submodule but the javadoc plugin
throws error while trying to generate javadoc for the submodule that has
dependency on another submodule. My parent pom has:


org.apache.maven.plugins
maven-javadoc-plugin
3.5.0

none
true
false
none
20



attach-javadocs

jar





I get an error that looks like:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-javadoc-plugin:3.5.0:jar (attach-javadocs)
on project yyy-core: MavenReportException: Error while generating Javadoc:
[ERROR] Exit code: 1
[ERROR] /Users/xxx/code/yyy/core/src/main/java/yyy/impl/v1/zzz.java:6:
error: cannot find symbol
[ERROR] public static aaa create() {
[ERROR] ^
[ERROR] symbol: class aaa
[ERROR] location: class zzz
[ERROR] /Users/xxx/code/yyy/core/src/main/java/yyy/impl/v1/zzz.java:3:
error: package yyy.core.api does not exist
[ERROR] import yyy.core.api.*;

What am I doing wrong here and how can I fix it? Thanks.

S.


question on maven dependency scope

2023-10-01 Thread Siddharth Jain
hello.

https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope

   - *provided*
   This is much like compile, but indicates you expect the JDK or a
   container to provide the dependency at runtime. For example, when building
   a web application for the Java Enterprise Edition, you would set the
   dependency on the Servlet API and related Java EE APIs to scope
provided because
   the web container provides those classes. A dependency with this scope is
   added to the classpath used for compilation and test, but not the runtime
   classpath. It is not transitive.

what does the runtime classpath mean here? does it mean the classpath when
running the application using the maven-exec-plugin? does it make any
difference to the maven-assembly-plugin whether scope is provided or not?

context: I am trying to build an application with different levels of
subscription. there will be a common core but i will provide premium
features as addons. so I want to treat them as dependencies with
provided scope in the core and package the application differently
depending on the customer's subscription level. as the packing into a jar
is done with the assembly plugin, I would like to know whether it makes any
difference to the assembly plugin whether the scope is provided or not.

if not, what is the best way to achieve my goal?

thanks.

S.


How to use Vector API with Maven Exec Plugin

2023-08-21 Thread Siddharth Jain
>
>
> Hello,


How can I use the Vector API with maven exec plugin? I compiled my project
with these settings and it worked fine:

org.apache.maven.plugins
maven-compiler-plugin

20
20

--enable-preview
--add-modules
jdk.incubator.vector


20




But when I try to run it using mvn exec:java I get this error:
java.lang.ClassNotFoundException: jdk.incubator.vector.Vector

My exec plugin configuration looks like this: I have tried many variations
but nothing seems to work. Please help!

org.codehaus.mojo
exec-maven-plugin
3.1.0



java




com.mycompany.app.App

--enable-preview 
--add-modules jdk.incubator.vector 





Re: Re: How to add a library to the classpath

2023-01-06 Thread Siddharth Jain
I think as a user of maven the expected behavior (ask) is for the
additionalClasspathElements to support a user.property which it doesn't
currently. would be a good feature to add to maven exec plugin i believe.
thanks again to all for the help.

On Fri, Jan 6, 2023 at 9:33 AM Delany  wrote:

> The way to separate multiple classpaths is to have multiple poms. You can
> make another child module (so that it inherits the base dependencies) and
> add the extra dependencies and the exec:java to THAT module.
> Delany
>
> On Fri, 6 Jan 2023 at 18:55, Siddharth Jain  wrote:
>
> > Hi All,
> >
> > Thanks for your help. To keep the discussion focused, the ask is how to
> add
> > additional dependencies/jars to the classpath when running a program
> using
> > mvn exec:java and from what i understand it is not possible.
> >
> > I am using mvn dependency:build-classpath to get the full CP and then
> > augment it with additional jars and pass it to java (instead of
> > maven exec:java) as workaround. but that is not the question being asked.
> >
> > Sid
> >
> > On Fri, Jan 6, 2023 at 5:19 AM Eric Bresie  wrote:
> >
> > >
> > > Would using basic batch/shell specifying the dependencies with the Java
> > > classpath argument (without maven run) and the main runtime class be
> the
> > > alternative?
> > >
> > > Kind of a side question…when building with maven does it automate the
> > > addition dependencies within the META-INF/MANIFEST.MF (1) embedded
> within
> > > the jar?
> > >
> > > Eric Bresie
> > > ebre...@gmail.com (mailto:ebre...@gmail.com)
> > >
> > > References (1)
> > >
> https://stackoverflow.com/questions/70216/whats-the-purpose-of-meta-inf
> > > > On January 6, 2023 at 2:35:16 AM CST, Mantas Gridinas <
> > > mgridi...@gmail.com (mailto:mgridi...@gmail.com)> wrote:
> > > > I'm confused. Why would your users write additional entries intk your
> > > pom?
> > > >
> > > > On Fri, Jan 6, 2023, 10:33 (x-apple-data-detectors://4) Delany <
> > > delany.middle...@gmail.com (mailto:delany.middle...@gmail.com)> wrote:
> > > >
> > > > > Could this help?
> > > > >
> > > > >
> > >
> >
> https://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html
> > > > > Delany
> > > > >
> > > > > On Fri, 6 Jan 2023 at 05:30, Siddharth Jain  > > (mailto:siddh...@gmail.com)> wrote:
> > > > >
> > > > > > thanks. unfortunately this is exactly what i don't want to do. i
> am
> > > > > looking
> > > > > > for a command line solution. i don't want my users to have to
> > write a
> > > > > > pom.xml to add additional dependencies to the classpath.
> > > > > >
> > > > > > On Thu, Jan 5, 2023 at 5:16 PM Greg Chabala <
> > greg.chab...@gmail.com
> > > (mailto:greg.chab...@gmail.com)>
> > > > > > wrote:
> > > > > >
> > > > > > > Try searching for an example:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > >
> >
> https://github.com/search?l=Maven+POM&q=additionalClasspathElements&type=Code
> > > > > > >
> > > > > > > On Thu, Jan 5, 2023 at 7:11 PM Siddharth Jain <
> > siddh...@gmail.com
> > > (mailto:siddh...@gmail.com)>
> > > > > > wrote:
> > > > > > >
> > > > > > > > thanks. how do i separate multiple classpaths? tried : and ,
> > and
> > > none
> > > > > > of
> > > > > > > > them work.
> > > > > > > >
> > > > > > > > On Thu, Jan 5, 2023 at 3:58 PM Laird Nelson <
> > ljnel...@gmail.com
> > > (mailto:ljnel...@gmail.com)>
> > > > > > wrote:
> > > > > > > >
> > > > > > > > > On Thu, Jan 5, 2023 at 3:20 PM Siddharth Jain <
> > > siddh...@gmail.com (mailto:siddh...@gmail.com)>
> > > > > > > > wrote:
> > > > > > > > >
> > > > > > > > > > I am using mvn exec:java to run a program. […] I want to
> > add
> > > some
> > > > > > > more
> > > > > > > > > > libraries that I have
> > > > > > > > > > installed in M2 repository to the classpath at runtime
> and
> > I
> > > do
> > > > > NOT
> > > > > > > > want
> > > > > > > > > to
> > > > > > > > > > list them in the project's pom.xml. How can I do this? I
> > > tried
> > > > > > > > searching
> > > > > > > > > > online but could not find an answer.
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > The documentation for the exec-maven-plugin's java goal
> > > contains
> > > > > > this:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > >
> >
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#additionalClasspathElements
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > >
> >
>


Re: Re: How to add a library to the classpath

2023-01-06 Thread Siddharth Jain
Hi All,

Thanks for your help. To keep the discussion focused, the ask is how to add
additional dependencies/jars to the classpath when running a program using
mvn exec:java and from what i understand it is not possible.

I am using mvn dependency:build-classpath to get the full CP and then
augment it with additional jars and pass it to java (instead of
maven exec:java) as workaround. but that is not the question being asked.

Sid

On Fri, Jan 6, 2023 at 5:19 AM Eric Bresie  wrote:

>
> Would using basic batch/shell specifying the dependencies with the Java
> classpath argument (without maven run) and the main runtime class be the
> alternative?
>
> Kind of a side question…when building with maven does it automate the
> addition dependencies within the META-INF/MANIFEST.MF (1) embedded within
> the jar?
>
> Eric Bresie
> ebre...@gmail.com (mailto:ebre...@gmail.com)
>
> References (1)
> https://stackoverflow.com/questions/70216/whats-the-purpose-of-meta-inf
> > On January 6, 2023 at 2:35:16 AM CST, Mantas Gridinas <
> mgridi...@gmail.com (mailto:mgridi...@gmail.com)> wrote:
> > I'm confused. Why would your users write additional entries intk your
> pom?
> >
> > On Fri, Jan 6, 2023, 10:33 (x-apple-data-detectors://4) Delany <
> delany.middle...@gmail.com (mailto:delany.middle...@gmail.com)> wrote:
> >
> > > Could this help?
> > >
> > >
> https://maven.apache.org/plugins/maven-dependency-plugin/build-classpath-mojo.html
> > > Delany
> > >
> > > On Fri, 6 Jan 2023 at 05:30, Siddharth Jain  (mailto:siddh...@gmail.com)> wrote:
> > >
> > > > thanks. unfortunately this is exactly what i don't want to do. i am
> > > looking
> > > > for a command line solution. i don't want my users to have to write a
> > > > pom.xml to add additional dependencies to the classpath.
> > > >
> > > > On Thu, Jan 5, 2023 at 5:16 PM Greg Chabala  (mailto:greg.chab...@gmail.com)>
> > > > wrote:
> > > >
> > > > > Try searching for an example:
> > > > >
> > > > >
> > > >
> > >
> https://github.com/search?l=Maven+POM&q=additionalClasspathElements&type=Code
> > > > >
> > > > > On Thu, Jan 5, 2023 at 7:11 PM Siddharth Jain  (mailto:siddh...@gmail.com)>
> > > > wrote:
> > > > >
> > > > > > thanks. how do i separate multiple classpaths? tried : and , and
> none
> > > > of
> > > > > > them work.
> > > > > >
> > > > > > On Thu, Jan 5, 2023 at 3:58 PM Laird Nelson  (mailto:ljnel...@gmail.com)>
> > > > wrote:
> > > > > >
> > > > > > > On Thu, Jan 5, 2023 at 3:20 PM Siddharth Jain <
> siddh...@gmail.com (mailto:siddh...@gmail.com)>
> > > > > > wrote:
> > > > > > >
> > > > > > > > I am using mvn exec:java to run a program. […] I want to add
> some
> > > > > more
> > > > > > > > libraries that I have
> > > > > > > > installed in M2 repository to the classpath at runtime and I
> do
> > > NOT
> > > > > > want
> > > > > > > to
> > > > > > > > list them in the project's pom.xml. How can I do this? I
> tried
> > > > > > searching
> > > > > > > > online but could not find an answer.
> > > > > > > >
> > > > > > >
> > > > > > > The documentation for the exec-maven-plugin's java goal
> contains
> > > > this:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#additionalClasspathElements
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
>


Re: How to add a library to the classpath

2023-01-05 Thread Siddharth Jain
thanks. unfortunately this is exactly what i don't want to do. i am looking
for a command line solution. i don't want my users to have to write a
pom.xml to add additional dependencies to the classpath.

On Thu, Jan 5, 2023 at 5:16 PM Greg Chabala  wrote:

> Try searching for an example:
>
> https://github.com/search?l=Maven+POM&q=additionalClasspathElements&type=Code
>
> On Thu, Jan 5, 2023 at 7:11 PM Siddharth Jain  wrote:
>
> > thanks. how do i separate multiple classpaths? tried : and , and none of
> > them work.
> >
> > On Thu, Jan 5, 2023 at 3:58 PM Laird Nelson  wrote:
> >
> > > On Thu, Jan 5, 2023 at 3:20 PM Siddharth Jain 
> > wrote:
> > >
> > > > I am using mvn exec:java to run a program. […] I want to add some
> more
> > > > libraries that I have
> > > > installed in M2 repository to the classpath at runtime and I do NOT
> > want
> > > to
> > > > list them in the project's pom.xml. How can I do this? I tried
> > searching
> > > > online but could not find an answer.
> > > >
> > >
> > > The documentation for the exec-maven-plugin's java goal contains this:
> > >
> > >
> >
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#additionalClasspathElements
> > >
> >
>


Re: How to add a library to the classpath

2023-01-05 Thread Siddharth Jain
in fact i don't think it works at all. tried using it like
-Dexec.additionalClasspathElements and doesn't work. i notice the
documentation only says:
Additional elements to be appended to the classpath.
for rest of the options the documentation also says:
*User property is*: exec.arguments.
to give an example.

On Thu, Jan 5, 2023 at 5:10 PM Siddharth Jain  wrote:

> thanks. how do i separate multiple classpaths? tried : and , and none of
> them work.
>
> On Thu, Jan 5, 2023 at 3:58 PM Laird Nelson  wrote:
>
>> On Thu, Jan 5, 2023 at 3:20 PM Siddharth Jain  wrote:
>>
>> > I am using mvn exec:java to run a program. […] I want to add some more
>> > libraries that I have
>> > installed in M2 repository to the classpath at runtime and I do NOT
>> want to
>> > list them in the project's pom.xml. How can I do this? I tried searching
>> > online but could not find an answer.
>> >
>>
>> The documentation for the exec-maven-plugin's java goal contains this:
>>
>> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#additionalClasspathElements
>>
>


Re: How to add a library to the classpath

2023-01-05 Thread Siddharth Jain
thanks. how do i separate multiple classpaths? tried : and , and none of
them work.

On Thu, Jan 5, 2023 at 3:58 PM Laird Nelson  wrote:

> On Thu, Jan 5, 2023 at 3:20 PM Siddharth Jain  wrote:
>
> > I am using mvn exec:java to run a program. […] I want to add some more
> > libraries that I have
> > installed in M2 repository to the classpath at runtime and I do NOT want
> to
> > list them in the project's pom.xml. How can I do this? I tried searching
> > online but could not find an answer.
> >
>
> The documentation for the exec-maven-plugin's java goal contains this:
>
> https://www.mojohaus.org/exec-maven-plugin/java-mojo.html#additionalClasspathElements
>


How to add a library to the classpath

2023-01-05 Thread Siddharth Jain
Hello,

I am using mvn exec:java to run a program. It automatically adds all the
dependencies defined in the project's pom.xml to the Java classpath at
runtime which is good but I want to add some more libraries that I have
installed in M2 repository to the classpath at runtime and I do NOT want to
list them in the project's pom.xml. How can I do this? I tried searching
online but could not find an answer. Thanks,

Sid


Re: java.lang.ClassNotFoundException: com.google.common.base.Preconditions

2022-07-25 Thread Siddharth Jain
I understand that. But we have been using maven exec:java for other
projects and did not run into this exception with them. *So we want to
understand why its not working here?* the debug log also shows that guava
is added to the classpath. how can we debug this issue further? could this
be a bug in maven? thanks.

On Mon, Jul 25, 2022 at 3:49 AM Martin Gainty  wrote:

> He advised you to not use exec:java which uses a configured classloader
> He advised you use exec:exec
>
> Directions to use exec:exec provided here
> Exec Maven Plugin – exec:exec (mojohaus.org)<
> https://www.mojohaus.org/exec-maven-plugin/exec-mojo.html>
>
> Exec Maven Plugin - MojoHaus<
> https://www.mojohaus.org/exec-maven-plugin/exec-mojo.html>
> The executable. Can be a full path or the name of the executable. In the
> latter case, the executable must be in the PATH for the execution to work.
> www.mojohaus.org
> gruss
> Martin
> 
> From: Siddharth Jain 
> Sent: Sunday, July 24, 2022 8:13 PM
> To: Maven Users List 
> Subject: Re: java.lang.ClassNotFoundException:
> com.google.common.base.Preconditions
>
> could you explain this to me? we have tried running without configuring any
> agent
> mvn exec:java -X -Dexec.mainClass=com.example.App
>
> and the exception is still there. and maven:exec works for other projects.
>
> On Sun, Jul 24, 2022 at 1:19 PM Bernd Eckenfels 
> wrote:
>
> > Since exec:java executes in the running JVM it does not reconfigure the
> > (boot)classpath but provides a configured classloader. It looks like the
> > measuring agent does not like that. In that Case you need either
> > exec:exec or a plug-in for that purpose.
> >
> > Gruss
> > Bernd
> >
> >
> > --
> > http://bernd.eckenfels.net
> > 
> > Von: Siddharth Jain 
> > Gesendet: Sunday, July 24, 2022 8:46:04 PM
> > An: users@maven.apache.org 
> > Betreff: java.lang.ClassNotFoundException:
> > com.google.common.base.Preconditions
> >
> > we are running into the dreaded ClassNotFoundException in a project. Here
> > is the setup. Using JDK 11 and Maven 3.8.5. Trying to create sample test
> > project that uses memory-measurer
> > <https://github.com/DimitrisAndreou/memory-measurer> to measure memory.
> > First we mvn packaged and installed the memory-measurer artifact into M2
> > repository. Then we created a test project in which we add dependency on
> > memory-measurer. The project compiles fine but gives error on running (we
> > run using mvn exec:java plugin):
> >
> > Caused by: java.lang.ClassNotFoundException:
> > com.google.common.base.Preconditions
> > at jdk.internal.loader.BuiltinClassLoader.loadClass
> > (BuiltinClassLoader.java:581)
> > at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass
> > (ClassLoaders.java:178)
> > at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
> > at objectexplorer.InstrumentationGrabber.checkSetup
> > (InstrumentationGrabber.java:20)
> > at objectexplorer.InstrumentationGrabber.instrumentation
> > (InstrumentationGrabber.java:25)
> > at objectexplorer.MemoryMeasurer. (MemoryMeasurer.java:24)
> > at com.example.App.main (App.java:20)
> > at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
> > at java.lang.Thread.run (Thread.java:834)
> >
> >
> > What have we tried? Here is output of mvn dependency:build-classpath:
> >
> >
> >
> /Users/xxx/.m2/repository/objectexplorer/memory-measurer/1.0-SNAPSHOT/memory-measurer-1.0-SNAPSHOT.jar:/Users/xxx/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/xxx/.m2/repository/com/google/guava/guava/19.0/guava-19.0.jar:/Users/xxx/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/xxx/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
> >
> > we unpacked guava-19.0.jar in a temp directory and can see
> >
> > -rw-r--r--  1 xxx  staff  5252 Aug 25  2014
> > /Users/xxx/temp/com/google/common/base/Preconditions.class
> >
> > in it. The next thing we tried is printing
> > System.getProperty("java.class.path"). This gives:
> >
> > /Library/Downloads/apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar
> >
> > above does not contain the classpath calculated by mvn dependency plugin.
> > Question 1: Why?
> >
> > Question 2: When we printed System.getProperty("java.class.path") in
> > another working project we got same result. It seems the classpath when
> > using mvn exec:java is always
> >
> > /Li

Re: java.lang.ClassNotFoundException: com.google.common.base.Preconditions

2022-07-24 Thread Siddharth Jain
could you explain this to me? we have tried running without configuring any
agent
mvn exec:java -X -Dexec.mainClass=com.example.App

and the exception is still there. and maven:exec works for other projects.

On Sun, Jul 24, 2022 at 1:19 PM Bernd Eckenfels 
wrote:

> Since exec:java executes in the running JVM it does not reconfigure the
> (boot)classpath but provides a configured classloader. It looks like the
> measuring agent does not like that. In that Case you need either
> exec:exec or a plug-in for that purpose.
>
> Gruss
> Bernd
>
>
> --
> http://bernd.eckenfels.net
> ____
> Von: Siddharth Jain 
> Gesendet: Sunday, July 24, 2022 8:46:04 PM
> An: users@maven.apache.org 
> Betreff: java.lang.ClassNotFoundException:
> com.google.common.base.Preconditions
>
> we are running into the dreaded ClassNotFoundException in a project. Here
> is the setup. Using JDK 11 and Maven 3.8.5. Trying to create sample test
> project that uses memory-measurer
> <https://github.com/DimitrisAndreou/memory-measurer> to measure memory.
> First we mvn packaged and installed the memory-measurer artifact into M2
> repository. Then we created a test project in which we add dependency on
> memory-measurer. The project compiles fine but gives error on running (we
> run using mvn exec:java plugin):
>
> Caused by: java.lang.ClassNotFoundException:
> com.google.common.base.Preconditions
> at jdk.internal.loader.BuiltinClassLoader.loadClass
> (BuiltinClassLoader.java:581)
> at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass
> (ClassLoaders.java:178)
> at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
> at objectexplorer.InstrumentationGrabber.checkSetup
> (InstrumentationGrabber.java:20)
> at objectexplorer.InstrumentationGrabber.instrumentation
> (InstrumentationGrabber.java:25)
> at objectexplorer.MemoryMeasurer. (MemoryMeasurer.java:24)
> at com.example.App.main (App.java:20)
> at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
> at java.lang.Thread.run (Thread.java:834)
>
>
> What have we tried? Here is output of mvn dependency:build-classpath:
>
>
> /Users/xxx/.m2/repository/objectexplorer/memory-measurer/1.0-SNAPSHOT/memory-measurer-1.0-SNAPSHOT.jar:/Users/xxx/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/xxx/.m2/repository/com/google/guava/guava/19.0/guava-19.0.jar:/Users/xxx/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/xxx/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
>
> we unpacked guava-19.0.jar in a temp directory and can see
>
> -rw-r--r--  1 xxx  staff  5252 Aug 25  2014
> /Users/xxx/temp/com/google/common/base/Preconditions.class
>
> in it. The next thing we tried is printing
> System.getProperty("java.class.path"). This gives:
>
> /Library/Downloads/apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar
>
> above does not contain the classpath calculated by mvn dependency plugin.
> Question 1: Why?
>
> Question 2: When we printed System.getProperty("java.class.path") in
> another working project we got same result. It seems the classpath when
> using mvn exec:java is always
>
> /Library/Downloads/apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar
>
> How is the other project able to load classes from above classpath? Why is
> mvn
> exec:java not using correct classpath? How do we fix this?
>
>
> Here <https://gist.github.com/siddjain/5d2afee15a756b689c5231488e6c29be>
> is
> output of maven with the -X switch. You can see following debug info:
>
>
> [DEBUG] Adding project dependency artifact: memory-measurer to classpath
> [DEBUG] Adding project dependency artifact: jsr305 to classpath
> *[DEBUG] Adding project dependency artifact: guava to classpath* here
> <https://gist.github.com/siddjain/2ceaca405acdaf460df94a064e07c17f> is
> pom.xml. would be great if someone could help us out.
>


java.lang.ClassNotFoundException: com.google.common.base.Preconditions

2022-07-24 Thread Siddharth Jain
we are running into the dreaded ClassNotFoundException in a project. Here
is the setup. Using JDK 11 and Maven 3.8.5. Trying to create sample test
project that uses memory-measurer
 to measure memory.
First we mvn packaged and installed the memory-measurer artifact into M2
repository. Then we created a test project in which we add dependency on
memory-measurer. The project compiles fine but gives error on running (we
run using mvn exec:java plugin):

Caused by: java.lang.ClassNotFoundException:
com.google.common.base.Preconditions
at jdk.internal.loader.BuiltinClassLoader.loadClass
(BuiltinClassLoader.java:581)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass
(ClassLoaders.java:178)
at java.lang.ClassLoader.loadClass (ClassLoader.java:521)
at objectexplorer.InstrumentationGrabber.checkSetup
(InstrumentationGrabber.java:20)
at objectexplorer.InstrumentationGrabber.instrumentation
(InstrumentationGrabber.java:25)
at objectexplorer.MemoryMeasurer. (MemoryMeasurer.java:24)
at com.example.App.main (App.java:20)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
at java.lang.Thread.run (Thread.java:834)


What have we tried? Here is output of mvn dependency:build-classpath:

/Users/xxx/.m2/repository/objectexplorer/memory-measurer/1.0-SNAPSHOT/memory-measurer-1.0-SNAPSHOT.jar:/Users/xxx/.m2/repository/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar:/Users/xxx/.m2/repository/com/google/guava/guava/19.0/guava-19.0.jar:/Users/xxx/.m2/repository/junit/junit/4.11/junit-4.11.jar:/Users/xxx/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar

we unpacked guava-19.0.jar in a temp directory and can see

-rw-r--r--  1 xxx  staff  5252 Aug 25  2014
/Users/xxx/temp/com/google/common/base/Preconditions.class

in it. The next thing we tried is printing
System.getProperty("java.class.path"). This gives:

/Library/Downloads/apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar

above does not contain the classpath calculated by mvn dependency plugin.
Question 1: Why?

Question 2: When we printed System.getProperty("java.class.path") in
another working project we got same result. It seems the classpath when
using mvn exec:java is always

/Library/Downloads/apache-maven-3.8.5/boot/plexus-classworlds-2.6.0.jar

How is the other project able to load classes from above classpath? Why is mvn
exec:java not using correct classpath? How do we fix this?


Here  is
output of maven with the -X switch. You can see following debug info:


[DEBUG] Adding project dependency artifact: memory-measurer to classpath
[DEBUG] Adding project dependency artifact: jsr305 to classpath
*[DEBUG] Adding project dependency artifact: guava to classpath* here
 is
pom.xml. would be great if someone could help us out.