0

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 because bar.java was always in the same place, even if it was different in some of the versions. I mean, both Android\src\com\company\product\a\foo.java, SWT\src\com\company\product\a\foo.java and Swing\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 could foo.java import bar.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
    
Community
  • 1
  • 1
Yeray
  • 5,009
  • 1
  • 13
  • 25
  • Would it be possible to import the right `Bar` class by setting the class path appropriately? If you are working on the Android project, the `com.company.product.android` package should be in the class path. For SWT or Swing, you would include the `com.company.product.swt_swing` package. – Freek de Bruijn Dec 23 '15 at 11:31
  • Do the implementations for the respective platforms share the same API? If so, you could have a look at how [SWT](https://github.com/eclipse/eclipse.platform.swt/tree/master/bundles/org.eclipse.swt) organizes the sources. It basically uses multiple (Eclipse) source folders to assemble different variations of source files. – Rüdiger Herrmann Dec 23 '15 at 13:54

0 Answers0