Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle. How to copy resources from another module

I have 2 modules: A and B. Module B contains /src/main/resources/file.xml, but module A also dependent on this file.xml at runtime. Is it possible to copy resources from module B to module A during build? I've been used maven-resources-plugin in Maven for this goal, but I can't find a similar thing for Gradle.

like image 866
Mykola Yashchenko Avatar asked Mar 09 '23 22:03

Mykola Yashchenko


1 Answers

The solution is quite simple:

sourceSets {
    main {
        resources {
            srcDir '../B/src/main/resources'
        }
    }

    test {
        resources {
            srcDir '../B/src/main/resources'
        }
    }
}

Maybe there are other solutions, but it looks good to me.

like image 167
Mykola Yashchenko Avatar answered Mar 21 '23 08:03

Mykola Yashchenko