tags:

views:

68

answers:

2

I will be hosting a java project on SVN which will need to be downloaded by other developers with the ability of that project to be compiled / packaged on their local machine.

I would like to know what files are needing to be stored on SVN and which ones can be left out. I know the files that Netbeans creates can be left out and the build.xml will need to be included as it has code to package the libraries used in the project into the .jar file.

I am assuming that the following need to be stored on the SVN server:

/lib
/src
build.xml
  • Does any of the files in the nbproject folder need to be added?

  • If not what svn commands (IE svn-ignore) will I need to run to ignore all the files except for those in /lib, /src and the build.xml file?

  • What should my file structure on the svn look like? Should I keep the source files in the src directory on svn or should I name the folder something else so the developer can then "Create a new project from existing source"?

+5  A: 

You shouldn't host you lib directory on your SVN, you can use Ivy or Maven as a dependencies manager which will download all your dependency from a repository.

Concerning the netbeans files it depends on the way your team work, I would say that you can let them on the SVN it will be useful for other developers using netbeans and shouldn't bother developers using another IDE.


For the svn:ignore part you have to do svn propset svn:ignore dirname . in command line.


A general file structure is :

/svn
|-projectName/
 |-branches/
 |-tags/
 |-trunk/
  |-projectName/ (Sometimes this directory doesn't exists and its content is put right into trunk)
   |-pom.xml (Maven !)
   |-module1Name/
    |-src/
     |-main/
      |-java/
      |-resources/
     |-test/
      |-java/
      |-resources/
    |-pom.xml (Maven !)
   |-module2Name/
   |-module3Name/

Resources :

On the same topic :

Colin Hebert
All developers in this department use Netbeans however, their file structure is different.
jostster
Keeping your lib folder in the repository is, IMHO, quite OK for projects with few and stable dependencies, but in general I do agree with Colin, Ivy or Maven is the way to go. I guess I'm just moaning about the strict "you shouldn't" directive :).
darri
The problem is that any project can evolve and someday need new dependencies or new versions. Some dependencies can disappear too. If you don't use good practices from the start, it will be harder to get rid of the bad ones later.
Colin Hebert
Colin, can you also answer my other question about what svn ignore commands should be done as well as proper file structure for the source code on svn?
jostster
Your current directory structure is fine (although you might want to follow the Maven project structure guidelines, if you see Maven becoming your build tool sometime in the future), and yes, keep your source files in the src directory. Can't help you with the ignore stuff, never really had to think about it, I guess that's something IntelliJ is doing for me.
darri
I updated the answer
Colin Hebert
Colin... After thinking about it further Maven may be an option so that we don't have to go transferring the .jar around to different servers to reach production. Does Maven allow me to build and have the end .jar be a specific name no matter what build version it is? I don't want to have to go in and change my code for the application that uses this .jar file after every build.
jostster
And more important will Maven allow me to package the libraries inside the .jar so I don't have to transport around a /lib folder?
jostster
Yes, and yes, but if your other projects use maven too they don't need to use an "unversioned" jar, and your jar won't need to contain all the libs.
Colin Hebert
A: 

I decided to take another route. While I had read your original post about using Maven, we are wanting to stay away from Maven as we are basically just writing a command line interface for an existing library.

Another reason I decided to do what I did was during adding my svn:ignore's I realized that some of the developers here keep their netbeans project settings in different directories which would basically not do any good since it wouldn't be an svn working copy in that dir.

So what I did was just add the /src and /lib directory to the repo.

The end user then checksout the repo with svn co svn+ssh://path/to/repo/trunk . and then will open netbeans and select "Create project from existing source". At which point they will go in and add the library from the /lib directory.

I have Up Voted your answer as it would have been very helpful should I of gone through with using Maven.

jostster
Even if it's already the case in your team, you should think about a unified way to load your projects so new developers won't have to discover a new architecture. Plus in your case, having the same architecture on every developer PC will allow them to work together easily, no need for a customized configuration every time. That said, I understand that you don't really want to change everything now.
Colin Hebert