In the company I work for, we develop a library in java that is released for SWT, Swing and Android. Imagine this folder structure (simplified):
├───Android
│ └───src
│ ├───com
│ │ └───company
│ │ └───product
│ │ ├───android
│ │ ├───a
│ │ ├───foo.java
│ │ ├───bar.java
│ │ ├───b
├───Swing
│ └───src
│ ├───com
│ │ └───company
│ │ └───product
│ │ ├───a
│ │ ├───foo.java
│ │ ├───bar.java
│ │ ├───b
│ │ ├───editors
├───SWT
│ └───src
│ ├───com
│ │ └───company
│ │ └───product
│ │ ├───a
│ │ ├───foo.java
│ │ ├───bar.java
│ │ ├───b
│ │ ├───editors
│ │ ├───swt
We basically use Windows as development machines, but the library supports (and want to continue supporting) linux. We use ant
to compile the library when we want to publish a release.
We are moving from Team Coherence (TCo) to Git. We used file-links in TCo to keep files in sync between the three versions.
The majority of files in a
and b
folders are linked between the three versions. But there are some files in these folders that are in the version for SWT and Swing but not for Android.
Also, there are folders that only exist in a version, like android
or swt
folders above.
I guess we can use symlinks as explained here but it would be better to "rationalize" the structure. The problem is that I'm not sure how.
If we do this:
├───Sources
│ └───src
│ ├───com
│ │ └───company
│ │ └───product
│ │ ├───android
│ │ ├───bar.java
│ │ ├───swing
│ │ ├───swt
│ │ ├───swt_swing
│ │ ├───bar.java
│ │ ├───a
│ │ ├───foo.java
│ │ ├───b
│ │ ├───editors
I can put not shared units in android
, swing
and swt
folders.
I can put units shared between swt and swing in the swt_swing
folder.
And I can put the units shared by the three in the rest of folders.
However, how can I make a unit shared by the three to import a unit that is in a dependant folder?
Let's say foo.java
imports bar.java
.
With the old structure with file-links we could have
foo.java
linked in the three versions becausebar.java
was always in the same place, even if it was different in some of the versions. I mean, bothAndroid\src\com\company\product\a\foo.java
,SWT\src\com\company\product\a\foo.java
andSwing\src\com\company\product\a\foo.java
started with:import com.company.product.a.bar.java
With the new structure we moved
bar.java
in different places because it's different, but I don't know how couldfoo.java
importbar.java
from different locations depending on what project loads it:import com.company.product.android.bar.java import com.company.product.swt_swing.bar.java