I added another sample commit:

https://github.com/kriegaex/kryo/commit/c1d8729748ddb0e6367d440bed57f58aa64d534a

Quoting the commit comment:

Move Surefire configuration to root POM and streamline

Now only the Compiler plugin configuration for test compilation is
duplicated in submodules kryo and kryo5.

There are two mutually exclusive profiles for versions 11-13 vs. 14+
now, so configuration override is no longer necessary.

I think you can easily adjust that to your needs if in your branch you
have other version ranges, such as 5-8, 9-13, 14+ or 8-13, 14+.

An open question is how you could actually, like you tried right at the
beginning, also configure Maven Compiler in the root POM without making
Maven trigger compilation for the root POM itself. But I did not try to
find out. I am not a Maven expert either, not even a professional
programmer. As an agile coach I just play with software development in
my sparetime. I am sure someone else can help you better there than I.

Cheers
-- 
Alexander Kriegisch
https://scrum-master.de


Alexander Kriegisch schrieb am 03.09.2020 11:56 (GMT +07:00):

> Hi Julia.
> 
> With the MCVE I can see what is going on and also what is going wrong.
> But before I make a suggestion or send you a PR, I think we need to
> clarify a misunderstanding:
> 
> In my first message I was wondering why you wanted mutual exclusivity
> and not JDK 14 compilation and tests being a superset of JDK < 14. You
> insisted on mutual exclusivity against my recommendation. But now in
> your description I see that you seem to describe a behaviour which is
> more like the superset thing I had in mind, e.g. for JDK 14 you also
> compile the other tests, not just the JDK 14 test you wish to run.
> 
> And indeed, when I tried to run the Kryo tests, all except one of the
> original (upstream) tests also run fine on JDK 14. Only one of them
> fails, SerializationCompatTest. But that is just because you added one
> default serializer. This was easy to fix, see commit @7781a952 [1].
> Funny enough, UnsafeByteBufferInputOutputTest passes, even though an
> exception occurs in method testByteBufferOutputWithPreallocatedMemory.
> But there is a try-catch around it, making the test pass. I think it
> would be better to fix Kryo to use the appropriate DirectByteBuffer
> constructor for newer JDK versions, but this is beyond the scope of our
> little chat here.
> 
> So what I suggest is to not just run a single test on JDK 14 but to run
> all tests, just like you compile all tests.
> 
> Now let me explain what went wrong in your build configuration: You have
> the profiles jdk8ge and jdk14ge, and *both* of them are active at the
> same time under JDK 14 due to the auto-activation conditions you chose.
> So far, so good. But that means that their configurations are not
> mutually exclusive, as you said you would make them, but they merge into
> one. The effective POM shows something like this for the compiler
> plugin:
> 
> <execution>
>   <id>default-testCompile</id>
>   <phase>test-compile</phase>
>   <goals>
>     <goal>testCompile</goal>
>   </goals>
>   <configuration>
>     <release>14</release>
>     <compilerArgs>
>       <arg>--enable-preview</arg>
>     </compilerArgs>
>     <testIncludes>
>       <testInclude>jdk14/**</testInclude>
>     </testIncludes>
>     <testExcludes>
>       <testExclude>jdk14/**</testExclude>
>     </testExcludes>
>     <source>1.8</source>
>     <target>1.8</target>
>     <encoding>utf-8</encoding>
>   </configuration>
> </execution>
> 
> So first you include package jdk14, then you exclude it. Surprisingly,
> all tests get compiled anyway, I have no idea why. Maybe the include
> just wins in Maven Compiler.
> 
> But now there is a similar effect in Surefire:
> 
> <execution>
>   <id>default-test</id>
>   <phase>test</phase>
>   <goals>
>     <goal>test</goal>
>   </goals>
>   <configuration>
>     <includes>
>       <include>jdk14/**</include>
>     </includes>
>     <argLine>--enable-preview</argLine>
>     <excludes>
>       <exclude>jdk14/**</exclude>
>     </excludes>
>   </configuration>
> </execution>
> 
> Here the in- vs. exclusion has the effect that no tests are run, as you
> said. Here obviously the include means that *only* what is included is
> considered for a test run, but then you exclude the same thing again,
> resulting in zero tests to be run.
> 
> So how do you solve that?
> 
> Variant 1: You use <configuration combine.self="override"> in the JDK 14
> profile for both the Compiler and Surefire plugins and just remove the
> corresponding includes, i.e. JDK 14 is the normal case. See commit
> @59b013e8 [2].
> 
> Variant 2: You do it the other way around and say: Compile and run all
> tests is the default and for JDK < 14 you override with excludes. This
> way you would not have to configure anything special for JDK 14 except
> for the --enable-preview switch and the <release> tag.
> 
> By the way, in the root POM is another profile 'until-java11' with
> activation condition <jdk>[1.5,11)</jdk>, excluding certain Java 11
> tests. I tried to run a build on JDK 8 or JDK 9 with Kryo master, but it
> does not even compile because it uses Java 10+ API calls. So maybe
> Kryo's build configuration is outdated already. But that's just another
> strange thing about that project. I will just assume that anything below
> JDK 11 is irrelevant to you, even though you have created a Java 8+
> profile. Or does your own real project fork off of another Kryo branch
> which is not the master?
> 
> [1]
> https://github.com/kriegaex/kryo/commit/7781a952d2f61766329743c49ea6ca9464920152
> [2]
> https://github.com/kriegaex/kryo/commit/59b013e8bbd25d4fde7a8d6d4f211350ef6bff80
> -- 
> Alexander Kriegisch
> https://scrum-master.de
> 
> 
> Julia Boes schrieb am 02.09.2020 19:32 (GMT +07:00):
> 
>> Here's the MCVE fork
>> 
>> https://github.com/oracle/kryo/tree/records
>> 
>> I followed your suggestion and moved the compiler config to the
>> relevant children's poms (pom-main, pom-versioned). Compilation works
>> as expected now.
>> 
>> To recap: RecordSerializerTest (t) requires jdk 14 --enable-preview
>> for compilation and test run.
>> 
>> $ mvn clean && mvn install
>> 
>> with jdk-14.0.1 compiles t with --enable-preview and all other tests
>> without the flag
>> 
>> with jdk-11.0.8 compiles all tests but t Similarly, I tried to set
>> executions for the test goal to achieve the following:
>> 
>>   1. with jdk-14.0.1 runs t with --enable-preview and all other tests
>>      without the flag
>> 
>>   2. with jdk-11.0.8 runs all tests but t
>> 
>> Result:
>> 
>>   2. works fine with the current configuration, but
>> 
>>   1. runs *no* tests at all. I inspected the effective pom and can see
>>      that the profile for <jdk11 from the parent pom is inherited, but
>>      I'm not sure if that's the problem.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to