Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-30 Thread Stanimir Stamenkov

Sat, 30 Mar 2024, /Debraj Manna/:

As suggested by Stanimir if I remove the test-jar type and also the 
includes like below then mvn package --projects=:agent -T 2 --also-make 
works

[...]
But if I add back the below inclusion it again starts throwing the 
NoClassDefFoundError

[...]


At least for me, it is already hard to follow.  Without accessible full 
example setup I can only suggest you follow Gary's and the official 
documentation advice to factor the necessary classes into their own 
module, declaring their dependencies explicitly:


 * 
https://maven.apache.org/plugins/maven-jar-plugin/examples/create-test-jar.html#the-preferred-way



*The preferred way*

In order to let Maven resolve all |test|-scoped transitive dependencies 
you should create a separate project.


  * Move the sources files from |src/test/java| you want to share from the 
original project to the |src/main/java| of this project...


--
Stanimir

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



Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-29 Thread Debraj Manna
As suggested by Stanimir if I remove the test-jar type and also the
includes like below then mvn package --projects=:agent -T 2 --also-make
works


org.apache.maven.plugins
maven-jar-plugin
3.3.0



test-jar





But if I add back the below inclusion it again starts throwing the
NoClassDefFoundError


 
common/**
 


On Thu, Mar 28, 2024 at 5:51 PM Stanimir Stamenkov
 wrote:

> Thu, 28 Mar 2024, /Debraj Manna/:
>
> > Ok I can try that but I can see the type test-jar from the below
> > documentation
> >
> > https://maven.apache.org/guides/mini/guide-attached-tests.html
>
> I hadn't been aware of it.  It could be specific to the ear-plugin:
>
> * https://issues.apache.org/jira/browse/MEAR-216
>
>
> > On Thu, Mar 28, 2024 at 3:11 PM Stanimir Stamenkov wrote:
> >> Thu, 28 Mar 2024, /Debraj Manna/:
> >>
> >>> 
> >>> com.spotnana
> >>> synapse
> >>> 0.0.1-SNAPSHOT
> >>> tests
> >>> test-jar
> >>
> >> This doesn't seem right.  I'm not aware of test-jar –
> >> should be just jar (or just omit it as it is implied).
>
> --
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-28 Thread Stanimir Stamenkov

Thu, 28 Mar 2024, /Debraj Manna/:

Ok I can try that but I can see the type test-jar from the below 
documentation


https://maven.apache.org/guides/mini/guide-attached-tests.html


I hadn't been aware of it.  It could be specific to the ear-plugin:

* https://issues.apache.org/jira/browse/MEAR-216



On Thu, Mar 28, 2024 at 3:11 PM Stanimir Stamenkov wrote:

Thu, 28 Mar 2024, /Debraj Manna/:



com.spotnana
synapse
0.0.1-SNAPSHOT
tests
test-jar


This doesn't seem right.  I'm not aware of test-jar – 
should be just jar (or just omit it as it is implied).


--

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



Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-28 Thread Debraj Manna
Ok I can try that but I can see the type test-jar from the below
documentation

https://maven.apache.org/guides/mini/guide-attached-tests.html

On Thu, Mar 28, 2024 at 3:11 PM Stanimir Stamenkov
 wrote:

> Thu, 28 Mar 2024, /Debraj Manna/:
>
> > But I am still facing issues in the below case.
> > [...]
> >
> > 
> >com.spotnana
> >synapse
> >0.0.1-SNAPSHOT
> >tests
> >test-jar
>
> This doesn't seem right.  I'm not aware of test-jar –
> should be just jar (or just omit it as it is implied).
>
> >test
> > 
> >
> > Now if I am trying to do mvn package --projects=:agent -T 2 --also-make
> >
> > I am getting NoClassDefFound for common/C.java while tests are being
> > executed in the agent module...
>
> --
> Stanimir
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-28 Thread Stanimir Stamenkov

Thu, 28 Mar 2024, /Debraj Manna/:


But I am still facing issues in the below case.
[...]


   com.spotnana
   synapse
   0.0.1-SNAPSHOT
   tests
   test-jar


This doesn't seem right.  I'm not aware of test-jar – 
should be just jar (or just omit it as it is implied).



   test


Now if I am trying to do mvn package --projects=:agent -T 2 --also-make

I am getting NoClassDefFound for common/C.java while tests are being
executed in the agent module...


--
Stanimir

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



Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-28 Thread Debraj Manna
Gary

Somehow your message went into my spam folder.

The idea was in synapse there were certain utility classes which other
modules should only use while writing integration tests with synapse. The
test classes are not expected to be used in non-test code by other modules.

synapse also contains test classes to check its code which is not that
relevant for other modules. So I was trying to exclude those codes in the
test-jar.

Since maven --also-make is not working properly with test-jar. I can create
a separate synapse-testing-utility jar which synapse and other modules can
use in their test scope for testing. I think that is what you were
suggesting.

Thanks,


On Fri, Mar 22, 2024 at 4:15 PM Gary Gregory  wrote:

> I think the "simple" solution is to use 2 maven modules, then you don't
> need to do anything special. The layout does not make sense to me so I must
> be missing something. If the common code is needed for both main and test,
> then it should be in main. You can put that common code in its own package
> to signal its specific purpose.
>
> Gary
>
>
> On Fri, Mar 22, 2024, 3:29 AM Debraj Manna 
> wrote:
>
> > I have a Maven module named synapse.
> >
> > main
> >   java
> > package1
> >   A.java
> >
> > test
> >   java
> > common
> >   C.java
> > package1
> >   ATest.java
> >
> > Can someone let me know if in Maven I can create a non-executable jar
> > containing all non-test code (main/) and another test-jar containing only
> > the code under the package test/java/common?
> >
> > I tried the below
> >
> > 
> >   
> >
> > org.springframework.boot
> > spring-boot-maven-plugin
> > 
> >   true
> > 
> >
> >
> >  org.apache.maven.plugins
> >  maven-jar-plugin
> >  3.3.0
> >  
> >   
> > common/**
> >   
> > 
> > 
> >   
> > 
> >   test-jar
> > 
> >   
> > 
> >   
> >  
> >   
> >
> > I am observing that the test-jar is getting created as expected
> containing
> > only the code from test/java/common but the non-executable, non-test jar
> > does not contain the code from main/java/package1.
> >
> >- Maven Version - 3.8.4
> >- Java 17
> >
>


Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-27 Thread Debraj Manna
As suggested the below config is working fine


org.apache.maven.plugins
maven-jar-plugin
3.3.0



test-jar



common/**








But I am still facing issues in the below case.


Let's say I have a module agent which depends on synapse and its test-jar.



  com.sp
  synapse
  0.0.1-SNAPSHOT
  compile



  com.spotnana
  synapse
  0.0.1-SNAPSHOT
  tests
  test-jar
  test


Now if I am trying to do mvn package --projects=:agent -T 2 --also-make


I am getting NoClassDefFound for common/C.java while tests are being
executed in the agent module. To get around this I had to do


   1. mvn package --projects=:agent,:synapse -T 2 --also-make
   2. and remove the configuration.includes section in test-jar execution goal

Is this the expected behaviour with --also-make?


On Fri, Mar 22, 2024 at 4:34 PM Stanimir Stamenkov
 wrote:

> See my reply below the quote...
>
> Fri, 22 Mar 2024, /Debraj Manna/:
>
> > [...]
> > I tried the below
> >
> > 
> >
> > 
> >  org.springframework.boot
> >  spring-boot-maven-plugin
> >  
> >true
> >  
> > 
> > 
> >   org.apache.maven.plugins
> >   maven-jar-plugin
> >   3.3.0
> >   
> >
> >  common/**
> >
> >  
> >  
> >
> >  
> >test-jar
> >  
> >
> >  
> >
> >   
> >
> >
> > I am observing that the test-jar is getting created as expected
> containing
> > only the code from test/java/common but the non-executable, non-test jar
> > does not contain the code from main/java/package1.
>
> The easiest way is probably what Gary Gregory has suggested – extract
> the common code in its own module.
>
> Your main JAR is likely missing classes as you've applied 
> configuration globally to the maven-jar-plugin, and not just to the
> "test-jar" execution:
>
>  
>
>  
>test-jar
>  
>  
>
>  common/**
>
>  
>
>  
>
> You may wish to give the execution a non-default ID, and produce
> additional JAR with a different classifier:
>
>  
>
>  common-test-jar
>  
>test-jar
>  
>  
>tests-common
>
>  common/**
>
>  
>
>  
>
> You'll then use the given classifier when specifying this JAR as a test
> dependency to other modules.
>
> See also: "How to create an additional attached jar artifact from the
> project"
> <
> https://maven.apache.org/plugins/maven-jar-plugin/examples/attached-jar.html
> >
>
> --
> Stanimir
>
> -
> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> For additional commands, e-mail: users-h...@maven.apache.org
>
>


Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-22 Thread Stanimir Stamenkov

See my reply below the quote...

Fri, 22 Mar 2024, /Debraj Manna/:


[...]
I tried the below


   

 org.springframework.boot
 spring-boot-maven-plugin
 
   true
 


  org.apache.maven.plugins
  maven-jar-plugin
  3.3.0
  
   
 common/**
   
 
 
   
 
   test-jar
 
   
 
   
  
   

I am observing that the test-jar is getting created as expected containing
only the code from test/java/common but the non-executable, non-test jar
does not contain the code from main/java/package1.


The easiest way is probably what Gary Gregory has suggested – extract 
the common code in its own module.


Your main JAR is likely missing classes as you've applied  
configuration globally to the maven-jar-plugin, and not just to the 
"test-jar" execution:



  

  test-jar


  
common/**
  

  


You may wish to give the execution a non-default ID, and produce 
additional JAR with a different classifier:



  
common-test-jar

  test-jar


  tests-common
  
common/**
  

  


You'll then use the given classifier when specifying this JAR as a test 
dependency to other modules.


See also: "How to create an additional attached jar artifact from the 
project" 



--
Stanimir

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



Re: How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-22 Thread Gary Gregory
I think the "simple" solution is to use 2 maven modules, then you don't
need to do anything special. The layout does not make sense to me so I must
be missing something. If the common code is needed for both main and test,
then it should be in main. You can put that common code in its own package
to signal its specific purpose.

Gary


On Fri, Mar 22, 2024, 3:29 AM Debraj Manna  wrote:

> I have a Maven module named synapse.
>
> main
>   java
> package1
>   A.java
>
> test
>   java
> common
>   C.java
> package1
>   ATest.java
>
> Can someone let me know if in Maven I can create a non-executable jar
> containing all non-test code (main/) and another test-jar containing only
> the code under the package test/java/common?
>
> I tried the below
>
> 
>   
>
> org.springframework.boot
> spring-boot-maven-plugin
> 
>   true
> 
>
>
>  org.apache.maven.plugins
>  maven-jar-plugin
>  3.3.0
>  
>   
> common/**
>   
> 
> 
>   
> 
>   test-jar
> 
>   
> 
>   
>  
>   
>
> I am observing that the test-jar is getting created as expected containing
> only the code from test/java/common but the non-executable, non-test jar
> does not contain the code from main/java/package1.
>
>- Maven Version - 3.8.4
>- Java 17
>


How to include only certain test packages in a maven test-jar & all non test code in a non test jar?

2024-03-22 Thread Debraj Manna
I have a Maven module named synapse.

main
  java
package1
  A.java

test
  java
common
  C.java
package1
  ATest.java

Can someone let me know if in Maven I can create a non-executable jar
containing all non-test code (main/) and another test-jar containing only
the code under the package test/java/common?

I tried the below


  
   
org.springframework.boot
spring-boot-maven-plugin

  true

   
   
 org.apache.maven.plugins
 maven-jar-plugin
 3.3.0
 
  
common/**
  


  

  test-jar

  

  
 
  

I am observing that the test-jar is getting created as expected containing
only the code from test/java/common but the non-executable, non-test jar
does not contain the code from main/java/package1.

   - Maven Version - 3.8.4
   - Java 17