0

I'm a fan of a fairly big open-source program which is written in Java and uses Swing as a front-end client on series of web actions. As I've been working with Android development for a few months, I had an idea that I could create a new app that works similarly to the Swing application. The program is well-organized and separates interface from implementation, also offering a command line interface as well as Swing.

So ideally I'd like to be able to just inject a new Android package into the existing file system somewhere, make use of the back end that already exists, and have it work seamlessly with new updates to the program. The closest suggestion I found was this:

Q: How can I create a new project from an existing project, using Android command line tools?

A: Copy the directory tree of the old project into a new project.

This doesn't seem like it can be feasible advice for me, since I have to work with the existing SVN repository rather than starting the whole thing from scratch. Is there any way to pull this off?

Community
  • 1
  • 1
Kazim
  • 99
  • 4

1 Answers1

1

since I have to work with the existing SVN repository rather than starting the whole thing from scratch. Is there any way to pull this off?

I doubt it. Android won't like the Swing code; standard Java won't know what to do with the Android code.

I suggest that you reorganize your code base into three:

  • One generates a JAR file, containing the common logic
  • One is the rest of your existing Swing/command-line logic, which uses the JAR
  • One is a new Android project, which also uses the JAR

Maybe you can pull this off by having src-jar/, src-swing/ and src/ (latter for Android) and associated build scripts. Personally, I'd have three totally separate projects.

Since SVN supports move operations (at least, it used to, last I used it, oh so many years ago), you should be able to accomplish this reorganization without losing any version history.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Yeah, it's likely that you're right. The project does, of course, generate a jar when finished, so I'm going to see what happens if I just import the jar rather than executing the main class inside it. Maybe I can work with the primary developers in setting up an extra location in the repository or else put it somewhere else. – Kazim Oct 26 '11 at 19:21
  • @Kazim: "The project does, of course, generate a jar when finished" -- yeah, but it'll have a bunch of extra classes in it that won't do you any good. There might be a way to get rid of them via ProGuard. "so I'm going to see what happens if I just import the jar rather than executing the main class inside it" -- if you mean you will add the JAR to a separate Android project, that in principle should work, so long as you don't try executing anything that depends on stuff not in Android (e.g., Swing). – CommonsWare Oct 26 '11 at 19:37