Why is the generated name for a lambda class not the same for identical programs

Looking into javac source you may notice that the corresponding counter (which is appended to the lambda method name) is defined as an instance field in the LambdaAnalyzerPreprocessor which is reused for the whole compilation process. It's incremented on every lambda occurrence. So if I compile your class only, I will have numbers started from 0:

> javac Test.java
> javap -p Test
Compiled from "Test.java"
public class Test {
  public Test();
  public static void main(java.lang.String[]);
  private static void lambda$main$2(java.lang.Object);
  private static boolean lambda$main$1(java.util.Map, java.lang.Object);
  private static java.util.stream.Stream lambda$main$0(java.util.List);
}

But if I create one more class

public class Test2 { 
    Runnable r = () -> {};
}

And compile them together I will see the counter incremented:

> javac Test2.java Test.java 
> javap -p Test
Compiled from "Test.java"
public class Test {
  public Test();
  public static void main(java.lang.String[]);
  private static void lambda$main$3(java.lang.Object);
  private static boolean lambda$main$2(java.util.Map, java.lang.Object);
  private static java.util.stream.Stream lambda$main$1(java.util.List);
}

So this is not the maven problem, this is how javac compiler works.

If you definitely need stable compilation results I may suggest you to try Eclipse Compiler for Java. Seems that it has no such problem:

>java -jar org.eclipse.jdt.core_3.11.1.v20150902-1521.jar -8 Test2.java Test.java
>javap -p Test
Compiled from "Test.java"
public class Test {
  public Test();
  public static void main(java.lang.String[]);
  private static java.util.stream.Stream lambda$0(java.util.List);
  private static boolean lambda$1(java.util.Map, java.lang.Object);
  private static void lambda$2(java.lang.Object);
}

Refer to this question on how to integrate ecj with maven.