Gradle + Buildship - dependency between JAR and projects

I'm having trouble setting up Buildship for Eclipse the way I want. Currently, I have> 50 projects that always open in Eclipse, but I want to go only to those projects that I am actively working on in Eclipse, and other projects will use the Maven repository to solve their dependency.

Suppose ProjectA (containing the main one) depends on ProjectB (library project). If ProjectB opens in Eclipse, I would like ProjectA to use ProjectB directly. Changing the code in ProjectB would be noticeable when ProjectA started. However, if ProjectB is closed, I would like ProjectA to use the ProjectB JB located in the Maven repository mentioned in the build.gradle file.

The behavior I'm talking about is described in detail here .

Is there a way to do this with Buildship? Or should I use another Gradle Eclipse plugin?

+8
eclipse maven-2 build.gradle gradle gradle-eclipse
source share
2 answers
  • The new version of Gradle 3.1 adds a new feature to support composite assembly . This function is a game change and simplifies the work on several projects at once.

  • You can use dependency expansion rules to replace repository dependencies with local project dependencies.

  • If each project is within its own separate git / subversion repository, you can use the prezi pride to control the pride of the projects. You can import (dynamically generated) assembly of several modules into buildship.

  • If you want to use the eclipse plugin instead of buildship, you use whenMerged or thank you intercepts the generated .classpath files to point to the projects inside your workspace (note that eclipse will now build differently on the Gradle command line).

+8
source share

To finish, I ended up working with dependency replacement, as suggested by Lance Java. This approach has the following advantages:

  • No third-party software required.
  • Regardless of IDE. We do not redo the .classpath file directly, we allow the Eclipse plugin (or any other IDE plugin).
  • Other plugins can access the actual dependency we want to use.

However, there are some problems with this approach:

  • Dependency substitution cannot be performed inside a task . This must be done either in the build.gradle file or in the method that is called from the build.gradle file.
  • You need to update your workspace.
+2
source share

All Articles