Multi-Project (native) with Nexus-Dependency

Hi.
In a native C++ multi-project, I have module with the following project structure:

Module
build.gradle
settings.gradle
– demo
---- build.gradle
---- src
– library1
---- build.gradle → upload to Nexus
---- src
– library2
---- build.gradle → fetch dependency from Nexus, upload own lib
---- src

library2 depends on library1.
demo depends on library1 & library2.

The requested order is:

  1. build library1 and upload to Nexus
  2. build library2 and upload to Nexus
  3. build demo

It works, if I execute the build steps in the requested order.

Now I want to have a single build step for the whole module from scratch.
That does not work as libraries have configuration dependencies to Nexus-repo which is empty.

How can I instruct the build to first build library1 and upload it, if the dependency could not found?

What are our opinions about this approach?
(Think about of delivering a whole module including some subprojects to a customer. You want to give him one single command to build the whole application)

Why spend the extra time going through a Nexus server when all the required binaries are already available locally?

Because this library is also mandatory for other modules.
And they will fetch it from Nexus.

IMO, usually one would only want to publish artifacts to a repository on demand (CI builds, developer explicitly does so for reasons XYZ). Are you saying that you want every single build that anyone performs to publish artifacts just so that a build can succeed, despite the fact that everything required is already available locally?

Sorry for all the questions, I just think this sounds like a terrible idea, but I want to make sure I’m understanding you correctly.