Fixed libkiwix dependency

* Updated the source of libkiwix and libzim .so files to download.kiwix.org/release instead of using nightly builds.
* Introduced new variables for specifying the versions of libkiwix and libzim, allowing retrieval of .so files from the release repositories.
* Modified the README.md file to get the version and image from maven central for `org.kiwix.libkiwix` artifact.
This commit is contained in:
MohitMali 2023-07-19 11:20:47 +05:30
parent 423000e1a6
commit ebd27b53f1
2 changed files with 37 additions and 50 deletions

View File

@ -1,4 +1,4 @@
[![Maven Central](https://img.shields.io/maven-central/v/org.kiwix.kiwixlib/kiwixlib)](https://search.maven.org/artifact/org.kiwix.kiwixlib/kiwixlib) [![Maven Central](https://img.shields.io/maven-central/v/org.kiwix.libkiwix/libkiwix)](https://search.maven.org/artifact/org.kiwix.libkiwix/libkiwix)
[![CodeFactor](https://www.codefactor.io/repository/github/kiwix/java-libkiwix/badge)](https://www.codefactor.io/repository/github/kiwix/java-libkiwix) [![CodeFactor](https://www.codefactor.io/repository/github/kiwix/java-libkiwix/badge)](https://www.codefactor.io/repository/github/kiwix/java-libkiwix)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

View File

@ -1,5 +1,3 @@
import java.util.stream.Collectors
plugins { plugins {
id 'com.android.library' id 'com.android.library'
id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.android'
@ -24,6 +22,10 @@ ext {
set("VERSION", "1.0.0") set("VERSION", "1.0.0")
} }
// Replace these versions with the latest available versions of libkiwix and libzim
ext.libkiwix_version = "12.0.0"
ext.libzim_version = "8.2.0"
apply from: 'publish.gradle' apply from: 'publish.gradle'
android { android {
compileSdk 32 compileSdk 32
@ -74,19 +76,16 @@ dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
} }
ext.libkiwix_base_url = 'https://download.kiwix.org/nightly' ext.libkiwix_base_url = 'https://download.kiwix.org/release/libkiwix/'
ext.libzim_base_url = 'https://download.openzim.org/nightly' ext.libzim_base_url = 'https://download.openzim.org/release/libzim/'
ext.libkiwix_version = project.properties["libkiwix_version"] ?: ""
ext.libzim_version = project.properties["libzim_version"] ?: ""
task downloadLibzimSoAndHeaderFiles(type: Download) { task downloadLibzimSoAndHeaderFiles(type: Download) {
src([ src([
libzim_base_url + '/libzim_android-arm.tar.gz', libzim_base_url + 'libzim_android-arm-' + libzim_version + '.tar.gz',
libzim_base_url + '/libzim_android-arm64.tar.gz', libzim_base_url + 'libzim_android-arm64-' + libzim_version + '.tar.gz',
libzim_base_url + '/libzim_android-x86.tar.gz', libzim_base_url + 'libzim_android-x86-' + libzim_version + '.tar.gz',
libzim_base_url + '/libzim_android-x86_64.tar.gz', libzim_base_url + 'libzim_android-x86_64-' + libzim_version + '.tar.gz',
libzim_base_url + '/libzim_linux-x86_64-bionic.tar.gz' libzim_base_url + 'libzim_linux-x86_64-bionic-' + libzim_version + '.tar.gz'
]) ])
dest buildDir dest buildDir
overwrite true overwrite true
@ -94,24 +93,24 @@ task downloadLibzimSoAndHeaderFiles(type: Download) {
task unzipLibzim(type: Copy) { task unzipLibzim(type: Copy) {
// unzip android arm // unzip android arm
from tarTree(buildDir.path + "/libzim_android-arm.tar.gz") from tarTree(buildDir.path + "/libzim_android-arm-" + libzim_version + ".tar.gz")
into buildDir into buildDir
// unzip android arm64 // unzip android arm64
from tarTree(buildDir.path + "/libzim_android-arm64.tar.gz") from tarTree(buildDir.path + "/libzim_android-arm64-" + libzim_version + ".tar.gz")
into buildDir into buildDir
// unzip android x86 // unzip android x86
from tarTree(buildDir.path + "/libzim_android-x86.tar.gz") from tarTree(buildDir.path + "/libzim_android-x86-" + libzim_version + ".tar.gz")
into buildDir into buildDir
// unzip android x86_64 // unzip android x86_64
from tarTree(buildDir.path + "/libzim_android-x86_64.tar.gz") from tarTree(buildDir.path + "/libzim_android-x86_64-" + libzim_version + ".tar.gz")
into buildDir into buildDir
// unzip linux x86_64 // unzip linux x86_64
from tarTree(buildDir.path + "/libzim_linux-x86_64-bionic.tar.gz") from tarTree(buildDir.path + "/libzim_linux-x86_64-bionic-" + libzim_version + ".tar.gz")
into buildDir into buildDir
} }
task renameLibzimFolders() { task renameLibzimFolders() {
removeDateFromFolderName(buildDir.path,"libzim_") removeVersionFromFolderName(buildDir.path, "libzim_", libzim_version)
} }
task copyLibzimHeaderAndSoFiles(type: Copy) { task copyLibzimHeaderAndSoFiles(type: Copy) {
@ -147,8 +146,7 @@ task copyLibzimHeaderAndSoFiles(type: Copy) {
copy { copy {
// copying linux_x86_64 so file // copying linux_x86_64 so file
project.ext.set("libzim_version", getFileFromFolder(buildDir.path + "/libzim_linux-x86_64-bionic/lib/x86_64-linux-gnu/")) from buildDir.path + "/libzim_linux-x86_64-bionic/lib/x86_64-linux-gnu/libzim.so." + libzim_version
from buildDir.path + "/libzim_linux-x86_64-bionic/lib/x86_64-linux-gnu/" + libzim_version
into buildDir.path into buildDir.path
} }
} }
@ -156,35 +154,35 @@ task copyLibzimHeaderAndSoFiles(type: Copy) {
task renameLibzimSoFile(type: Copy) { task renameLibzimSoFile(type: Copy) {
if (libzim_version != null) { if (libzim_version != null) {
from(buildDir.path) from(buildDir.path)
include libzim_version include "libzim.so." + libzim_version
destinationDir file(buildDir.path) destinationDir file(buildDir.path)
rename libzim_version, "libzim.so" rename "libzim.so." + libzim_version, "libzim.so"
} }
} }
task downloadLibkiwixSoAndHeaderFiles(type: Download) { task downloadLibkiwixSoAndHeaderFiles(type: Download) {
src([ src([
libkiwix_base_url + '/libkiwix_android-arm.tar.gz', libkiwix_base_url + 'libkiwix_android-arm-' + libkiwix_version + '.tar.gz',
libkiwix_base_url + '/libkiwix_android-arm64.tar.gz', libkiwix_base_url + 'libkiwix_android-arm64-' + libkiwix_version + '.tar.gz',
libkiwix_base_url + '/libkiwix_android-x86.tar.gz', libkiwix_base_url + 'libkiwix_android-x86-' + libkiwix_version + '.tar.gz',
libkiwix_base_url + '/libkiwix_android-x86_64.tar.gz', libkiwix_base_url + 'libkiwix_android-x86_64-' + libkiwix_version + '.tar.gz',
libkiwix_base_url + '/libkiwix_linux-x86_64.tar.gz' libkiwix_base_url + 'libkiwix_linux-x86_64-' + libkiwix_version + '.tar.gz'
]) ])
dest buildDir dest buildDir
overwrite true overwrite true
} }
task renameLibkiwixFolders() { task renameLibkiwixFolders() {
removeDateFromFolderName(buildDir.path,"libkiwix_") removeVersionFromFolderName(buildDir.path, "libkiwix_", libkiwix_version)
} }
static void removeDateFromFolderName(String path, String startWith) { static void removeVersionFromFolderName(String path, String startWith, String version) {
File directory = new File(path) File directory = new File(path)
if (directory.exists() && directory.isDirectory()) { if (directory.exists() && directory.isDirectory()) {
Arrays.stream(directory.listFiles()) Arrays.stream(directory.listFiles())
.filter(folder -> folder.isDirectory() && folder.getName().startsWith(startWith)) .filter(folder -> folder.isDirectory() && folder.getName().startsWith(startWith))
.forEach(file -> { .forEach(file -> {
String newName = file.getName().replaceAll("-\\d{4}-\\d{2}-\\d{2}", "") String newName = file.getName().replace("-" + version, "")
File newFile = new File(directory, newName) File newFile = new File(directory, newName)
file.renameTo(newFile) file.renameTo(newFile)
}) })
@ -193,19 +191,19 @@ static void removeDateFromFolderName(String path, String startWith) {
task unzipLibkiwix(type: Copy) { task unzipLibkiwix(type: Copy) {
// unzip android arm // unzip android arm
from tarTree(buildDir.path + "/libkiwix_android-arm.tar.gz") from tarTree(buildDir.path + "/libkiwix_android-arm-" + libkiwix_version + ".tar.gz")
into buildDir into buildDir
// unzip android arm64 // unzip android arm64
from tarTree(buildDir.path + "/libkiwix_android-arm64.tar.gz") from tarTree(buildDir.path + "/libkiwix_android-arm64-" + libkiwix_version + ".tar.gz")
into buildDir into buildDir
// unzip android x86 // unzip android x86
from tarTree(buildDir.path + "/libkiwix_android-x86.tar.gz") from tarTree(buildDir.path + "/libkiwix_android-x86-" + libkiwix_version + ".tar.gz")
into buildDir into buildDir
// unzip android x86_64 // unzip android x86_64
from tarTree(buildDir.path + "/libkiwix_android-x86_64.tar.gz") from tarTree(buildDir.path + "/libkiwix_android-x86_64-" + libkiwix_version + ".tar.gz")
into buildDir into buildDir
// unzip linux x86_64 // unzip linux x86_64
from tarTree(buildDir.path + "/libkiwix_linux-x86_64.tar.gz") from tarTree(buildDir.path + "/libkiwix_linux-x86_64-" + libkiwix_version + ".tar.gz")
into buildDir into buildDir
} }
@ -242,28 +240,17 @@ task copyLibkiwixHeaderAndSoFiles(type: Copy) {
copy { copy {
// copying linux_x86_64 so file // copying linux_x86_64 so file
project.ext.set("libkiwix_version", getFileFromFolder(buildDir.path + "/libkiwix_linux-x86_64/lib/x86_64-linux-gnu/")) from buildDir.path + "/libkiwix_linux-x86_64/lib/x86_64-linux-gnu/libkiwix.so." + libkiwix_version
from buildDir.path + "/libkiwix_linux-x86_64/lib/x86_64-linux-gnu/" + libkiwix_version
into buildDir.path into buildDir.path
} }
} }
static String getFileFromFolder(String path) {
File folderFile = new File(path)
if (folderFile.exists()) {
return folderFile.listFiles()
.stream()
.filter(f -> f.length() > 0)
.collect(Collectors.toList())[0].name
}
}
task renameLibkiwixSoFile(type: Copy) { task renameLibkiwixSoFile(type: Copy) {
if (libkiwix_version != null) { if (libkiwix_version != null) {
from(buildDir.path) from(buildDir.path)
include libkiwix_version include "libkiwix.so." + libkiwix_version
destinationDir file(buildDir.path) destinationDir file(buildDir.path)
rename libkiwix_version, "libkiwix.so" rename "libkiwix.so." + libkiwix_version, "libkiwix.so"
} }
} }