@@ -68,6 +68,12 @@ android {
6868 }
6969 ndkVersion ' 21.4.7075529'
7070
71+ configurations {
72+ testCompileClasspath. extendsFrom(compileClasspath)
73+ testRuntimeClasspath. extendsFrom(testCompileClasspath)
74+ testImplementation. extendsFrom(implementation)
75+ testRuntimeOnly. extendsFrom(runtimeOnly)
76+ }
7177}
7278
7379dependencies {
@@ -80,11 +86,6 @@ ext.libzim_base_url = 'https://download.openzim.org/nightly'
8086// temporary url for libzim linux variant zim file, Once https://github.com/openzim/libzim/issues/772 fixed, then we can remove this
8187ext. linux_libzim_base_url = ' https://download.openzim.org/nightly/2023-03-20'
8288
83- ext. nightly_date_for_libkiwix = project. properties[" nightly_date_for_libkiwix" ] ?: " "
84- ext. nightly_date_for_libkiwix_linux = project. properties[" nightly_date_for_libkiwix_linux" ] ?: " "
85- ext. nightly_date_for_libzim = project. properties[" nightly_date_for_libzim" ] ?: " "
86- ext. nightly_date_for_libzim_linux = project. properties[" nightly_date_for_libzim_linux" ] ?: " "
87-
8889ext. libkiwix_version = project. properties[" libkiwix_version" ] ?: " "
8990ext. libzim_version = project. properties[" libzim_version" ] ?: " "
9091
@@ -100,14 +101,6 @@ task downloadLibzimSoAndHeaderFiles(type: Download) {
100101 overwrite true
101102}
102103
103- task checkCurrentLibzimDate () {
104- project. ext. set(" nightly_date_for_libzim" , getDateFromPath(buildDir. path, " libzim_android-arm64-" ))
105- }
106-
107- task checkCurrentLinuxLibzimDate () {
108- project. ext. set(" nightly_date_for_libzim_linux" , getDateFromPath(buildDir. path, " libzim_linux-x86_64-" ))
109- }
110-
111104task unzipLibzim (type : Copy ) {
112105 // unzip android arm
113106 from tarTree(buildDir. path + " /libzim_android-arm.tar.gz" )
@@ -126,41 +119,45 @@ task unzipLibzim(type: Copy) {
126119 into buildDir
127120}
128121
122+ task renameLibzimFolders () {
123+ renameFolders(buildDir. path," libzim_" )
124+ }
125+
129126task copyLibzimHeaderAndSoFiles (type : Copy ) {
130127 copy {
131128 // copying header file
132- from buildDir. path + " /libzim_android-arm- " + nightly_date_for_libzim + ' /include/'
129+ from buildDir. path + " /libzim_android-arm/include/"
133130 into buildDir. path + " /include/libzim/"
134131 }
135132
136133 copy {
137134 // copying android_arm so file
138- from buildDir. path + " /libzim_android-arm- " + nightly_date_for_libzim + ' /lib/arm-linux-androideabi/'
135+ from buildDir. path + " /libzim_android-arm/lib/arm-linux-androideabi/"
139136 into buildDir. path + " /jniLibs/armeabi-v7a/libzim/"
140137 }
141138
142139 copy {
143140 // copying android_arm64 so file
144- from buildDir. path + " /libzim_android-arm64- " + nightly_date_for_libzim + ' /lib/aarch64-linux-android/'
141+ from buildDir. path + " /libzim_android-arm64/lib/aarch64-linux-android/"
145142 into buildDir. path + " /jniLibs/arm64-v8a/libzim/"
146143 }
147144
148145 copy {
149146 // copying android_x86 so file
150- from buildDir. path + " /libzim_android-x86- " + nightly_date_for_libzim + ' /lib/i686-linux-android/'
147+ from buildDir. path + " /libzim_android-x86/lib/i686-linux-android/"
151148 into buildDir. path + " /jniLibs/x86/libzim/"
152149 }
153150
154151 copy {
155152 // copying android_x86_64 so file
156- from buildDir. path + " /libzim_android-x86_64- " + nightly_date_for_libzim + ' /lib/x86_64-linux-android/'
153+ from buildDir. path + " /libzim_android-x86_64/lib/x86_64-linux-android/"
157154 into buildDir. path + " /jniLibs/x86_64/libzim/"
158155 }
159156
160157 copy {
161158 // copying linux_x86_64 so file
162- project. ext. set(" libzim_version" , getFileFromFolder(buildDir. path + " /libzim_linux-x86_64- " + nightly_date_for_libzim_linux + " /lib/x86_64-linux-gnu/" ))
163- from buildDir. path + " /libzim_linux-x86_64- " + nightly_date_for_libzim_linux + " /lib/x86_64-linux-gnu/" + libzim_version
159+ project. ext. set(" libzim_version" , getFileFromFolder(buildDir. path + " /libzim_linux-x86_64/lib/x86_64-linux-gnu/" ))
160+ from buildDir. path + " /libzim_linux-x86_64/lib/x86_64-linux-gnu/" + libzim_version
164161 into buildDir. path
165162 }
166163}
@@ -186,22 +183,20 @@ task downloadLibkiwixSoAndHeaderFiles(type: Download) {
186183 overwrite true
187184}
188185
189- task checkCurrentLibkiwixDate () {
190- project . ext . set( " nightly_date_for_libkiwix " , getDateFromPath( buildDir. path, " libkiwix_android-arm64- " ) )
186+ task renameLibkiwixFolders () {
187+ renameFolders( buildDir. path," libkiwix_ " )
191188}
192189
193- task checkCurrentLinuxLibkiwixDate () {
194- project. ext. set(" nightly_date_for_libkiwix_linux" , getDateFromPath(buildDir. path, " libkiwix_linux-x86_64-" ))
195- }
196-
197- static String getDateFromPath (String path , String matchesString ) {
198- File folder = new File (path)
199- if (folder. exists()) {
200- return folder. listFiles()
201- .stream()
202- .filter(f -> f. name. startsWith(matchesString))
203- .map(s -> s. name. replace(matchesString, " " ))
204- .collect(Collectors . toList())[0 ]
190+ static void renameFolders (String path , String startWith ) {
191+ File directory = new File (path)
192+ if (directory. exists() && directory. isDirectory()) {
193+ Arrays . stream(directory. listFiles())
194+ .filter(folder -> folder. isDirectory() && folder. getName(). startsWith(startWith))
195+ .forEach(file -> {
196+ String newName = file. getName(). replaceAll(" -\\ d{4}-\\ d{2}-\\ d{2}" , " " )
197+ File newFile = new File (directory, newName)
198+ file. renameTo(newFile)
199+ })
205200 }
206201}
207202
@@ -226,38 +221,38 @@ task unzipLibkiwix(type: Copy) {
226221task copyLibkiwixHeaderAndSoFiles (type : Copy ) {
227222 copy {
228223 // copying header file
229- from buildDir. path + " /libkiwix_android-arm- " + nightly_date_for_libkiwix + ' /include/kiwix/'
224+ from buildDir. path + " /libkiwix_android-arm/include/kiwix/"
230225 into buildDir. path + " /include/libkiwix/"
231226 }
232227
233228 copy {
234229 // copying android_arm so file
235- from buildDir. path + " /libkiwix_android-arm- " + nightly_date_for_libkiwix + ' /lib/arm-linux-androideabi/'
230+ from buildDir. path + " /libkiwix_android-arm/lib/arm-linux-androideabi/"
236231 into buildDir. path + " /jniLibs/armeabi-v7a/libkiwix/"
237232 }
238233
239234 copy {
240235 // copying android_arm64 so file
241- from buildDir. path + " /libkiwix_android-arm64- " + nightly_date_for_libkiwix + ' /lib/aarch64-linux-android/'
236+ from buildDir. path + " /libkiwix_android-arm64/lib/aarch64-linux-android/"
242237 into buildDir. path + " /jniLibs/arm64-v8a/libkiwix/"
243238 }
244239
245240 copy {
246241 // copying android_x86 so file
247- from buildDir. path + " /libkiwix_android-x86- " + nightly_date_for_libkiwix + ' /lib/i686-linux-android/'
242+ from buildDir. path + " /libkiwix_android-x86/lib/i686-linux-android/"
248243 into buildDir. path + " /jniLibs/x86/libkiwix/"
249244 }
250245
251246 copy {
252247 // copying android_x86_64 so file
253- from buildDir. path + " /libkiwix_android-x86_64- " + nightly_date_for_libkiwix + ' /lib/x86_64-linux-android/'
248+ from buildDir. path + " /libkiwix_android-x86_64/lib/x86_64-linux-android/"
254249 into buildDir. path + " /jniLibs/x86_64/libkiwix/"
255250 }
256251
257252 copy {
258253 // copying linux_x86_64 so file
259- project. ext. set(" libkiwix_version" , getFileFromFolder(buildDir. path + " /libkiwix_linux-x86_64- " + nightly_date_for_libkiwix_linux + " /lib/x86_64-linux-gnu/" ))
260- from buildDir. path + " /libkiwix_linux-x86_64- " + nightly_date_for_libkiwix_linux + " /lib/x86_64-linux-gnu/" + libkiwix_version
254+ project. ext. set(" libkiwix_version" , getFileFromFolder(buildDir. path + " /libkiwix_linux-x86_64/lib/x86_64-linux-gnu/" ))
255+ from buildDir. path + " /libkiwix_linux-x86_64/lib/x86_64-linux-gnu/" + libkiwix_version
261256 into buildDir. path
262257 }
263258}
0 commit comments