.launch files in maven or gradle - eclipse

What is the "correct"/better place to put eclipse's .launch files in a maven/gradle project? I want to commit my run configurations but I don't know where to put the files
I know maven and gradle are always about standarization so I rather ask than put them in a random folder and then get in trouble with some plugin
After creating a launcher on each maven module now I have each launcher appearing twice in eclipse. This is due to the fact that when I check out my multi-module project it creates an eclipse project for the top POM as well as for each child POM and all the files are "duplicated" in the Navigator view, once for the top and once for each module. This to me means that either I have some problem in my maven organization or that I am putting the launcher in the wrong place
Edit
Since I asked this question I learned of a new way to solve this. Enable an experimental feature in eclipse which will prevent the subprojects to appear in the top project. The setting is under windows/preferences/maven/Hide folders of physically nested modules

The standard location in Eclipse is in the project's root directory, that's where I always save them (and commit to SVN). Maven will ignore them there by default, so they will not show up in your artifacts.
One additional thing to keep in mind (since you mentioned that you want to commit the launch configurations to SCM and possibly share them with others): Avoid absolute paths in the launch configurations, since they will probably not work for other people. Try to use relative paths or Eclipse variables pointing to your local resources.
Edit: moved comment that answers the question
In this case you might consider moving them to a sub-directory (launch?). It should be one that is ignored by Maven by default (so not src/main/java or src/main/resources. On the other hand, I'm not sure whether Eclipse will pick up the files from a sub-directory... I've always kept them in the project root.

Related

Eclipse doesn't see classes from Maven modules in workspace

We have some Maven modules shared between several teams, with the mandate to share the source code even though our projects use different dependencies and resources. To accomplish this, we have our modules set up as recommended in Using Maven When You Can't Use the Conventions under "Producing Multiple Unique JARs from a Single Source Directory." Specifically, we have a shared parent module containing the src directory but whose pom declares <packaging>pom</packaging> and only builds the two submodules. Each submodule inherits from this parent and refers to the shared src directory using this:
<build>
<sourceDirectory>../src/main/java</sourceDirectory>
</build>
The two submodules have different artifact ids, allowing dependent modules and projects to specify which version and dependency set they need. It also upholds the Maven principle of "one module, one output."
This all works great in Maven-land: compilation, installation, deployments, etc. What doesn't work well is Eclipse integration. Some things work fine: building the modules, deploying to our Maven repo, pulling in dependencies to build our project. But things such as code completion and jumping to class/method definitions do not work at all. It's as though Eclipse doesn't recognize the source at all.
If we just check out a module from SVN, Eclipse doesn't know about the classes but instead uses jars from the repo. If we then import the modules as Maven modules, they show up in package explorer and the project build path. However, all references to those classes and methods are now flagged as errors by Eclipse. And we still do not have code completion or navigation.
So my questions are these: How can we get Eclipse to recognize the code and do its normal code navigation while still satisfying our varying project requirements? Am I missing some simple Eclipse configuration? Do we need to rework our Maven module structure, and if so, how?
Some additional context: The different dependencies for the projects are rather large, including different major versions for things such as Weblogic and Spring. The Weblogic versions will converge some time next year, but the other dependencies will be slower (and some resource files will likely always remain distinct). So for the near- to mid-future, we have to account for different dependencies between the projects.
We are using profiles to allow our Jenkins server to build both submodules while allowing individual developers to build only the submodule their project needs. Using profiles to manage the dependencies is problematic because we lose transitivity of dependencies.
Update (12/8/15)
I was eventually able to make Eclipse recognize the source directory by using "Link Source..." on the "Configure Build Path..." dialog. Adding a source folder would not let me reference the module's parent directory, but Link Source let me assign an arbitrary directory to use. It's not ideal, but it seems to be working.
I was eventually able to make Eclipse recognize the source directory by using "Link Source..." on the "Configure Build Path..." dialog. Adding a source folder would not let me reference the module's parent directory, which derailed me for a while. However,Link Source let me assign an arbitrary directory to use.
It's not ideal, but it seems to be working. We can now jump to definitions with F3, and errors are now highlighted correctly. It's good enough that I don't feel bad recommending it to the other team. I wish Eclipse would automatically allow a parent source directory to be referenced, but at least the manual intervention worked right.

IDE neutral project in versioning system

I have a netbeans project that is under mercurial. What I would like to do is to strip down everything that makes this project netbeans project to only to leave code in there so that I can easily import it in say eclipse.
Is there some automated way to do this or do I have to remove manually this?
What approach would you recommend.
Cheers
You only have to add the nbproject folder to ignore (= don't check in). All NetBean-settings are placed in this folder. Dont check in the build and dist folder as well, because these contain the compiled code (but they are ignored per default).
The best way to do "IDE neutral projects" is to use Maven !
In NetBeans when the project is Maven-based (as opposed to Ant-based) you'll see that all those NetBeans-specific files that you normally see in nbproject folder are just not there. The nbproject folder doesn't even exist. The reason is that for a Maven-based project NetBeans essentially uses the pom.xml as the definition of the project and that's a good thing because the POM is portable and directly understood by other IDEs.
Even for a Maven-based project NetBeans will still store some IDE-specific stuff in a file called nb-configuration.xml but you can include all of the contents of this file as properties inside the pom.xml. These properties will then be ignored by other IDEs when they load the POM. This way you can pretty much avoid altogether to check any IDE-specific files into the VCS. Also it is worth mentioning that the stuff in nb-configuration.xml is never needed for someone else (using NetBeans or another IDE) to be able to build your project. Another way to put it is that it contains non-essential data. The POM - by virtue - is always guaranteed to be a complete description of how to build the project.
Contrary if your NetBeans project is Ant-based then at least in my experience you cannot avoid checking NetBeans specific files into the VCS ... because otherwise even those using NetBeans won't be able to correctly open your project.
However even with Maven there's one area where you'll be forced to have NetBeans-specific files in the VCS and that is if you use the Matisse GUI builder in NetBeans. The Matisse GUI builder produces some proprietary files with .form extension and you really need to have those in your VCS. But this is the only example I can come up with where NetBeans-specific files will need to go into the VCS assuming your project is Maven-based.
If the project indeed is Maven-based and you still feel that there are NetBeans-specific files that you need to have in the VCS then let us know exactly which files you're thinking of. Then we can take it from there. :-)

When commiting projects should I include .project & .classpath?

When I commit a web appliction to source control should I also include the .project & .classpath files ? I don't think it should make any difference either way as other users who use the project should have the same project settings ?
This is the sort of question that gets people bent out of shape in a debate that never ends. You basically have two camps:
Only put source code into the source control system. Each developer chooses their own IDE and manages their own project configuration. Setting up your IDE after getting source code from the repository will be tricky. If one dev changes project dependencies, they have to explicitly communicate that so that all other devs update their project configurations. There are some tools that try to address this problem, like a Maven plugin that will attempt to generate Eclipse project metadata from pom.xml, but all have their limitations. Groups that go this way favor the purity of not restricting developer choice in IDE over the convenience of having Eclipse projects across the team that just work.
Standardize on Eclipse. Put all Eclipse project metadata into source control. This includes .project, .classpath and the entire contents of .settings. Basically, the only thing that you don't want in your source control repository is content marked as derived in Eclipse. You can check that in right-click->properties. Taking this approach ensures that developers can get started coding immediately after getting the project from source control. No additional configuration required. Also, when one dev changes project configuration, the rest of the team will see the same change on next sync.
Choose the approach that makes the most sense for your team.
For ClearCase, including the .project and .classpath can make a difference when you are using the IBM ClearCase plugin for Eclipse.
That plugin will work better if it can rely on those (versioned) files being there, right next to the sources (as opposed as being in the Eclipse workspace, which doesn't necessarily contains said sources).
In general, nothing generated should go into repository. Those files are generally generated by IDE or maven. However, sometimes you may need to click a button or execute a command to get those generated.
i would include them.
The .project file have plugin info (e.g. maven, ant, pdt, wst, aspectj, findbug..). It is essential if it is not a plain java project.
.classpath contain the classpath. it is needed if you use jar files.
I would say that all files - including .project and .classpath - should go to source control, to ensure that everyone in the team has the exact same setup.

eclipse + svn: how to manage whole workspace with svn

I have a workspace with several projects that are build using maven.
I know that i can add each project separate to the svn, but how can i add my super-pom?
My super-pom is in the workspace directory and therefore not visible.
Can i configure eclipse to add the whole workspace directory to my svn?
Best regards
This is not exactly what you asked for, but I have used following pattern with svn-eclipse-maven combo quite successfully.
/pom.xml
- contains only referenced projects
/parent/pom.xml
- contains dependencies common to all projects, <dependencyManagement>, properties..
- the stuff you would normally put in root pom
/procject(X|Y|Z|...)/pom.xml
- normal project pom.xml:s
This way you only need to commit /pom.xml outside eclipse when you add or remove a project (witch is relatively rare). With this configuration parent and project:s are visible in eclipse and only root/reactor pom is not visible in eclipse.

Eclipse treating all the files in a project as Derived

I have created a Dynamic Web Project in my Eclipse workspace. It is also a Maven project, and under SVN control. But in "Open Resource" (Ctrl+Alt+R) no file from this project appears, unless I check from the window's options (top right drop-down) "Show Derived Resources".
I have checked on some of the project's folders and they are not marked as "Derived".
I have two more (plain Java) projects in the workspace, and all the files from them are visible in "Open Resource".
Do you know what might be wrong with either Eclipse, the Maven plugin or Subclipse (the SVN plugin)?
I experienced a similar issue in Eclipse (Ganymede), when using the Maven and Subclipse plugins. I have not determined which plugin caused this problem, but I suspect that it is related to my pom.xml containing nested modules (ie. a <modules><module>main-module</module><module>integration-test</module>). These appear in Eclipse as nested folders with their own pom.xml files (I did not use the Multiple Projects plugin although I have installed it).
I assume that one of the plug-ins has incorrectly set the derived flag on these folders when I checked out the project by SVN and then updated the MVN dependencies and project settings.
When I right click->properties on the top-level nested module directories I can see the Derived flag is checked. By unchecking the derive flag on the module directories (and checking the derive flag on the target directories within each sub-module instead), it fixed the Open Resource functionality.
As the derived flag is inherited from directories, you may need to check all of your directories in the hierarchy to find the 'culprit'.
If it helps the plug-in authors, my top level module directories contain a hyphen '-' in their names. Maybe that is throwing out one of the plugins.
I think it is the maven plugin:
Jira issue
See also the notes for July 31, 2008 at the New and Noteworthy page for m2eclipse.
Several other nice links deleted because of restrictions of stackoverflow.
In fact, I think that somehow this is eclipse in its own right, as I don't have m2eclipse or using maven for this.
By default, eclipse uses /bin as the target directory. My situation is similar to having maven in the project in that the target directory was changed to lib/classes to accommodate an existing project.
I started seeing issues similar to what is reported here, and while searching for the problem, came across this solution. Eclipse somehow didn't "uncheck" the bin directory as no longer derived, so I ran into the same issues. I tried replicating it, but I couldn't.