How to show shortened project names in the Eclipse package explorer? - eclipse

I work for a big company that has standards on Java project names. Long standards:
com.company.department.subdepartment.stream.project
Rather than let the package explorer take up a sizable portion of my screen, I'm looking for a way to shorten the project names. Mousing over project names shows the full name, but it's still very slow to determine which project I want to look at next with the incredibly long names. As has been answered before, package names can be shortened. I've got a rule set up, but it only works for packages:
com.company.department.subdepartment={department}
Is there a way to do an analogous thing for project names in Eclipse?

Package explorer uses the org.eclipse.jdt.internal.ui.packageview.PackageExplorerLabelProvider class to provide the view labels. Going through the source of this I don't see any support for shortening the project names.

The following ideas depend on how your eclipse workspaces are setup. If you're lucky and you just import project from your VCS, these could work for you.
If you're using maven, Eclipse project names are usually derived from your GAV. The Import as Maven project wizard has options for what pattern to use for the project name based on your maven GAV.
Otherwise, you can sometimes just right click the project -> rename. YMMV if you have any scripts or such that have the project name hardcoded. If you have these constraints, find those scripts and use variables rather than hardcoding.

Related

Sharing common helper scripts among projects in VSCode

I have a few utility functions, snippets and scratches that I want to be able to use in every project.
Currently I have the following setup for Clojure projects and Intellij IDEA/Cursive:
I have a user profile defined in .lein, where I have source-paths pointing to
when I sync and run REPL for project in IDEA/Cursive, I check that :user profile is selected (it is the default)
Cursive shows both project files and common files (i.e. scratches folder) in project pane
I can edit and eval in REPL real project files and my local helers/scratchpads seamlessly.
Is there a way to achieve this behaviour in VSCode?
Notes:
My clojure setup in Cursive is for illustration purposes only. I would like to find a way to get similar feature in other scripting languages (i.e. python, groovy). So ideally I don't want to use leiningen for that, but rather find a generic way to add common source folder to VS code Explorer pane.
I know that with multi-root workspaces I can achieve what I want, but it must be done manually per project. It would be much better if my folder with common utils was added to every workspace automatically. Something like a default workspace template would solve this, but I couldn't find anything similar. Am I missing something?

Multiple Xtext DSLs in single Eclipse project

I would like to know if there is a way to organize multiple DSLs inside a single Eclipse project. More specifically, I would like to organize all five Xtext projects of a DSL in some top-level "project folder".
The background is that we manage complexity and enable reuse by making smaller reusable DSLs, e.g. one reusable for expressions and other one for more domain-specific or application-specific aspects. However, each Xtext DSL results in 5 projects, causing a lot of clutter in the Package Explorer when multiple DSLs are involved. A strongly related question has been asked before:
Xtext: define 2 DSL's in one project
The answer there is that multiple DSLs are not needed inside the project for that specific use-case. My use-case is different because I want to be able to easily view the different DSLs and potentially co-develop them.
We are using Xtext in an environment managed by Gradle. We are using the Gradle Eclipse plugin, which creates a lot of Eclipse project files everywhere. As a result, when choosing to "Open Project from File System" in Eclipse, I not only get the option to import the five projects related to the DSL, but also the option of opening the parent folder as a project. This means I can have each DSL (all its five projects) organized neatly in a "project folder". This is exactly what I want! ...
BUT ...
it does not actually work. The figure below shows my package explorer with the five projects of my ExperimentDSL included in the bottom. This DSL works. On top, it shows the folder structure I get when including the project file generated by Gradle, resulting in a "project folder" that can potentially contain multiple DSLs.
As you can see, GenerateExperimentDSL is flagged red and refuses to run. It seems Eclipse somehow treats it as a Java project, but I do not know how to change this or and if this would help solve my problem. Secondly, I would not know how to set up such a project by hand, since the project file in this failing case was generated by Gradle.
Long story short, does anyone know how to get this kind of folder structure to work so that I can keep all my DSLs in the workspace without clutter?
What you try to do is currently not possible. Have a look at the concept of WorkingSets in Eclipse that let you achieve something similar

