Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make a separate, independent java library out of the core package #10

Open
pec0ra opened this issue Jan 16, 2020 · 14 comments
Open

Make a separate, independent java library out of the core package #10

pec0ra opened this issue Jan 16, 2020 · 14 comments

Comments

@pec0ra
Copy link

pec0ra commented Jan 16, 2020

Currently, this repository contains two things:

  1. the core package which provides an interface to execute speedtests
  2. an Android application template that uses this interface

I suggest that you separate these two things into two separate repositories. One for the speedtest library and one for the android app template.

This would give the following advantages:

  • It would be easier to use the library (core package), not only in android apps but also in any java app
  • It would offer the possibility to publish the speedtest library to maven
  • It would make the licensing clearer. You could for example publish the library under LGPL and the application template under MIT license
  • It would make it easier to contribute to the projects

A good alternative to multiple repositories could also be multiple branches inside one repository.

@adolfintel
Copy link
Member

Yes this would be a good idea

@pec0ra
Copy link
Author

pec0ra commented Jan 16, 2020

Let me know if you need my help!

If you don't have the time to do it I can also try to do it myself.

@pec0ra
Copy link
Author

pec0ra commented Jan 30, 2020

Hello @adolfintel

It has been some time since I opened this issue.
Since I haven't heard any news from you I decided to go ahead and start making an independent library for LibreSpeed.

You can find it in my fork in the branch library: https://github.com/pec0ra/speedtest-android/tree/library
It can be compiled as a jar by using the task ./gradlew jar. The library can then be used by putting the jar in the libs folder of a java (or android) project with the following gradle dependency: implementation fileTree(dir: 'libs', include: ['*.jar'])

Here are a few points I wanted to mention:

  • To make the library more compatible (java in general), I removed android dependencies. This breaks the user agent which now doesn't know about the device type anymore. I am not sure what we should now use as a user agent here. Maybe this could be passed to the library as some kind of parameter.
  • I have flattened the packages to allow using package private visibility and only publish the required methods and classes.
  • I started the code from scratch in a new branch. I still don't know if you prefer a separate repository or just a separate branch. I couldn't make a pull request for a new branch on your repository anyway so you might need to take some action here.
  • Documentation (readme and preferably javadoc for public methods too) will still need to be written. As soon as I have some feedback from your side I will start writing it.

Let me know what you think.

@adolfintel
Copy link
Member

It's ok, I was planning to do this in the next update, that's why I didn't close the issue.

Your work seems pretty good to me. Removing the android dependencies was something that I wanted to do as well because I intend to use the core package as a base for the command line client that I'll be developing some time in the future. There's probably some way to keep both an android and a non-android version of the user-agent code in the same file (something like C preprocessor directives), you might want to look into it.

Good job, keep me posted :)

@pec0ra
Copy link
Author

pec0ra commented Jan 31, 2020

The problem with the android code is that it needs some android libraries to be added to the build.gradle. I don't think we can load these libraries dynamically and it would probably be an overkill anyway.
What I suggest is adding an option to the config. We can probably already have a good default without android libraries (something like LibreSpeed/1.1.3 (Ubuntu 18.04...) and users of the libraries can easily improve it if they want.

If you want to use the code I have as a base, could you please create an empty branch in your repository? Then I will be able to create a Pull Request which will facilitate development.

@adolfintel
Copy link
Member

Done, there's a coreOnly branch now

@pec0ra
Copy link
Author

pec0ra commented Jan 31, 2020

Thank you!
I have created a PR: #12
I will keep my remarks about implementation there

@MarceloTabian
Copy link

I want to use the core only branch as a library. I checked out the branch, but it came empty.

Have I committed a mistake or is the branch really yet to be filled?

I have some questions related to de license. I read about LGPL, but it is a complex license.

I intend to use the core-only branch as a library in my proprietary Android App.

Am I allowed to do this if I generate a jar from the core only branch and then use the jar in the build of my proprietary app?

Am I allowed to do this if I simply include the source code of the core package directly in the build of my proprietary app?

Thank you.

@adolfintel
Copy link
Member

@MarceloTabian The branch is empty because the work on it was never finished.

To answer your questions:

I intend to use the core-only branch as a library in my proprietary Android App.

Yes, you can. The LGPL license merely requires that you release modifications to my code, you are free to use whatever license you prefer for yours.

Am I allowed to do this if I generate a jar from the core only branch and then use the jar in the build of my proprietary app?

Yes

Am I allowed to do this if I simply include the source code of the core package directly in the build of my proprietary app?

Technically it's possible, but I would strongly suggest creating a repo on github instead

@MarceloTabian
Copy link

Thank you for the fast answer.

So I will try to compile the core package and generate a jar. Then I will include the jar in the project of the proprietary App.

If I modify the code of the core package, then I will submit a push to this git hub project.

Wouldn't it be better to have two separate github repositories, one for your app and one for your library as suggested before?

I really think that the separate library would be a great contribution of yours to Android developers.

If you or someone else modifies the core package, no action of my part is required, right?

@adolfintel
Copy link
Member

If I modify the code of the core package, then I will submit a push to this git hub project.

The core is designed to be independent from the UI, so you shouldn't have problems with that. Technically that counts as a modification according to the LGPL license but I'm willing to make an exception if you're not touching the core code.

Wouldn't it be better to have two separate github repositories, one for your app and one for your library as suggested before?
I really think that the separate library would be a great contribution of yours to Android developers.

Yes, that was the intention of the original author, he wanted to modify the core so that it could work as a library that could be used in any java app, and not just android.

If you or someone else modifies the core package, no action of my part is required, right?

No, but you should check for updates every once in a while.

@MarceloTabian
Copy link

I have divided the project in two. Now, one project builds an arr, which is a library for Android, containing the core package and the other uses the arr and contains the UI package.

Using Android Studio, I created a project with two modules, an app and a library. Them I copied the files from the original project to the correct places.

May I push the changes to a new branch?

@adolfintel
Copy link
Member

That's great. Fork the project and make a PR to the coreOnly branch

@MarceloTabian
Copy link

I did it, but named the branch split, because it contains both the core package, arranged to generate an arr, and the UI package to use the arr.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants