-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev mode pulls in dependencies from Maven profiles of other modules if profile with same name is present in parent #19152
Comments
/cc @quarkusio/devtools |
To add more sense to this setup: |
cc @aloubyansky |
@aloubyansky are you going to look at this anytime soon? (welcome back, btw) |
Yes, I was going to. I have a few issues accumulated during my absence, so a bit slow. |
Alright, please let me know if/how I can support. I might be slow to respond as I'm very busy in these last days before my PTO. |
The |
Just to clarify, if you execute
|
FTR (as discussed on Zulip):
|
Not seeing this anymore in 2.4.0.CR1 or newer. Might have been fixed in #20500. /cc @aloubyansky |
Describe the bug
Ok, that's a very dodgy one:
Imagine you have a multi module Maven project with:
parent
contains a Maven profilemocks
with nothing in it (!)core
SupportInterface
test-classes
with classifiermocks
that includes a producer that produces a Mockito Mock forSupportInterface
(via@AlternativePriority(-1)
)support
SupportInterface
mocks
(same name as in parent!) that defines dependency onmocks
jar fromcore
dist
depends on all other modules and is the place where dev mode is startedPlease note that the
mocks
profile insupport
doesn't make much sense here assupport
is already providing the "real" implementation. In my real project we have a few other modules that have such a profile (not thesupport
one which is actually calledidp
), but I wanted to keep the numbers of modules to an absolute minimum and decided to describe the setup of the reproducer instead of my real project.So with this setup, when calling
mvn clean quarkus:dev -f dist -Pmocks
and calling the rest resource, instead of using the "real" impl of the interface fromsupport
, the mock producer from the secondarymocks
core jar is called.To make things worse, a
NoClassDefFoundError
is thrown forSupportInterface
which highlights that something in dev mode Maven bootstrapping (and classloading) is really going wrong with this setup.Expected behavior
Dependencies in profiles of upstream modules don't leak into dev mode started in the current module, even if a profile with the same name is activated that is defined in the parent/root pom.xml of the project.
Actual behavior
Dependencies in such profiles from upstream modules must not be pulled in. Only dependencies in activated profiles defined in the current module or any of the current modules' parent(s) may be pulled in.
How to Reproduce?
issue-19152-devmode-mvnprofile
mvn clean install
mvn clean quarkus:dev -f dist -Pmocks
SupportMockProducer
when its class is being loaded (which should not happen at all!).NoClassDefFoundError: com/github/famod/modmono_quarkus/support/SupportInterface
Output of
uname -a
orver
Linux BIGBLUE 4.19.128-microsoft-standard #1 SMP Tue Jun 23 12:58:10 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Output of
java -version
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)
GraalVM version (if different from Java)
n/a
Quarkus version or git rev
2.0.3.Final and 2.1.0.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.1
Additional information
What I found additionally dodgy is that when I do not use
clean
to start dev mode, the results are inconsistent:mvn quarkus:dev -f dist
-> 🟢mvn quarkus:dev -f dist -Pmocks
-> 🟢⚡mvn clean quarkus:dev -f dist -Pmocks
-> 🔴mvn quarkus:dev -f dist
-> 🔴⚡mvn clean quarkus:dev -f dist
-> 🟢Btw,
<type>test-jar</type>
doesn't change anything andmvn dependency:tree -f dist -Pmocks
shows no sign of themocks
jar.I can work around this specific case via
@UnlessBuildProperty
(or similar) on the producer but that might not work for other variations.See also: https://quarkusio.zulipchat.com/#narrow/stream/187030-users/topic/Producer.20in.20src.2Ftest.2Fjava.20vs.2E.20dev.20mode
The text was updated successfully, but these errors were encountered: