Skip to content
This repository was archived by the owner on Dec 18, 2022. It is now read-only.

Commit 10900bc

Browse files
authored
Merge pull request #28 from 05nelsonm/mn/feature/gradle-maven-publish
implements gradle maven publish plugin
2 parents 30c54d8 + 175161c commit 10900bc

28 files changed

Lines changed: 117 additions & 47 deletions

File tree

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ buildscript {
66
repositories {
77
google()
88
jcenter()
9+
mavenCentral()
910
}
1011
dependencies {
1112
classpath deps.androidGradlePlugin
1213
classpath deps.kotlin.dokka
1314
classpath deps.kotlin.gradlePlugin
15+
classpath deps.mavenPublish
1416
}
1517
}
1618

docs/get_started.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Get Started
1111
- Download `geoip` and `geoip6` files from https://github.com/torproject/tor/tree/master/src/config
1212
- If you prefer the non-mirror repository, you can also obtain them from
1313
https://gitweb.torproject.org/tor.git/tree/src/config
14-
- In your Application module's `src/main` directory, create a new `Directory` named `assets`
14+
- In your Application module's `src/main/` directory, create a new `Directory` named `assets`
1515
- Copy `geoip` and `geoip6` files into the `assets` directory (or a subdirectory within
1616
`assets`, such as `assets/common/`. File extensions not necessary).
1717
- **torrc file**:
@@ -20,21 +20,30 @@ Get Started
2020
[TorServicePrefs](./topl-service/io.matthewnelson.topl_service.prefs/-tor-service-prefs/index.md).
2121
If nothing is in `TorServicePrefs` for that particular setting, then it will fall back on
2222
your static/default [TorSettings](./topl-core-base/io.matthewnelson.topl_core_base/-tor-settings/index.md)
23-
that you supply upon initialization of `TorServiceController.Builder`.
24-
- **Tor Binaries**:
25-
- I use The GuardianProject's <a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>
26-
project to build binaries, and provided them
27-
<a href="https://github.com/05nelsonm/TOPL-Android-TorBinary" target="_blank">here</a>. The
28-
difference is in how they are packaged as a dependency, and the contents of what you are
29-
importing as a dependency. I package them in the `jniLibs` directory so that the Android OS
30-
will automatically install them into your application's `/data/app/...` directory, and include
31-
no unnecessary classes or resources; just the binaries. Android API 29+ no longer supports
32-
execution of executable files from your application's `/data/data/` directory, and must now be
33-
installed in the `context.applicationInfo.nativeLibraryDir` directory (aka, `/data/app/...`)
34-
to execute.
35-
- Nothing more is needed in terms of configuring initialization via the
36-
`TorServiceController.Builder`, as files will be installed in the correct directory, and
37-
named to match what `topl-service` looks for.
23+
that you supply upon initialization of `TorServiceController.Builder`.
24+
- **Tor Binaries**:
25+
- For now, you'll have to copy the binaries into your application's `src/main/jniLibs/<abi>/`
26+
directory so that they are packaged in your APK **uncompressed** (which Android will automatically
27+
extract to your application's native directory on the device (`/data/app/<your app>/<abi>/libTor.so`))
28+
- Tor v0.4.3.5 binaries can be found in the `sampleapp` which you can copy over (for the
29+
time being).
30+
- I am currently building a gradle plugin to streamline binary distribution, so stay tuned!
31+
- The issue: Providing Tor Binaries packaged via an `aar` presents problems, as the
32+
binaries are compressed which results in the Android OS not extracting them automatically.
33+
This requires extraction of the Shared Native Library from the APK to be executed via
34+
inclusion of `extractNativeLibs="true"` in the app's Manifest (min API 23), or code to
35+
unzip the APK and extract the tor binaries to the application's native directory at runtime.
36+
There are many bugs/limitations across the various Android APIs (16-29) that makes this
37+
incredibly inefficient, not UX friendly for library users, error prone, and makes
38+
versioning somewhat complicated as devs have no control over the Android OS' symlink
39+
creation process. API 29 also presents problems with extracting the binaries
40+
to the application's `/data/data/` directory as it
41+
<a href="https://developer.android.com/about/versions/10/behavior-changes-10" target="_blank">
42+
no longer supports running of executables from that location</a>. Because of the plethora
43+
of issues across APIs, distribution of *.so files would be best done as a gradle plugin
44+
such that upon building of your application, the *.so files included in the plugin can be
45+
extracted to your application module's `src/main/jniLibs/<abi>/` directory. This ensures
46+
that when your application is built and zipaligned, everything will simply work.
3847
- If you wish to use GuardianProject's binaries, see
3948
<a href="https://github.com/guardianproject/tor-android" target="_blank">tor-android</a>.
4049
- You'll need to use their `NativeResouceInstaller` to install the binaries.
@@ -49,9 +58,8 @@ Get Started
4958

5059

5160
!!! Info
52-
Tor Binaries are ~8MB for each ABI (will be less after compression), so it's advised that builds
53-
are split to keep apk sizes down. For example, the `sampleapp`'s universalApk size (all ABIs)
54-
is ~16MB, where splits are ~7MB. See the `sampleapp`'s `build.gradle` file for more details.
61+
Tor Binaries are ~8MB for each ABI, so it's advised that builds are split to keep apk sizes
62+
down. See the `sampleapp`'s `build.gradle` file for more details.
5563
<a href="https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/sampleapp/build.gradle" target="_blank">here</a>
5664

5765
## Implementation - Step 2: topl-service

docs/releasing.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ extra:
2727
```
2828
rm -rf docs/topl-core docs/topl-core-base docs/topl-service
2929
./gradlew topl-core-base:dokka topl-core:dokka topl-service:dokka
30+
```
31+
32+
- Fix Dokka doc links
33+
```
3034
./gradlew fixDokkaDocLinks
3135
```
3236

docs/topl-core-base/io.matthewnelson.topl_core_base/-tor-config-files/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ See [Companion.createConfig](create-config.md) or [Builder](-builder/index.md) t
2828
| [hiddenServiceDir](hidden-service-dir.md) | `val hiddenServiceDir: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
2929
| [hostnameFile](hostname-file.md) | The &lt;base32-encoded-fingerprint&gt;.onion domain name for this hidden service. If the hidden service is restricted to authorized clients only, this file also contains authorization data for all clients.`val hostnameFile: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
3030
| [installDir](install-dir.md) | `val installDir: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
31-
| [libraryPath](library-path.md) | `val libraryPath: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
31+
| [libraryPath](library-path.md) | `val libraryPath: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`?` |
3232
| [resolveConf](resolve-conf.md) | `val resolveConf: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
3333
| [torExecutableFile](tor-executable-file.md) | `val torExecutableFile: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |
3434
| [torrcFile](torrc-file.md) | `var torrcFile: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) |

