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

Added support for SDK 34. #97

Merged
merged 4 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: adopt
java-version: 11
java-version: 17

- name: Install dependencies
run: bash ./install_deps.sh
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ buildscript {
maven { url 'https://plugins.gradle.org/m2/' }
}
dependencies {
classpath "com.android.tools.build:gradle:7.0.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
classpath 'io.github.gradle-nexus:publish-plugin:1.1.0'
classpath 'com.android.tools.build:gradle:8.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20"
classpath 'io.github.gradle-nexus:publish-plugin:2.0.0'
classpath 'de.undercouch:gradle-download-task:5.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle.kts files
Expand All @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'io.github.gradle-nexus.publish-plugin'

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Aug 12 19:44:15 IST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
64 changes: 37 additions & 27 deletions lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ ext.libzim_version = "9.2.1"

apply from: 'publish.gradle'
android {
compileSdk 32

compileSdk 34
namespace = "kiwix.org.kiwixlib"
defaultConfig {

minSdk 21
targetSdk 32
minSdk 24
targetSdk 34
versionCode 1
versionName "1.0"

Expand Down Expand Up @@ -69,6 +69,14 @@ android {
viewBinding true
}
ndkVersion '21.4.7075529'

// Enabled the lint to avoid potential errors.
lintOptions {
abortOnError true
checkAllWarnings = true
warningsAsErrors true
disable("GradleDependency", "UnknownNullness")
}
}

dependencies {
Expand All @@ -79,7 +87,7 @@ dependencies {
ext.libkiwix_base_url = 'https://download.kiwix.org/release/libkiwix/'
ext.libzim_base_url = 'https://download.openzim.org/release/libzim/'

task downloadLibzimSoAndHeaderFiles(type: Download) {
tasks.register('downloadLibzimSoAndHeaderFiles', Download) {
src([
libzim_base_url + 'libzim_android-arm-' + libzim_version + '.tar.gz',
libzim_base_url + 'libzim_android-arm64-' + libzim_version + '.tar.gz',
Expand All @@ -91,7 +99,8 @@ task downloadLibzimSoAndHeaderFiles(type: Download) {
overwrite true
}

task unzipLibzim(type: Copy) {
tasks.register('unzipLibzim', Copy) {
mustRunAfter downloadLibzimSoAndHeaderFiles
// unzip android arm
from tarTree(buildDir.path + "/libzim_android-arm-" + libzim_version + ".tar.gz")
into buildDir
Expand All @@ -109,11 +118,11 @@ task unzipLibzim(type: Copy) {
into buildDir
}

task renameLibzimFolders() {
tasks.register('renameLibzimFolders') {
removeVersionFromFolderName(buildDir.path, "libzim_", libzim_version)
}

task copyLibzimHeaderAndSoFiles(type: Copy) {
tasks.register('copyLibzimHeaderAndSoFiles', Copy) {
copy {
// copying header file
from buildDir.path + "/libzim_android-arm/include/"
Expand Down Expand Up @@ -151,7 +160,7 @@ task copyLibzimHeaderAndSoFiles(type: Copy) {
}
}

task renameLibzimSoFile(type: Copy) {
tasks.register('renameLibzimSoFile', Copy) {
if (libzim_version != null) {
def finalLibzimVersion = getActualLibraryVersion(libzim_version)

Expand All @@ -167,7 +176,7 @@ task renameLibzimSoFile(type: Copy) {
}
}

task downloadLibkiwixSoAndHeaderFiles(type: Download) {
tasks.register('downloadLibkiwixSoAndHeaderFiles', Download) {
src([
libkiwix_base_url + 'libkiwix_android-arm-' + libkiwix_version + '.tar.gz',
libkiwix_base_url + 'libkiwix_android-arm64-' + libkiwix_version + '.tar.gz',
Expand All @@ -179,7 +188,7 @@ task downloadLibkiwixSoAndHeaderFiles(type: Download) {
overwrite true
}

task renameLibkiwixFolders() {
tasks.register('renameLibkiwixFolders') {
removeVersionFromFolderName(buildDir.path, "libkiwix_", libkiwix_version)
}

Expand All @@ -196,7 +205,8 @@ static void removeVersionFromFolderName(String path, String startWith, String ve
}
}

task unzipLibkiwix(type: Copy) {
tasks.register('unzipLibkiwix', Copy) {
mustRunAfter downloadLibkiwixSoAndHeaderFiles
// unzip android arm
from tarTree(buildDir.path + "/libkiwix_android-arm-" + libkiwix_version + ".tar.gz")
into buildDir
Expand All @@ -214,7 +224,7 @@ task unzipLibkiwix(type: Copy) {
into buildDir
}

task copyLibkiwixHeaderAndSoFiles(type: Copy) {
tasks.register('copyLibkiwixHeaderAndSoFiles', Copy) {
copy {
// copying header file
from buildDir.path + "/libkiwix_android-arm/include/kiwix/"
Expand Down Expand Up @@ -252,7 +262,7 @@ task copyLibkiwixHeaderAndSoFiles(type: Copy) {
}
}

task renameLibkiwixSoFile(type: Copy) {
tasks.register('renameLibkiwixSoFile', Copy) {
if (libkiwix_version != null) {
def finalLibkiwixVersion = getActualLibraryVersion(libkiwix_version)
def sourceFile = file(buildDir.path + "/libkiwix.so." + finalLibkiwixVersion)
Expand All @@ -277,50 +287,50 @@ static String getActualLibraryVersion(String libraryVersion) {
return dashIndex != -1 ? libraryVersion.substring(0, dashIndex) : libraryVersion
}

task testSourceJar(type: Jar) {
tasks.register('testSourceJar', Jar) {
from android.sourceSets.test.java.srcDirs
archiveName = 'test-sources.jar'
archiveBaseName = 'test-sources'
}

task compileTestFile(type: JavaCompile) {
tasks.register('compileTestFile', JavaCompile) {
dependsOn testSourceJar
source = file('src/test')
destinationDirectory = file("$buildDir")
classpath = files("src/test/junit-4.13.jar" , "src/test/hamcrest-core-1.4.jar", "build/libs/test-sources.jar")
classpath = files("src/test/junit-4.13.jar", "src/test/hamcrest-core-1.4.jar", "build/libs/test-sources-${VERSION}.jar")
}

task runTests(type: JavaExec) {
tasks.register('runTests', JavaExec) {
workingDir("$projectDir/src/test/")
dependsOn compileTestFile
classpath = files("$buildDir", 'src/test/java/', 'src/test/junit-4.13.jar', 'src/test/hamcrest-core-1.3.jar')
main = 'org.junit.runner.JUnitCore'
mainClass = 'org.junit.runner.JUnitCore'
args = ['test']
jvmArgs = [
'-Djava.library.path=' + buildDir.path,
'-javaagent:jacoco-0.8.7/lib/jacocoagent.jar=destfile=../../build/jacoco/jacoco.exec'
]
}

task createCodeCoverageReport(type: JavaExec) {
tasks.register('createCodeCoverageReport', JavaExec) {
workingDir "${projectDir}/src/test/"
dependsOn runTests
classpath = files('src/test/', 'src/test/java/', 'src/test/junit-4.13.jar', 'src/test/hamcrest-core-1.3.jar', 'src/test/jacoco-0.8.7/lib/*')
main = 'org.jacoco.cli.internal.Main'
mainClass = 'org.jacoco.cli.internal.Main'
args = [
'report', '../../build/jacoco/jacoco.exec',
'--classfiles', 'java/org/kiwix', '--classfiles', '../../build/org/kiwix',
'--html', '../../build/coverage-report', '--xml', '../../build/coverage.xml'
]
}

task checkCurrentJavaVersion() {
if (JavaVersion.current() != JavaVersion.VERSION_11) {
throw new RuntimeException("This build must be run with java 11. your current java version is ${JavaVersion.current()}")
tasks.register('checkCurrentJavaVersion') {
if (JavaVersion.current() != JavaVersion.VERSION_17) {
throw new RuntimeException("This build must be run with java 17. your current java version is ${JavaVersion.current()}")
}
}


task buildHeaders(type: Exec) {
tasks.register('buildHeaders', Exec) {
workingDir "${projectDir}/src/main/java/org/kiwix/"
commandLine 'bash', '-c', "javac -h ${buildDir}/include/javah_generated/ -d ${projectDir}/src/test/java/ ${getLibzimFiles()} ${getLibkiwixFiles()}"
}
Expand Down Expand Up @@ -358,7 +368,7 @@ String getLibzimFiles() {
"${projectDir}/src/main/java/org/kiwix/libzim/FdInput.java"
}

task buildLinuxBinding(type: Exec) {
tasks.register('buildLinuxBinding', Exec) {
workingDir "${projectDir}/src/main/cpp/"
commandLine 'bash', '-c', "cmake . -B ${buildDir} && make -C ${buildDir}"
}
Expand Down
2 changes: 1 addition & 1 deletion lib/publish.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'

task androidSourcesJar(type: Jar) {
tasks.register('androidSourcesJar', Jar) {
archiveClassifier.set('sources')
if (project.plugins.findPlugin("com.android.library")) {
// For Android libraries
Expand Down
5 changes: 1 addition & 4 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"

package="kiwix.org.kiwixlib"
>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application android:allowBackup="true"
android:label="@string/app_name"
Expand Down