Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » [ECLIPSE][IDE] How to set project name dynamically(Using SVN we need to find a way to change the project name set in the eclipse project file of the ECLIPSE IDE automatically)
[ECLIPSE][IDE] How to set project name dynamically [message #1807966] Thu, 13 June 2019 12:16 Go to next message
David Schmittwilken is currently offline David SchmittwilkenFriend
Messages: 5
Registered: June 2019
Junior Member
The eclipse project file (.project) currently defines the project name statically in the name xml tag(<projectDescription><name>xxxx</name></projectDescription>), but we need to adjust it dynamically based on the current branch name because we have several branches checked out at the same time. At the moment we change the project name manually in the file based on the folder name of the branch, but we want to automate that somehow. Is there any way to do that?
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1807971 is a reply to message #1807966] Thu, 13 June 2019 14:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Have a look at org.eclipse.core.resources.IProject.getDescription() and org.eclipse.core.resources.IProject.setDescription(IProjectDescription, int, IProgressMonitor)
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808416 is a reply to message #1807971] Mon, 24 June 2019 09:09 Go to previous messageGo to next message
David Schmittwilken is currently offline David SchmittwilkenFriend
Messages: 5
Registered: June 2019
Junior Member
I googled a lot to find out how I can use the Eclipse API, but I couldn't find out how to automatically set the description for all branches, after checking them out. Probably it is much easier to change the project name by just editing the .project file via script.
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808420 is a reply to message #1808416] Mon, 24 June 2019 10:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
You'd need to call org.eclipse.core.resources.IProject.getDescription(), modify the description and then call setDescription. But all the views already decorate the project with the repo and the branch name, so I'm not sure why you'd want to change the project name itself; wouldn't that also then get committed given one generally commits the .project file?
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808650 is a reply to message #1808420] Fri, 28 June 2019 08:14 Go to previous messageGo to next message
David Schmittwilken is currently offline David SchmittwilkenFriend
Messages: 5
Registered: June 2019
Junior Member
When importing a project the name of the project set in the .project file is shown in the eclipse project explorer. The problem here is that each developer creates multiple private branches from a common source called team branch and all of them then have the same name and you can't import them into eclipse at the same time unless you change the name in the .project file. My current solution is to edit the "project" file directly via python script. I would have liked it better if the eclipse IDE changes the name of the project when I open it. For that of course eclipse would need a base path in which it should check for project files and then automatically import them. I am now fine with my python solution but for the sake of completeness I would like to know how to use the eclipse java api. Is it correct that I have to create a java project where I can use that library and than export it to a library "jar" file, which I then have to import as a plugin into eclipse? If that is correct, how that the custom plugin know when it has to be execute one of its library functions? Is it possible to tell eclipse to execute one of the functions on startup? Unfortunately I couldn't find a tutorial about that.

Answering your question:
1. The eclipse project file is not in scope for a svn merge unless it is intentionally changed. So there are no conflicts.
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808654 is a reply to message #1808650] Fri, 28 June 2019 08:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Changing the name of the project of course changes the .project file; such a change is likely to be committed back to the source code repository. One would not generally want a "checked out" project to be dirty, i.e., to be in a different state (even if just the contents of the .project file) than the state it is in the source code repository.

I really don't think the path you are wanting to take is a feasible one and I don't think it's generally sensible to try to check out two different "branches" of the same project in the same workspace. After all, how would any project know which of its multiple variant dependencies to use to resolve its dependencies? I think your goal doesn't make sense and that's why you see no support for such a thing, i.e., the team providers such as Git do not allow one to check out projects from different branches at the same time in the same workspace...
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808663 is a reply to message #1808654] Fri, 28 June 2019 10:59 Go to previous messageGo to next message
David Schmittwilken is currently offline David SchmittwilkenFriend
Messages: 5
Registered: June 2019
Junior Member
When using git I totally agree to you but when using svn it is common practice to have multiple branches checked out at the same time and in the same eclipse project because svn branching is based on folders. Unfortunately it is not possible for us to switch to git. Anyway is the following correct?

Quote:
I would like to know how to use the eclipse java api. Is it correct that I have to create a java project where I can use that library and than export it to a library "jar" file, which I then have to import as a plugin into eclipse? If that is correct, how that the custom plugin know when it has to be execute one of its library functions? Is it possible to tell eclipse to execute one of the functions on startup? Unfortunately I couldn't find a tutorial about that.
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808667 is a reply to message #1808663] Fri, 28 June 2019 12:26 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Yes, of course its impossible with Git because Git has only one working tree. But what you're trying to do can't be such a common practice or the Eclipse SVN support would have tried harder to provide such a thing. And as I said, I think the problem will be bigger than you realize once you start going down this path. Yes you would need to implement a plugin, you would need to install that plugin, and you would need to try to integrate that with the SVN checkout processes. And it's kind of a chicken and egg problem. You can't create the IProject and then rename it because creating it will always fail if the name conflicts, so you have to intercept early in the process, likely somewhere deep down in the SVN support where there are likely no APIs for doing such a things. In any case, the project description has to be modified before the IProject for that description is created, and that doesn't sound like something you can all handle on startup but rather something you need to handle each time SVN checks out a project. And even if you get that all working, then the question that will arise is how do you manage the dependencies between projects (so that you can manage the classpath, for example). Or are these not Java projects nor even projects with project references to other projects? What kind of projects are they?
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808729 is a reply to message #1808667] Sun, 30 June 2019 11:40 Go to previous messageGo to next message
David Schmittwilken is currently offline David SchmittwilkenFriend
Messages: 5
Registered: June 2019
Junior Member
There are no problems with dependencies because the include paths for the eclipse indexer are set with relative path and the compilation is done via makefile. In our case there are no dependencies between projects because we only have one which is an embedded software project.
Re: [ECLIPSE][IDE] How to set project name dynamically [message #1808736 is a reply to message #1808729] Sun, 30 June 2019 18:03 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
So that one would be hard to check out twice, for example, and that's the general case, and though you only have one, you do have one nevertheless.
Previous Topic:Image Report
Next Topic:installing 2019.06 versions of Eclipse CDT on CentOS6
Goto Forum:
  


Current Time: Thu Oct 17 15:31:05 GMT 2019

Powered by FUDForum. Page generated in 0.03738 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top