Skip to content
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

Quarkus multi module projects should use the compiled source, instead of downloading it from nexus (or local .m2 folder) #17231

Closed
RobinGoussey opened this issue May 14, 2021 · 10 comments · Fixed by #17351
Assignees
Labels
area/maven kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Milestone

Comments

@RobinGoussey
Copy link

RobinGoussey commented May 14, 2021

Describe the bug

(Describe the problem clearly and concisely.)

So currently, we have a git repo, with (altered names)

  • model (quarkus extension, all dao and model classes)
  • service (quarkus extension, all service classes)
  • http (quarkus extension, All rest endpoints)
  • application
  • aggregator

Currently when maven -f aggregator clean verify runs it's tests, it shows:

[INFO] Running <omitted>.http.coastal.ContactOfInterestRestEndpointTest
Downloading from nexusRepository: https://nexus.<omitted>/nexus/content/groups/public/<omitted>-service/0.5-SNAPSHOT/maven-metadata.xml
Downloaded from nexusRepository: https://nexus.<omitted>/nexus/content/groups/public/<omitted>-service/0.5-SNAPSHOT/maven-metadata.xml (978 B at 3.8 kB/s)
...
<omitted>
...
Downloaded from nexusRepository: https://nexus.<omitted>/nexus/content/groups/public/<omitted>--stack-quarkus-deployment/0.5-SNAPSHOT/maven-metadata.xml (995 B at 22 kB/s)

But all of these imports are modules that are alle in the same git repo. And because it downloads all the jars, it does not pick up changes that might have happened in the other modules.

This causes all kind of errors::