How do I combine projects in eclipse?

I have a lot of projects in Eclipse and I'm trying to tidy it up with something simple like a folder. Is there any way to do this so i can have, for example all projects for a particular client in one collapsable folder?
You can achieve this organization within eclipse without actually changing the filesystem structure of your projects. The feature, to cut to the chase, is called Eclipse Working Sets.
The gist is working sets are groups of projects or resources, and most of the eclipse views (package view, enterprise explorer, navigator, etc) can honor and switch between working sets.
Create a working set of type Resource, select the projects you want, then in the package explorer carat drop down (I'm looking at eclipse Kepler) you can either have the top-level elements be the working sets (e.g. a folder-like view per client) or you can filter out stuff one working set at a time.
Some other uses for working sets might be projects of certain types, Java vs. C++ projects, etc. as outlined in this older tutorial.

using eclipse and maven, is there a quick way to mark all target and subfolder as derived?

I am working with eclipse on a mavenized project which has a significant number of modules/subfolders/maven subprojects.
Whenever I look for a resource, or make any kind of research, it shows me every occurrences in every project times two because of the target folder...
example:
projectA/projectB/src/main/resource/.../Foo.xml
if I look for a string that is in foo.xml, it will show:
projectA/projectB/src/main/resource/.../Foo.xml
projectB/src/main/resource/.../Foo.xml
projectA/projectB/target/main/resource/.../Foo.xml
projectA/projectB/target/main/resource/.../Foo.xml
That is a lot for one file. Besides, let say that the prohectA is intended to create a pom, not a war, a jar, or a ear... The problem is now, that if I select this entry, I won't be able to use the auto completion, or the inspect element functionality (that I can't work without!!!!). Even worse: if i select a target directory, my changes will be overwritten on the next maven build...
What can I do? At the moment, I am just paying attention, but it is kind of painful... And I do not have time to go through all the project to mark them one by one as derived (basically around 1000 clicks), so they do not come up in the searches... Besides, the target folder would just appear again after the next maven build.
Any ideas?
The perfect way would be to have eclipse recognize the subproject nature of these, and not show the different occurrences... and maybe setup a filter for the target resources... I do not know if it is possible.
I am also willing to write a tiny script, if people are kind enough to explain to me what eclipse files it should modify in order to accomplish this.
Import the sub projects as separate Eclipse projects (this should happen automatically if you point the Maven import wizard at the master project directory). Keep the master project closed if you're not editing it. You'll still get the target folder version of resources, but at least only once.
You could use that AutoDeriv Eclipse plugin here AutoDeriv to list the paths you'd like to mark as derived, and discard from research etc. as you would do in a .gitignore file.
Once it's done, resources are always correctly marked as derived, even after a maven clean/install.
[edit]
You can write rules at workspace level, to handle several projects at once.
Exclusion rules allows you to mark everything as derived, except for a peculiar folder or file.
Since the 1.3.0 version, Eclipse decoration helps you to quickly see the effects of the plugin.
Disclamer, I wrote it =)

How to create .jar from specific package (without main) in Netbeans?

There are a lot of similar questions, but none for this specifically. I have a Netbeans project with a bunch of packages. Only one has Main. I'd like to be able to create a .jar from just one of the packages (and all the classes it contains, of course), which doesn't have main.
Is this feasible without having to put that package in another project or without having to screw around with build.xml? If the latter, any easy way or good rtfm links?
The point is i'm developing part of an application for college, each group member is developing a module of sorts. If each could provide their .jar the main project can just include jars and use them. I'm guessing all the mains in the jars wouldn't really hurt? But still...
You can use the project properties to customize your project's jar file content. This screenshot shows what it looks like for a Java Class Library project.