docs/topl-core-base/io.matthewnelson.topl_core_base/-tor-config-files/library-path.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# libraryPath
44

5-
`val libraryPath: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core-base/src/main/java/io/matthewnelson/topl_core_base/TorConfigFiles.kt#L84)
5+
`val libraryPath: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`?` [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core-base/src/main/java/io/matthewnelson/topl_core_base/TorConfigFiles.kt#L84)

docs/topl-core/io.matthewnelson.topl_core.util/-file-utilities/clean-install-one-file.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# cleanInstallOneFile
44

5-
`fun cleanInstallOneFile(readFrom: `[`InputStream`](https://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html)`, fileToWriteTo: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L186)
5+
`fun cleanInstallOneFile(readFrom: `[`InputStream`](https://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html)`, fileToWriteTo: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L188)
66

77
Reads the input stream, deletes fileToWriteTo if it exists and over writes it with the stream.
88

docs/topl-core/io.matthewnelson.topl_core.util/-file-utilities/extract-content-from-zip.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# extractContentFromZip
44

5-
`fun extractContentFromZip(destinationDirectory: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`, zipFileInputStream: `[`InputStream`](https://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L211)
5+
`fun extractContentFromZip(destinationDirectory: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`, zipFileInputStream: `[`InputStream`](https://docs.oracle.com/javase/6/docs/api/java/io/InputStream.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L215)
66

77
This has to exist somewhere! Why isn't it a part of the standard Java library?
88

docs/topl-core/io.matthewnelson.topl_core.util/-file-utilities/read.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# read
44

5-
`fun read(f: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`ByteArray`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L161)
5+
`fun read(f: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`ByteArray`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L163)

docs/topl-core/io.matthewnelson.topl_core.util/-file-utilities/recursive-file-delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
# recursiveFileDelete
44

5-
`fun recursiveFileDelete(fileOrDirectory: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L195)
5+
`fun recursiveFileDelete(fileOrDirectory: `[`File`](https://docs.oracle.com/javase/6/docs/api/java/io/File.html)`): `[`Unit`](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) [(source)](https://github.com/05nelsonm/TorOnionProxyLibrary-Android/blob/master/topl-core/src/main/java/io/matthewnelson/topl_core/util/FileUtilities.kt#L197)

gradle.properties

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,26 @@ android.enableJetifier=true
2020
# Kotlin code style for this project: "official" or "obsolete":
2121
kotlin.code.style=official
2222

23+
GROUP=io.matthewnelson.topl-android
2324
VERSION_NAME=1.0.0-alpha01-SNAPSHOT
25+
26+
# The trailing 2 digits are for `alpha##` releases. For example:
27+
# 4.4.1-alpha02 = 441102 where `102` stands for alpha02
28+
# 4.4.1-beta01 = 441201 where `201` stands for beta01
29+
# 4.4.1-rc01 = 441301 where `301` stands for rc01
30+
VERSION_CODE=100101
31+
32+
POM_INCEPTION_YEAR=2020
33+
34+
POM_URL=https://github.com/05nelsonm/TorOnionProxyLibrary-Android
35+
POM_SCM_URL=https://github.com/05nelsonm/TorOnionProxyLibrary-Android
36+
POM_SCM_CONNECTION=scm:git:git://github.com/05nelsonm/TorOnionProxyLibrary-Android.git
37+
POM_SCM_DEV_CONNECTION=scm:git:ssh://git@github.com/05nelsonm/TorOnionProxyLibrary-Android.git
38+
39+
POM_LICENCE_NAME=GNU General Public License, Version 3.0
40+
POM_LICENCE_URL=https://www.gnu.org/licenses/gpl-3.0.html
41+
POM_LICENCE_DIST=repo
42+
43+
POM_DEVELOPER_ID=05nelsonm
44+
POM_DEVELOPER_NAME=Matthew Nelson
45+
POM_DEVELOPER_URL=https://github.com/05nelsonm/

0 commit comments

Comments
 (0)