I ran into an odd situation today and want to see if it's a known problem.

I work on Helidon (https://helidon.io).  (Disclaimer: I never speak for my
employer unless I say that's what I'm doing and I'm not doing that now.)  I
am compiling a Maven module that is also a "real" Java module (with a
src/main/java/module-info.java file) using the maven-compiler-plugin at
version 3.8.1 and JDK 11.

I have a convenient little alias that runs Maven with -f $(findup pom.xml)
where findup is:

#!/bin/bash
find-up () {
  path=$(pwd)
  while [[ "$path" != "" && ! -e "$path/$1" ]]; do
    path=${path%/*}
  done
  echo "$path/$1"
}
find-up "$@"

So: this lets me run Maven from a subdirectory.  Nice and convenient.

I found that when I run Maven in this manner from src/main/java, i.e. the
directory housing my module-info.java file, then test-compile fails, with
several hundred error messages complaining that none of the modules in
module-info are in the module graph.  Regular compilation of main sources
during this run works fine.

If I run it from, say, just src/main, everything works fine.  If I run it
from, say, src/test/java, everything works fine.  If I run it from, say,
src/main/java/io/helidon, or basically any other subdirectory, everything
works fine.  It is only when I run it from src/main/java that the entire
module graph is not found at test-compile time.

I have turned on debugging output via -X and started hunting for things
like relative paths, but found none.

Is there something special about the current working directory when it
contains module-info.java, either in the maven-compiler-plugin itself (in
TestCompilerMojo, I'd assume), or, perhaps unexpectedly, in javac itself?

Thanks,
Best,
Laird

Reply via email to