[GRADLE-1979] Tooling API: Respect user-defined 'GradleConnector.installation' property Created: 02/Dec/11  Updated: 04/Jan/13  Resolved: 08/Dec/11

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-6
Fix Version/s: None

Type: Bug
Reporter: Denis Zhdanov Assignee: Unassigned
Resolution: Not A Bug Votes: 0


The code as below for working with gradle tooling api:

GradleConnector connector = GradleConnector.newConnector();
ProjectConnection connection = connector.connect();

The problem is that only the first value of 'GradleConnector.installation' property is used if we do that more than one time within the same java process. I.e we have the following sequence:

  1. Execute the code against gradle milestone-6 installation;
  2. Everything is fine;
  3. Execute the same code within the same process but use milestone-3 installation;
    Expected: call to 'connection.model() fails because there is no BasicIdeaProject.class at the 'milestone-3' distribution
    Actual: the processing is ok

Comment by Adam Murdoch [ 02/Dec/11 ]

The model() method creates a builder for fetching the model. It does't do any work until you call one of the get() methods on it:

ModelBuilder<BasicIdeaProject> builder = connection.model(BasicIdeaProject)
// Do some stuff with the build - add listeners, etc
builder.get() // This is where it would fail

Comment by Denis Zhdanov [ 02/Dec/11 ]

Am I right understanding that the tooling api uses correct gradle distribution if I work via ModelBuilder instead of 'connection.getModel()'?

Comment by Adam Murdoch [ 04/Dec/11 ]

They both use the correct distribution. The only difference is in when the distribution is actually used and verified:

ProjectConnection connection = ...
result = connection.getModel() // uses the distribution here. Will fail if incorrect version used

ModelBuilder<BasicIdeaProject> builder = connection.model(BasicIdeaProject.class) // doesn't do anything yet. Won't fail.
result = builder.get() // uses the distribution here. Will fail if incorrect version used

You can use whichever method you prefer.

Comment by Denis Zhdanov [ 08/Dec/11 ]

Looks like it was my mistake - just created simple test and it shows that the tooling api behaves as expected.

Please close the ticket

Generated at Wed Jun 30 12:09:31 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.