ava.lang.RuntimeException:
  java.lang.RuntimeException: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
        [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type <omitted>.service.coastal.ContactOfInterestService and qualifiers [@Default]
      - java member: <omitted>.endpoint.http.coastal.ContactOfInterestRestEndpoint#contactOfInterestService
        - declared on CLASS bean [types=[<omitted>.endpoint.http.coastal.ContactOfInterestRestEndpoint, java.lang.Object], qualifiers=[@Default, @Any], target=<omitted>.endpoint.http.coastal.ContactOfInterestRestEndpoint]

And well, if I run mvn clean install, it then does work.

Expected behavior

(Describe the expected behavior clearly and concisely.)
@QuarkusTest annotation should use compiled source from the same git repo if possible, instead of downloading them. Same with quarkus:dev.

If not possible, properties should be added to allow these jars to be picked up.

Actual behavior

(Describe the actual behavior clearly and concisely.)
Quarkus always downloads the packages from your local or remote maven repository. Even if the dependencies are another maven submodule.

How to reproduce

Create a multi module maven project:
model (extension)
application (application).

Make application use model/extension without running maven install.
or just run mvn quarkus:dev.

It fails, because it cannot download dependency model.

reproducer:

https://github.com/RobinGoussey/quarkus-issue--17231

Java version

openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

OS

Linux 5.11.6-051106-generic #202103111435 SMP Thu Mar 11 14:42:39 UTC 2021 GNU/Linux

@RobinGoussey RobinGoussey added the kind/bug Something isn't working label May 14, 2021
@famod
Copy link
Member

famod commented May 16, 2021

Thanks for reporting this.

Can you please provide a reproducer? That would speed things up a lot and would avoid misunderstandings. Thanks!

Also, can you please add:

  • Quarkus version
  • Maven and Java versions
  • Operating system

@famod famod added area/maven triage/needs-reproducer We are waiting for a reproducer. and removed triage/needs-triage labels May 16, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented May 16, 2021

/cc @quarkusio/devtools

@stuartwdouglas
Copy link
Member

Nothing we can really do here, this is just how maven works. Just run mvn quarkus:dev from the top level to work around it.

@RobinGoussey
Copy link
Author

Well, I created a quick reproducer here:
https://github.com/RobinGoussey/quarkus-issue--17231

Basically, all our branches run on jenkins with a mvn clean verify, just to not corrupt other builds later on the system that might use the build artifacts (x-SNAPHSOT).

This is without the application and just the extensions, but it gives the same errors.

The same happens when I use:

  @RegisterExtension
  static final QuarkusUnitTest config = new QuarkusUnitTest()
      .setArchiveProducer(() ->
          ShrinkWrap.create(JavaArchive.class)
              .addClasses(MyBeanService.class, MyBean.class)
      );

Is this expected behaviour @stuartwdouglas ?
I would expect that I don't need to run a mvn install to make the tests execute. It happens because instead of looking in the compiled source, it pulls it data from the repository. Is there any way we can fixi this? Or is this just how quarkus and it's tests work?

@RobinGoussey RobinGoussey changed the title Quarkus multi module projects should use the compiled source, instead of downloading it from nexus. Quarkus multi module projects should use the compiled source, instead of downloading it from nexus (or local .m2 folder) May 17, 2021
@stuartwdouglas
Copy link
Member

You need a parent pom so that Maven knows they are all part of the same project. Maven has know way of knowing that the other folders in the repo have anything to do with the current project unless there is a parent pom that references them.

@RobinGoussey
Copy link
Author

Weird, I thought it was the aggregators job to bundle the build, and the parent is just inherited from, but in quarkus you use the parent to determine what other projects belong together?

Or do you need both? I'm a bit confused.

@stuartwdouglas
Copy link
Member

Ah, I did not fully look into the details, I just saw the lack of a parent and assumed they were unrelated. If you just add a parent pom

Quarkus only knows about the project structure from the POV of the project being run, in this case it has no idea about the other modules, as it does not know that maven has been run from an aggregator. If you make the aggregator the parent of the service-extension-parent then it should work fine.

@RobinGoussey
Copy link
Author

RobinGoussey commented May 18, 2021

Yes, indeed it then fixes the problems, you can also separate the projects, as is the default in our company. However this is information I haven't seen anywhere in the quarkus documentation, perhaps could you look into multi module projects documentation? Perhaps take this one with it? #6266

@stuartwdouglas
Copy link
Member

@aloubyansky I am pretty sure there is nothing we can do here, but just wondering what your opinion is?

IMHO the current behavior is fine, as using parents is the standard way to create a multi module project, and no matter what we do there will always be some way of laying out a project that causes us problems.

@aloubyansky
Copy link
Member

We can actually make this work. Stuart's right that our bootstrap fails to figure out what the top level project is. We can see the -f module-name but it's a relative path that we can't resolve. However, your project could be built if we add a property to the test plugins like

diff --git a/model-extension/pom.xml b/model-extension/pom.xml
index fa78b75..1ccf594 100644
--- a/model-extension/pom.xml
+++ b/model-extension/pom.xml
@@ -19,7 +19,7 @@
     <maven.compiler.target>1.8</maven.compiler.target>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-    <quarkus.version>1.13.4.Final</quarkus.version>
+    <quarkus.version>999-SNAPSHOT</quarkus.version>
     <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
   </properties>
   <dependencyManagement>
@@ -49,6 +49,7 @@
               <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
               <maven.home>${maven.home}</maven.home>
               <maven.repo>${settings.localRepository}</maven.repo>
+              <maven.topLevelProject.basedir>${session.topLevelProject.basedir.absolutePath}</maven.topLevelProject.basedir>
             </systemPropertyVariables>
           </configuration>
         </plugin>
@@ -60,6 +61,7 @@
               <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
               <maven.home>${maven.home}</maven.home>
               <maven.repo>${settings.localRepository}</maven.repo>
+              <maven.topLevelProject.basedir>${session.topLevelProject.basedir.absolutePath}</maven.topLevelProject.basedir>
             </systemPropertyVariables>
           </configuration>
         </plugin>
diff --git a/service-extension/pom.xml b/service-extension/pom.xml
index c3ae635..e534808 100644
--- a/service-extension/pom.xml
+++ b/service-extension/pom.xml
@@ -19,7 +19,7 @@
     <maven.compiler.target>1.8</maven.compiler.target>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
-    <quarkus.version>1.13.4.Final</quarkus.version>
+    <quarkus.version>999-SNAPSHOT</quarkus.version>
     <surefire-plugin.version>3.0.0-M5</surefire-plugin.version>
   </properties>
   <dependencyManagement>
@@ -49,6 +49,7 @@
               <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
               <maven.home>${maven.home}</maven.home>
               <maven.repo>${settings.localRepository}</maven.repo>
+              <maven.topLevelProject.basedir>${session.topLevelProject.basedir.absolutePath}</maven.topLevelProject.basedir>
             </systemPropertyVariables>
           </configuration>
         </plugin>
@@ -60,6 +61,7 @@
               <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
               <maven.home>${maven.home}</maven.home>
               <maven.repo>${settings.localRepository}</maven.repo>
+              <maven.topLevelProject.basedir>${session.topLevelProject.basedir.absolutePath}</maven.topLevelProject.basedir>
             </systemPropertyVariables>
           </configuration>
         </plugin>

and make the bootstrap check it (which is literally a couple lines of code). So I'll re-open this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/maven kind/bug Something isn't working triage/needs-reproducer We are waiting for a reproducer.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants