[ECLIPSE][IDE] How to set project name dynamically [message #1807966] |
Thu, 13 June 2019 12:16  |
Eclipse User |
|
|
|
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 #1808420 is a reply to message #1808416] |
Mon, 24 June 2019 10:25   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.09359 seconds