java - Gradle - import GitHub repository and make it a subproject dependency? -


i trying avoid multi-project builds deploying jar file dependencies, undermined nimble workflow , need faster way make git repositories dynamically add each other dependencies. i'm sure write creative deployment procedures using jar files, changes 1 project ripple other dependent projects without intermediary deployment.

i looking through grgit documentation, , see allows branch cloning operations. how extract working tree after clone , include dependency, assuming repo has own gradle.build script?

repositories {     mavencentral() }  apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'idea'  dependencies {     compile group: 'com.google.guava', name: 'guava', version: '18.0'     compile 'org.xerial:sqlite-jdbc:3.8.7'     compile 'net.jcip:jcip-annotations:1.0'     compile 'joda-time:joda-time:2.7'     compile files('path/to/my/repo') //not quite sure here???  }  task downloadgitdependency {      def grgit = grgit.clone(dir: 'path/to/my/repo', uri: 'git@github.com:ajoberstar/grgit.git') } build.dependson downloadgitdependency  sourcesets {     main.java.srcdir "src/main/java" }  jar {      configurations.compile.collect { entry -> ziptree(entry) } } 

if list of subprojects (fairly) static , each has own build.gradle, add them git submodules. in project dir, do:

git submodule add git@github.com:ajoberstar/grgit.git path/to/my/repo cd path/to/my/repo git fetch  # either (to switch different branch): git checkout -b mybranch origin/mybranch  # or (to check out particular ref on current branch): git checkout deadc0de  # or both of above (to check out particular ref on different branch) 

(note: git url used in example add grgit subproject—unless want, use url of remote repo subproject here. path/tp/my/repo arbitrary path within project tree subproject cloned.)

then, add subproject main project’s build config: import in settings.gradle , define dependency in build.gradle.

git link main modules’s commit particular commit of submodule.

be advised, however, working submodules in git not without pitfalls: don’t commit submodule (always commit upstream), , sure run git submodule update each time head changes (pull, merge, checkout etc.). article on pitfalls of git submodules at: https://codingkilledthecat.wordpress.com/2012/04/28/why-your-company-shouldnt-use-git-submodules/


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -