1

My friend and I are working on a Java project collaboratively. We are both very inexperienced with regards to Eclipse and Git alike.

The primary goal is:

  1. For my friend and I to seamlessly contribute to the code via git, with minimal limitation.

  2. To be able to develop the SWT interface without running into dependency errors that might arise due to absolute class paths and/or due to differences in OS (it would be beneficial if I could work on the project not only on my Windows machine at home, but my Macbook as well)

When I looked up the question, it seemed this question had the answer.

However, doesn't changing the build path affect the .classpath, and will thus be affected when you commit changes to git (see goal #2)? How do I ensure that virtually anyone can clone my repository, regardless of OS (see goal #1)? The other answers I have found involve setting the class path variables—however, as I have said, I am woefully inexperienced with Eclipse. I have also heard that Maven might be the answer, but I have no clue how to use the pom file and how to set it up for the 10 or so different jars in the "Referenced Libraries" part of my project.

Thank you in advance for the assistance

Community
  • 1
  • 1

1 Answers1

0

We are both very inexperienced with regards to Eclipse and Git alike.

And presumably SWT and Maven as well? Brace yourself for an exercise in patience and frustration - this sounds like a very ambitious (but not impossible) goal without much experience in these things.

develop the SWT interface [...] not only on my Windows machine at home, but my Macbook as well

SWT has different .jars for different OSes and architectures. If you truly want a single .jar that can be run on different platforms, it's not going to be trivial to handle which one is used at runtime. I would recommend building different assemblies depending on the target OS. If that is simply something you cannot do, then unfortunately I can't help much in regards to how to load different SWT .jars at runtime.

Maven might be the answer

Maven will definitely help, and you can use this repository in your pom.xml to get the corresponding SWT dependency: http://maven-eclipse.github.io/maven.

I have no clue how to use the pom file

A bit of Google-searching should bring up some very basic Maven examples. Take some time to understand the different parts of the pom.xml file (Maven in 5 Minutes).

how to set it up for the 10 or so different jars in the "Referenced Libraries"

You will need to find the corresponding Maven dependency for these. Eclipse will be very helpful with this, and you will not need to manually manage the .classpath file (How do I get my Eclipse-Maven project to automatically update its classpath when I change a dependency in my pom.xml file?).

Without throwing too much info at you, while still trying to provide a helpful answer, I would recommend (after getting a grasp on Maven basics) taking a look at using profiles in your pom to determine which SWT dependency will be used (Related: SWT on different systems). This will address your primary concern, as you will no longer be hard-coding a platform-specific dependency, so anyone on a different OS can now build your project.

For my friend and I to seamlessly contribute to the code via git, with minimal limitation.

IMO Git will be the least confusing part about what you're trying to achieve :) That said, just take some time to learn the basics of Git and you should be fine. It's not overly complicated once you understand the basics and stick to the basics.


In general, be aware that with SWT there are some nuances with how it will look/behave on different OSes. Just because something works for you Windows doesn't mean that it will look/behave exactly the same way on a Mac.

Side note: A "gotcha" that you will eventually run into on macOS is the need for the -XstartOnFirstThread JVM argument (Running SWT based, cross-platform jar properly on a Mac).

Community
  • 1
  • 1
avojak
  • 2,342
  • 2
  • 26
  • 32