0

I have a library and a program, both under my control and built using Gradle. What's the best way to develop these two at the same time?

I have set up a private maven repository to distribute the library and that's working, but I don't want to release to that repository every little experiment I make during development. It's slow and disruptive to users of the library.

I tried installing the jar to the local maven repository as explained here: Gradle alternate to mvn install but the project that's using the library is not picking up that newly installed version.

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622

3 Answers3

1

I think, you can try to use multi-project builds for that if it's possible. But you will likely need to restructure both your current projects to become modules of the same new project.

Stanislav
  • 27,441
  • 9
  • 87
  • 82
  • I'll probably explore this, although I still would like how to work on a completely independent library, in case I have to fork and work on one of my open source dependencies. – Pablo Fernandez Sep 15 '17 at 10:29
0

What's the best way to develop these two at the same time?

It depends by how the team is organized and what are your policies.
Of course if the team can use a git repo and access to the source code you can just use git without pushing a new version on the maven server for each commit or push.
Otherwise if other users can only use the final library, you have to push the version on the maven server.

I have set up a private repository to distribute the library and that's working, but I don't want to release to that repository every little experiment I make during development. It's slow and disruptive to users of the library.

Every maven repo has 2 different repositories:

  • release
  • snapshot

Usually release repo is used only for stable releases and the snapshot repo is used to publish little change, beta release and so on.
In any case it is not required that every changes in the code is pushed in the maven repo (it is a your choice)

It's slow

The time to upload artifacts usually is not so big, in any case you can evaluate to push the release in the maven repo with a CI server.

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
  • Build, upload, clean, download, build, test, repeat is a very slow cycle for development and if more than one developer are doing it at the same time, they'll step on each other's toes – Pablo Fernandez Sep 15 '17 at 10:25
  • @Pablo it depends by how the team is organized. If you can use a git repo it is not required to deploy and distribute the library updated for each commit and push. – Gabriele Mariotti Sep 15 '17 at 10:44
  • I don't have a team structure. I can use a git repo. What I'm trying to solve is without even making a commit. I'm at the code, compile, test cycle. – Pablo Fernandez Sep 15 '17 at 11:19
0

The best method seems to be to make one project include the other one when present by adding:

if (file("../libraryproject").exists()) {
    includeBuild "../libraryproject"
}

to the settings.gradle file of the project that uses the library. That can be committed to the source code repo because when that directory doesn't exist, the dependency will be included in the traditional way.

This is called Composite Build in the Gradle world, IntelliJ seems to handle properly and theres'a recorded webcast showing the whole setup: https://www.youtube.com/watch?v=grPJanXfRPg

Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622