rife2 / bld

Pure java build tool for developers who don't like dealing with build tools
https://rife2.com/bld
Apache License 2.0
231 stars 11 forks source link

Using -p and --module-path for a javac command causes the compiler to ignore --module-path #54

Open leeclarke opened 6 days ago

leeclarke commented 6 days ago

When building a java module that requires another module AND uses something like .include(module("org.projectlombok", "lombok", version(1,18,34))) as a compile dependency an unexpected bug comes up as they get different javac params assigned.

So what happens is in the CompileOperation.executeBuildSources the javac command gets built with the options containing -p , in this case with the lombok module from include module(). Since my module has a requires for another module "framework" this gets brought into the options as --module-path. From what I can tell, when Javac encounters both (-p & --module-path) in the command options it only uses one, I looks to be the last in order or maybe it prefers the --module-path, either way it discards the other. (Kinda rude really!)

A bit of an example the help illustrate it. I dumped this from debugging (path names are changed to protect the, not-so, innocent)

options values before calling javac task:

-d /home/user/code/MyProject/build/main/MyProject

-cp /home/user/code/MyProject/lib/compile/apiguardian-api-1.1.2.jar:/home/user/code/MyProject/lib/compile/bld-2.1.0.jar:/home/user/code/MyProject/lib/compile/jdom2-2.0.6.1.jar:/home/user/code/MyProject/lib/compile/junit-jupiter-5.11.0.jar:/home/user/code/MyProject/lib/compile/junit-jupiter-api-5.11.0.jar:/home/user/code/MyProject/lib/compile/junit-jupiter-params-5.11.0.jar:/home/user/code/MyProject/lib/compile/junit-platform-commons-1.11.0.jar:/home/user/code/MyProject/lib/compile/junit-platform-console-standalone-1.11.0.jar:/home/user/code/MyProject/lib/compile/lombok-1.18.34.jar:/home/user/code/MyProject/lib/compile/modules/lombok-1.18.34.jar:/home/user/code/MyProject/lib/compile/opentest4j-1.3.0.jar:/home/user/code/MyProject/lib/compile/rome-2.1.0.jar:/home/user/code/MyProject/lib/compile/rome-utils-2.1.0.jar:/home/user/code/MyProject/lib/compile/slf4j-api-2.0.6.jar:/home/user/code/MyProject/lib/compile/wfbuildtools-0.3.3.jar:/home/user/code/MyProject/lib/provided/modules/lombok-1.18.34.jar 

-p /home/user/code/MyProject/lib/compile/modules/lombok-1.18.34.jar:/home/user/code/MyProject/lib/provided/modules/lombok-1.18.34.jar

--module-path /home/user/code/MyProject/build/dist/framework-0.1.0.jar
leeclarke commented 6 days ago

I was able to fix this by combining the compileOptions_ paths into the paths added to the -p command. Line 131 in CompileOperation.java .