Gradle alternate to mvn install

后端 未结 4 1975
野趣味
野趣味 2020-11-29 17:33

I have 2 different project build on mvn. I am trying to replace to Gradle.

Project 1 is an SDK, and project 2 is using that sdk (example).

In the time of maven

4条回答
  •  迷失自我
    2020-11-29 17:37

    Check out Gradle's documentation on multi-project builds.

    Here's an example, with some extra dependencies. Just call gradle install in the root folder, and all will be built and put to your local repo.

    Folder structure:

    root
    +--> build.gradle
    +--> settings.gradle
    +--> sdk
    |    +--> build.gradle
    +--> example
         +--> build.gradle
    

    root/build.gradle:

    allprojects {
      apply plugin: 'java'
      apply plugin: 'maven'
    
      group = 'myGroup'
      version = '0.1-SNAPSHOT'
    }
    

    root/settings.gradle:

    include 'sdk'
    include 'example'
    

    root/sdk/build.gradle:

    dependencies {
      // just an example external dep.
      compile group:'commons-lang', name:'commons-lang', version:'2.3'
    }
    

    root/example/build.gradle:

    dependencies {
      compile project(':sdk')
      compile group:'log4j', name:'log4j', version:'1.2.16'
    }
    

提交回复
热议问题