1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 23:33:05 +04:00

Merge pull request #24956 from asmorkalov:as/android_build_offline

Added offline option for Android builds #24956

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
Alexander Smorkalov
2024-02-05 11:57:16 +03:00
committed by GitHub
parent 250cfe81c5
commit 8850a8219e
5 changed files with 32 additions and 27 deletions
+13 -12
View File
@@ -117,10 +117,10 @@ def main(args):
print("Running gradle assembleRelease...")
# Running gradle to build the Android project
subprocess.run(["./gradlew", "assembleRelease"],
shell=False,
cwd=ANDROID_PROJECT_DIR,
check=True)
cmd = ["./gradlew", "assembleRelease"]
if args.offline:
cmd = cmd + ["--offline"]
subprocess.run(cmd, shell=False, cwd=ANDROID_PROJECT_DIR, check=True)
print("Adding libs to AAR...")
# The created AAR package doesn't contain C++ shared libs.
@@ -146,20 +146,20 @@ def main(args):
shutil.copy(final_aar_path, path.join(ANDROID_PROJECT_DIR, "OpenCV/opencv-release.aar"))
print("Creating a maven repo from project sources (with sources jar and javadoc jar)...")
subprocess.run(["./gradlew", "publishReleasePublicationToMyrepoRepository"],
shell=False,
cwd=ANDROID_PROJECT_DIR,
check=True)
cmd = ["./gradlew", "publishReleasePublicationToMyrepoRepository"]
if args.offline:
cmd = cmd + ["--offline"]
subprocess.run(cmd, shell=False, cwd=ANDROID_PROJECT_DIR, check=True)
os.makedirs(path.join(FINAL_REPO_PATH, "org/opencv"), exist_ok=True)
shutil.move(path.join(ANDROID_PROJECT_DIR, "OpenCV/build/repo/org/opencv", MAVEN_PACKAGE_NAME),
path.join(FINAL_REPO_PATH, "org/opencv", MAVEN_PACKAGE_NAME))
print("Creating a maven repo from modified AAR (with cpp libraries)...")
subprocess.run(["./gradlew", "publishModifiedPublicationToMyrepoRepository"],
shell=False,
cwd=ANDROID_PROJECT_DIR,
check=True)
cmd = ["./gradlew", "publishModifiedPublicationToMyrepoRepository"]
if args.offline:
cmd = cmd + ["--offline"]
subprocess.run(cmd, shell=False, cwd=ANDROID_PROJECT_DIR, check=True)
# Replacing AAR from the first maven repo with modified AAR from the second maven repo
shutil.copytree(path.join(ANDROID_PROJECT_DIR, "OpenCV/build/repo/org/opencv", MAVEN_PACKAGE_NAME),
@@ -176,6 +176,7 @@ if __name__ == "__main__":
parser.add_argument('--java_version', default="1_8")
parser.add_argument('--ndk_location', default="")
parser.add_argument('--cmake_location', default="")
parser.add_argument('--offline', action="store_true", help="Force Gradle use offline mode")
args = parser.parse_args()
main(args)