Build dependency modules on demand for non-java module

I have a project that lists some dependencies via

configurations {
lib
}

dependencies {
lib project(":my-project")
}

This is not a ‘java’ project and i process these dependencies via own script. This module is part of the multi-module build and modules are lazy loaded via ‘org.gradle.configureondemand=true’. The problem with my custom non-java module is that its dependencies are not loaded and built by gradle before my project - it is build almost like a standalone module. For modules with ‘apply plugin: “java”’ gradle somehow builds all dependencies before the target module.

How can I configure script to enforce building of the dependency projects beforehand?

What are you doing with ‘my-project’ here?

For things like copy tasks or archive tasks, you can declare the configuration using from:

task copyStuff(type:Copy) {
    from(configurations.lib)
}

That way before the copy task is run, Gradle will create the other projects.

In order for this to work, you’ll need to define an artifact in ‘my-project’ and assign it to the ‘default’ configuration. Depending on the plugin (if any) used in my-project, you might already have artifacts assigned to the ‘archives’ configuration, or the default configuration.