игор игор - 1 month ago 10
Java Question

Better way for inter-project development (with Gradle or IntelliJ)

I have two projects (not modules),

A
and
B
. Project
B
depends on
A
. I can run only
B
. Dependency is set through maven repo, where local repo is the first to look into.

When I need to change something in dependency
A
, there is a flow I repeat all the time:


  • go to
    A
    in IDE

  • build
    A

  • install to local maven repo:
    gradlew install

  • go to
    B
    in IDE

  • refresh gradle project

  • run
    B



Is there any better way how to skip all these steps? I was thinking into having a 'master' dummy project in my IDE (intelliJ) that will contain these two, so I can run and change everything at once.

Answer

Gradle 3.1 introduces composite builds. With it you can, e.g., create new project, that is a composite of other projects. This new project contains only two files:

settings.gradle

rootProject.name='we'    
includeBuild '../api.java'
includeBuild '../common'
includeBuild '../engine'
includeBuild '../io'
includeBuild '../io-redis'

build.gradle

task buildServer {
    dependsOn gradle.includedBuild('engine').task(':server:build')
}

Released soon, IDEA 2016.3 will support this.