diff --git a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java index 35fe3cc90..0f7117c65 100644 --- a/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java +++ b/bramble-java/src/main/java/org/briarproject/bramble/plugin/tor/UnixTorPluginFactory.java @@ -96,15 +96,21 @@ public class UnixTorPluginFactory implements DuplexPluginFactory { String architecture = null; if (isLinux()) { String arch = System.getProperty("os.arch"); + LOG.info("System's os.arch is " + arch); if (arch.equals("amd64")) { architecture = "linux-x86_64"; } + else if (arch.equals("aarch64")) { + architecture = "linux-aarch64"; + } } if (architecture == null) { LOG.info("Tor is not supported on this architecture"); return null; } + LOG.info("The selected architecture for Tor is " + architecture); + Backoff backoff = backoffFactory.createBackoff(MIN_POLLING_INTERVAL, MAX_POLLING_INTERVAL, BACKOFF_BASE); TorRendezvousCrypto torRendezvousCrypto = new TorRendezvousCryptoImpl(); diff --git a/briar-headless/README.md b/briar-headless/README.md index 3b37bd571..bc050a925 100644 --- a/briar-headless/README.md +++ b/briar-headless/README.md @@ -11,9 +11,10 @@ The REST API peer comes as a `jar` file and needs a Java Runtime Environment (JRE) that supports at least Java 8. It currently works only on GNU/Linux operating systems. -To build the `jar` file, you can do this: +To build the `jar` file, you need to specify the combination of architecture and platform: - $ ./gradlew --configure-on-demand briar-headless:jar + $ ./gradlew --configure-on-demand briar-headless:x86LinuxJar + $ ./gradlew --configure-on-demand briar-headless:aarch64LinuxJar You can start the peer (and its API server) like this: diff --git a/briar-headless/build.gradle b/briar-headless/build.gradle index 4357f06fe..641ca400e 100644 --- a/briar-headless/build.gradle +++ b/briar-headless/build.gradle @@ -44,18 +44,32 @@ dependencies { kaptTest "com.google.dagger:dagger-compiler:$daggerVersion" } -jar { - manifest { +void jarFactory(Jar jarTask, jarArchitecture) { + jarTask.doFirst { + println 'Building ' + jarArchitecture + ' version has started' + } + jarTask.manifest { attributes( 'Main-Class': 'org.briarproject.briar.headless.MainKt' ) } - from { + jarTask.setArchiveClassifier(jarArchitecture) + jarTask.from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } - doLast() { + { + String[] architectures = ["linux-aarch64", "linux-x86_64"] + for (String arch : architectures) { + if (arch != jarArchitecture) { + exclude "obfs4proxy_" + arch + ".zip" + exclude "tor_" + arch + ".zip" + } + } + } + jarTask.with jar + jarTask.doLast { // Rename the original jar - File jar = project.jar.archivePath + File jar = jarTask.archivePath String srcPath = jar.toString().replaceFirst('\\.jar$', '.unsorted.jar') File srcFile = new File(srcPath) jar.renameTo(srcFile) @@ -80,9 +94,18 @@ jar { } destStream.close() srcJarFile.close() + println 'Building ' + jarArchitecture + ' version has finished' } } +task aarch64LinuxJar(type: Jar) { + jarFactory(it, 'linux-aarch64') +} + +task x86LinuxJar(type: Jar) { + jarFactory(it, 'linux-x86_64') +} + // At the moment for non-Android projects we need to explicitly mark the code generated by kapt // as 'generated source code' for correct highlighting and resolve in IDE. idea {