Issue
When I try to work with a group on a Java project, we always need to fix the libraries, since it uses the directory structure of the last user (eg. person1's libraries are in c:/documents, while person2's libraries are in c:/downloads, person2 will get a library not found error since it is looking in c:/documents)
I've noticed those references to libraries are stored in nbproject/project.properties, I tried adding it to gitignore, but I've read that project.properties should be excluded from gitignore.
In the project.properties file it shows this
file.reference.byte-buddy-1.8.15.jar-1=C:\\Users\\Cedric\\Desktop\\byte-buddy-1.8.15.jar
file.reference.byte-buddy-agent-1.8.15.jar-1=C:\\Users\\Cedric\\Desktop\\byte-buddy-agent-1.8.15.jar
file.reference.eclipselink.jar-1=C:\\Users\\Cedric\\Desktop\\eclipselink.jar
file.reference.javax.annotation_1.2.0.v201602091430.jar-1=C:\\Users\\Cedric\\Desktop\\javax.annotation_1.2.0.v201602091430.jar
file.reference.javax.persistence.jar-1=C:\\Users\\Cedric\\Desktop\\javax.persistence.jar
file.reference.jfoenix-9.0.8.jar-1=C:\\Users\\Cedric\\Desktop\\jfoenix-9.0.8.jar
file.reference.mockito-core-2.21.0.jar-1=C:\\Users\\Cedric\\Desktop\\mockito-core-2.21.0.jar
file.reference.objenesis-2.6.jar-1=C:\\Users\\Cedric\\Desktop\\objenesis-2.6.jar
#Mon Apr 08 17:43:30 CEST 2019
javadoc.splitindex=true
build.classes.excludes=**/*.java,**/*.form
@@ -58,7 +66,26 @@ javafx.application.implementation.version=1.0
main.class=com.javafx.main.Main
dist.javadoc.dir=${dist.dir}/javadoc
javadoc.additionalparam=
javac.classpath=${file.reference.Downloads-Microsoft_SQL_Server_JDBC_Driver_2.0}\:${file.reference.byte-buddy-1.8.15.jar}\:${file.reference.byte-buddy-agent-1.8.15.jar}\:${file.reference.eclipselink.jar}\:${file.reference.javax.annotation_1.2.0.v201602091430.jar}\:${file.reference.javax.persistence.jar}\:${file.reference.mockito-core-2.21.0.jar}\:${file.reference.objenesis-2.6.jar}\:${libs.eclipselink.classpath}\:${file.reference.jfoenix-9.0.8.jar}\:${libs.junit_4.classpath}
javac.classpath=\
${file.reference.Downloads-Microsoft_SQL_Server_JDBC_Driver_2.0}:\
${file.reference.byte-buddy-1.8.15.jar}:\
${file.reference.byte-buddy-agent-1.8.15.jar}:\
${file.reference.eclipselink.jar}:\
${file.reference.javax.annotation_1.2.0.v201602091430.jar}:\
${file.reference.javax.persistence.jar}:\
${file.reference.mockito-core-2.21.0.jar}:\
${file.reference.objenesis-2.6.jar}:\
${libs.eclipselink.classpath}:\
${file.reference.jfoenix-9.0.8.jar}:\
${libs.junit_4.classpath}:\
${file.reference.byte-buddy-1.8.15.jar-1}:\
${file.reference.byte-buddy-agent-1.8.15.jar-1}:\
${file.reference.eclipselink.jar-1}:\
${file.reference.javax.annotation_1.2.0.v201602091430.jar-1}:\
${file.reference.javax.persistence.jar-1}:\
${file.reference.jfoenix-9.0.8.jar-1}:\
${file.reference.mockito-core-2.21.0.jar-1}:\
${file.reference.objenesis-2.6.jar-1}
compile.on.save.unsupported.javafx=true
javadoc.noindex=false
javafx.deploy.backgroundupdate=false
My guess is the first file references are causing the problem, but I have no idea how to fix this.
Solution
You don't need to exclude project.properties
file from Version Control. Just change the way of adding libraries to your project.
As you mentioned, you and your team mates are maintaining separate folders for the libraries. Do not do that. Create one lib
folder inside your project and put all the (currently) required libraries in that folder. For example your project folder structure should look like this,
your-project-root-folder
|-- build
|-- dist
|-- nbproject
|-- lib <====== the folder which contains all required libraries
|-- src
|-- test
|-- web
|-- build.xml
|-- .gitignore
Now in Netbeans you need to select lib
folder as source libraries directory. Follow the instruction like below
And browse to the path where you kept Project folder and select required libraries from lib
folder like below
Let's say your project path is C:/users/user/Documents/NetbeansProjects/your-project-root-folder
From there select lib
And make sure that you've selected Relative Path radio button on right hand side.
Now this will add part of the (relative) path to project.properties
file. Once you add libraries in this way, you no longer need to worry about switching libraries folder from C:/Documents
to C:/Downloads
vice-versa.
As far as I know, we exclude build
, dist
and nbproject/private/
directories from Version Control. As these folders/files keep on re-generating every single time we build the project.
For your reference this is how I maintain my Netbeans projects in version control. My .gitignore
file looks like below
/build
/dist
/nbproject/private/
Answered By - Shashanth