Stefan Winkler
Stefan Winkler

Reputation: 3956

Why does IResource.getRawLocation() return null for IProject

I need the absolute location of a project folder, so I tried

project.getRawLocation()

but this returns null (at least in my case in which I have imported the project manually using Import ... Existing projects into workspace and I have checked the Copy projects into workspace checkbox).

The thing is that

project.getParent().getRawLocation() 

returns /work/Projekte/runtime-MyProduct.product which is correct

and

project.members()[0].getRawLocation()

returns /work/Projekte/runtime-MyProduct.product/Test/.cproject which is correct as well.

Consequently, I'd expect that

project.getRawLocation() 

would return /work/Projekte/runtime-MyProduct.product/Test, but it returns null.

Can anyone explain and/or show me where I'm wrong?

Upvotes: 4

Views: 730

Answers (1)

greg-449
greg-449

Reputation: 111142

The JavaDoc for getRawLocation() says

If this resource is an existing project, the returned path will be equal to the location path in the project description.

and the JavaDoc for the project description IProjectDescription.getLocation() says:

null is returned if the default location should be used

The getLocation() call will return a path.

Upvotes: 6

Related Questions