.project files contain references to the project natures used in the project.
These project natures are dependent on the plugins installed on the local developers machine.
So, should this file be excluded from SVN?
Will nautures unknown to other developers cause problems?
Thanks
It depends on your situation.
Indications for putting them under version control:
you are talking about a team in a company context. You should be able to enforce a common developer environment, unless you also have an organizational issue.
everyone is using Eclipse
you want to make it more easy for newbies to just check out the project as such from SVN (without recreating it as a new project)
Indications for not putting them under version control:
the people (or IDEs) working on the project are very different (like in public open source projects)
you want to also use the project on an integration server like Hudson/Jenkins. You need to use Maven or some other standardized artifact lifecycle management tool outside Eclipse then.
The best solution: Use Maven to describe your dependencies and build process completely independent of Eclipse. Afterwards use Tycho to "act as a broker" between the Maven and the Eclipse world. That way you know exactly what to put under version control and everyone will produce exactly the same builds (independent of what IDE he uses or which plugins are installed).
I never commit those (esp .project) and always vote for them to be svn:ignore'd. Maybe I'm wrong but I only commit code to SVN and then make a new project by checking out from SVN.
Every time I checked out a project which had those files commited literally BROKE my project. But then again maybe thats just my coworkers...
By breaking i mean converting these
src/com.package.name1
src/com.package.name2
src/com.pack.name1
src/com.pack.name2
to these
src/
src/com
src/com/package
src/com/package/name1
src/com/package/name2
src/pack
src/pack/name1
src/pack/name2
and other sorts of unnecessary irritations... like them not being recognized as packages anymore but as folders. One of those things that makes you have to run eclipse -clean or delete/reimport a project or waste time on eclipse stuff you don't wanna waste time on.
Related
I work with a partner in java programming, I use intellij and he uses Eclipse.
Is there a way that we can somehow mutually share our code with each other so we could work on the same code each in our own time?
Thanks
There is that possibility using GIT or another Code repository. Look at https://github.com/
or https://bitbucket.org/. There is also very helpfull article.
To be also independant you can simply integrate your code with Maven, both incellij and eclipse can import project based only on pom.xml file created in maven setup.
In this your should use repository when there are more than one programmer on a single project whether you are using even same IDE. SVN will be one of the choices for repository
Given that you guys need to implement version control, one important aspect of co-operating together is to keep your codebase IDE-agnostic.
Thankfully, with java and maven there is an easy way to do this.
Firstly, commit to building your project with a build tool such as maven. Therefore, using this example, the pom.xml is the master configuration file for your project.
In contrast, your "project" files (either your .idea folder for intellij or your .project, .classpath and related files for eclipse) should not be checked into version control at all.
You can then add "ignores" to your VCS so that IDE-specific configuration files are not checked in - this way you won't interfere with each other with IDE-specific things.
Then, it is relatively easy for both of you to share a maven (pom.xml) based project with each other, and to configure your IDE independently from each other (i.e.: locally).
It is the following situation:
I currently have multiple Java projects in Eclipse. All the sources, build files etc are checked in at a repository. If a new team member joins the project he has to rebuild the complete setup (setting build path dependencies, adding special libraries).
I thought if that could be automatically done some way, e.g. using an ant file to do all the configurations of eclipse or the servers (tomcat).
Anyone ever found a solution for this?
Check in the .classpath and .project files and you should be set!
(More information about the .project file.)
I believe that you might use Maven too.
But that would require quite an adjustment, I believe.
We as a development team were always happy with subversion and eclipse, we checked in everything and everything was fine. Until we had a new hire who's using anything but eclipse (RAD ). his RAD checkins are currently polluting the svn repo withholding our eclipse checkouts to finish building.
One solution may be to force eclipse in the new hirer's throat, another more subtle and probably more suitable approach is to make our project ide agnostic.
Instead of removing the files by trial and error I hope to learn a quick and reliable solution.
I already learned that i should
remove files and add them to the svn
global ignore. I'm wondering is there
a way to make this project wide
instead of having everybody fixing
their own svn config? Something to add to your root .svn directory?
I'm also
looking for a list or even script to
remove the eclipse files and
directories from the svn repo
(.project .settings .classpath??
.externalToolBuilders .springBeans)
without running the risk of
completely ruining the workspace.
I'm
also intested in finding the quickest
way of restoring the workspace, as
we're using maven for software
project management I can do mvn
eclipse:eclipse in the root of
workspace but how do I find what the
proper WST settings are, and what is the quickest way or restoring your path settings in eclipse ?
I thought that many people would have been faced with the same use case, and consequently had the same questions but I haven't found anything on Google yet. Hopefully somebody here can point me in the right direction.
If you want to have a language-agnostic code repository the question is less about which files to exclude that about which files to include. Meaning, in a language-agnostic repo there should really only be the files necessary for the project:
source files, libraries, property files, .xml config, ...
built stuff, i.e. .class files, archives, ...
You should certainly exclude:
.project - this is project specific config by eclipse
.settings folder - this is project specific config by eclipse
.classpath - also eclipse specific
In Eclipse there is a 'global' ignore list for files which are shared to repositories via SVN, CVS, etc. You can find it here:
Window > Preferences > Team > Ignored Resources
If you're looking for something outside Eclipse, try the global-ignores config in your local subversion config. Add this to your ~/.subversion/config file.
global-ignores = build *.mode* *.pbxuser *~.nib .DS_Store *~
Mind that if excluding the Eclipse config from the repos you'll have to set up your projects after a checkout more specifically.
However, as you say you're using Maven this should not pose too many problems for you actually. If the pom.xml files of maven projects are configured correctly and completely, you can easily import a project from SVN via 'Import as Maven Project' - Eclipse will do all the right config for you on the import. (For this you need the m2Eclipse Maven Plugin, but I guess you'll be using something like that already? Anyway, here's the link: http://m2eclipse.sonatype.org/sites/m2e )
As for your question concerning a script to clean the repo: I'm not aware of such a thing right now, and I'd be very careful with this. Sounds like a lotta things could go horribly wrong. ;)
Last but not least, restoring the workspace:
In my experience, it is often the easiest thing to just delete your project locally and to a fresh checkout 'as maven project'. This way Eclipse will reconfigure all the important stuff. I have spent hours on broken Eclipse config, sometimes it tends to just get stuck and fails to be able to recover - especially if you're working with a lot of plugins which tend to do some of their own configuration magic. (And happen to be not exactly bug free...)
Perhaps the reason I stalled learning Java until now is because I HATE how Java handles external libraries. I'm stuck keeping them in one place, adding them individually, fixing problems with versioning and every time I move/rename them, and copying and writing the classpath over and over each time I release a Java application.
There has to be an elegant solution to all of this. I keep all of my libraries (regardless of task, platform, or other) in their own little folder inside a "lib" folder in my development folder, kind of like this:
Dev
-lib
+JS-jQuery
+Flex-Degrafa
-Java-Xerces
+Xerces-1.2.3
+More libraries
I can use either Netbeans or Eclipse for Java dev, but none of them provide a very streamlined (and not to mention idiot-proof) way of managing all of these.
A nudge in the right direction or an online article/tutorial on this would be greatly appreciated.
You can either use Ant + Ivy or Maven to manage your library dependencies.
If it is only dependency management you're after and you're happy with the rest of your build process, I would use Ivy, as it can unobtrusively manage your dependencies, leaving your existing build process intact. There is a plugin for Eclipse called IvyIDE that contributes your dependencies via a classpath container.
Maven 2 has a steeper learning curve but provides a much richer set of functionality for building your projects and Eclipse integration through m2eclipse or IAM.
Personally I use Maven as I have a large number of projects to work with and Maven is particularly suited to efficient development across lots of projects.
Have a look at the introductory documentation to see what works for you.
Ivy Tutorial
Maven Getting Started Guide
Netbeans 6.7.1's Maven support is quite good and comes out of the box with the IDE.
The Eclipse addon was frustrating enough that I gave Netbeans another try.
A third choice besides ChssPly76's options is to use Ant with the Maven Ant Tasks. I don't know if I'd call any of these solutions particularly "elegant," but they do spare you the need to manage your own lib/ directory and classpath variables.
If you're working on Linux you can install Java libraries with APT or RPM.
Otherwise, I normally check precompiled JARs into a lib directory in my project's version control repository and make sure the names of the JAR files include full version information. E.g. lib/foo-1.5.6.jar, not lib/foo.jar.
To avoid having to manually set the classpath before running your app, you can set the classpath in the Manifests of the JARs themselves to define the dependencies of each JAR file. The JVM will follow all the dependencies when loading classes.
Maven is often more trouble than it's worth, but the ability to open a maven project directly into IDEs such as IntelliJ is excellent. For example, IntelliJ will download all dependencies and have them available without having to run a build first, or an mvn command and then a project refresh. It also isn't necessary to re-generate the project every time a dependency is added. I work with a number of Eclipse developers who switched to IntelliJ for this alone.
However, one shortfall of Maven is that many libraries (or versions of libraries) are not available on public repositories. Therefore it is often necessary to set up a local repository such as archiva. In ant, it would just be a matter of adding it to the lib directory in the repository.
Maven can also attack when you need to do something that maven doesn't directly support via a plugin. What would normally be a few lines of ant can often turn into a morning's worth of work.
Finally, buildr is an excellent way of using Maven's dependency management and plugins, while also supporting ad-hoc tasks.
We have several products which have a lot of shared code and which must be maintained several versions back.
To handle this we use a lot of Eclipse projects, some contain library jars, and some contain shared source code (in several projects to avoid getting a giant heap with numerous dependencies while being able to compile everything from scratch to ensure that source and binaries are consistent). We manage those with projectSet.psf's as these can directly pull all projects out from CVS and leave a fully prepared workspace. We do not do ant builds directly or use maven.
We now want to be able to put all these projects and their various versions in a Continous Integration tool - I like Hudson but this is just a matter of taste - which essentially means that we need to get an automatic way to check out the projects to a fresh workspace, and compile the source folders as described in the project-files in each project. Hudson does not provide such an approach to build a project, so I have been considering what the best way to approach this would be.
Ideas have been
Find or write an ant plugin/converter that understands projectSet.psf's and map to cvs-checkout and compile tags.
Create the build.xml files from within Eclipse and use those. I tried this, and found the result to be verbose and with absolute locations which is not good with automatic tools putting files where they want to.
Write a Hudson plugin which understands projectSet.psf's to derive a configuration and build it.
Just bite the bullet and manually create and update the CI configuration whenever stuff breaks - I don't like this :)
I'd really like to hear about other peoples experiences so I can decide how to approach this.
Edit: Another option might be using a CI which knows better about Eclipse projects and/or project sets. We are not religious - this is just a matter of getting stuff running without having to do everything ourselves. Would Cruise Control be a better option perhaps? Others?
Edit: Found that ant4eclipse has a "Team Project Set" facility. http://ant4eclipse.sourceforge.net/
Edit: Used the ant4eclipse and ant-contrib ant extensions to build a complete workspace as a sjgned runnable jar file similar to the Runnable Jar facility in Eclipse 3.5M6. I am still depending on Eclipse to create the initial empty workspace, and extract the ProjectSet, so that is the next hurdle.
Edit: Ended up with a dual configuration, namely that Hudson extracts the same set of modules as listed in the ProjectSet.pdf file from CVS (which needs to have the same tag) causing them to be located next to each other. Then ant4eclipse works well with the projectSet.psf file embedded in the main module. Caveat: Module list in Hudson must be manually updated, and it appears that a manual workspace cleanup is needed afterwards to let Hudson "discover" that there is more projects now than earlier. This has now worked well for us for a couple of months, but it was quite tedious to get everything working inside the ant file.
Edit: The "Use Team Projects" with ant4eclipse and a Ctrl-A, Ctrl-C in Project Panel with a Ctrl-V in the CVS projects in Hudson has turned out to work well enough for us to live with (for mature projects this is very rarely changed). I am awaiting the release of ant4eclipse 1.0 - http://www.ant4eclipse.org/, currently in milestone 2 - to see how much homegrown functionality can be replaced with ant4eclipse things.
Edit: ant4eclipse is as of 20100609 in M4 so the schedule at http://www.ant4eclipse.org/node?page=1 is slipping somewhat.
Edit: My conclusion after using our ant4eclipse approach for a longer period is that the build script get very gnarly and is hard to maintain. Also the Team ProjectSet facility (which ant4eclipse use to locate the projects) which works well for CVS based repositories, but not after we migrated to git (which is a big thing in itself). New projects will most likely be based on maven, as this has good support in Jenkins.
I'm not completely sure I understand the problem, but it sounds like the root issue is that you have many projects, some of which are dependent on others. Some of the projects that are closer to the "leaf" of the dependency tree need to be able to use "stable" (or previously "released") versions of the more "core" projects.
I solve exactly this problem using Hudson, ant, and ivy. I follow a pattern demonstrated by Clark in Pragmatic Project Automation (he doesn't demonstrate the dependency problems and solutions, and he uses CruiseControl rather than hudson.)
I have a hand-written ant build file (we call it "cc-build.xml", because of our CruiseControl roots.) This file is responsible for refreshing the working space for the project from the CM repository and labeling the contents for future reference. It then hands off control to another hand-written ant build file (build.xml) that is provided by each project's developers. This project is responsible for the traditional build steps (compile, packaging, etc.) It is required to spit out the installable artifacts, unit test reports, etc, to the Hudson artifacts directory. It is my experience that automatically generated build files (by Eclipse or other similar IDE's) will never get close to getting this sufficiently robust for use in a CI scenario.
Additionally, it uses ivy to resolve its own dependencies. Ivy supports precisely-specified dependency versions (e.g. "use version 1.1") and it supports "fuzzy versions" (e.g. "use version 1.1+" or "use the latest version in integration status.") Our projects typically start out specifying a very "fuzzy" version for internal projects under ongoing development, and as they get close to a release point, they "freeze" the dependency version so that stuff stops moving underneath them.
The non-leaf projects (projects that are dependents for other projects) also use ivy to publish their artifacts to our internal ivy repository. That repository keeps all past builds of the dependents, so that any project can always depend on any other previous version.
Lastly, each project in Hudson is configured to have a build trigger that causes a rebuild when any of its dependent projects successfully build. This causes them to get built again with the (possibly) new ivy dependent version.
It is worth noting that once you get this up and running, consistent automated "labeling" or "tagging" of an automated build's inputs is going to be critical for you - otherwise troubleshooting post-build problems is going to result in having to untangle a hornet's nest to find the original source.
Getting all of this setup for our environment took quite a bit of effort (primarily in setting up the ivy repository and ant build files,) but it has paid for itself many times over in saved headaches in manually managing the dependencies and decreased troubleshooting effort.
Write a Hudson plugin which
understands projectSet.psf's to derive
a configuration and build it.
That seems like the winning answer to me.
I work with CruiseControl rather than Hudson but in my experience if you can create a plugin that solves your problem it will quickly payoff. And it is generally pretty easy to write a plugin that is custom fit for your solution as opposed to one that needs to work for everyone in a similar situation.
I have tried both Cruise Control (CC) and Hudson for our CI solution. We (as a company) decided on Hudson. But for your question "Does CC support Eclipse project build" the answer is no as far as I know. CC supports many more different build tools and Source Control systems but it is a bit more difficult to configure and use. As for Hudson, it is more simple to configure and use it. We developed our custom plugins for both CC and Hudson for the parts of our build cycle that they do not provide as is. As for plugin development, if you know / use Maven, Hudson is simpler too. But if you are not familiar to Maven, first you need to learn the basic usage of maven to successfully develop a Hudson plugin. But once you understand the basic usage of maven, plugin development, test and even debug is simpler in Hudson.
For your specific problem, I can think of a solution that makes use of Eclipse plugins as well. You can develop your own Eclipse plugin that for instance gets the psf files from a (configurable) folder, and use Eclipse internals to process these psf's. I mean you can use existing Eclipse source codes that takes a psf file, check-outs it's project definitions and compile these projects. This Eclipse plugin of yours may have a preference page (which you can access by Eclipse -> Window -> Preferences) and configure which folder it will use to look for psf files. Your Eclipse plugin should also have a way to start psf processing without user interaction. For this, you can use ipc to trigger your process. I mean your Eclipse plugin can listen for a port, and you can write another java application that will connect to your plugin through this port and trigger its process. As for CI part, you can use either CC or Hudson and use their external process execution support. If you are using Windows, you can write a bat file (for Linux sh file) that first launchs Eclipse that has your plugin installed. Then it launches your java application that will communicate with your Eclipse plugin to trigger your process. From your CI tool you will need to run your bat / sh file to trigger your process.