There is such a project structure.

ProjectMain build.gradle Project1 release my.jar build.gradle 

The main ProjectMain project needs a Project1/release/my.jar . In build.gradle for Project1 required logic is written (by generating the jarnik), it is necessary that the dependencies from my.jar used when building ProjectMain .

How to implement it? (preferably with examples of groovy code)

PS before it was used ant, and there with it was just

 <target name="one"? <path id="project.classpath"> <fileset dir="${Project1.release}"> <patternset includes="**/*.jar"/> </fileset> </path> </target> <target name="Two"> <javac srcdir="${src}" destdir="${out}" debug="on"> <classpath refid="project.classpath"/> </javac> </target> 

    1 answer 1

    This is described here: https://docs.gradle.org/current/userguide/multi_project_builds.html

    If in a nutshell, you can specify a dependency for the taska:

     task buildWithSubProject( type: Jar, dependsOn: Project1.tasks["build"] ) { 
    • How does my build.gradle understand that Project1 is the one I need? How do I set the path to it? - Andrew Bystrov
    • In this example, Project1 is a subproject of ProjectMain. Gradle himself will find it by name. If you want Project1 not to be a subproject, then you need to specify it as an external dependency. You can use the local maven repository for this. - Max
    • Project1 is not a subproject. They lie next to each other - Andrew Bystrov