Commit 43a91f82 authored by hannesa2's avatar hannesa2 Committed by Alexander Alekhin

Merge pull request #16222 from hannesa2:AndroidMoveVersionInfo

Android move version info to Gradle style

* move version info to Gradle style

* Use VERSION_NAME in loader

* apply review suggestion
parent ccfca869
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv" package="org.opencv" >
android:versionCode="@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@0"
android:versionName="@OPENCV_VERSION@">
</manifest> </manifest>
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
def openCVersionName = "@OPENCV_VERSION@"
def openCVersionCode = ((@OPENCV_VERSION_MAJOR@ * 100 + @OPENCV_VERSION_MINOR@) * 100 + @OPENCV_VERSION_PATCH@) * 10 + 0
android { android {
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@
//buildToolsVersion "x.y.z" // not needed since com.android.tools.build:gradle:3.0.0
defaultConfig { defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@ minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
versionCode openCVersionCode
versionName openCVersionName
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments "-DANDROID_STL=@ANDROID_STL@" arguments "-DANDROID_STL=@ANDROID_STL@"
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.opencv" package="org.opencv">
android:versionCode="@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@0"
android:versionName="@OPENCV_VERSION@">
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" /> <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="21" />
</manifest> </manifest>
...@@ -90,16 +90,21 @@ ...@@ -90,16 +90,21 @@
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
println "OpenCV: " + project.buildscript.sourceFile def openCVersionName = "@OPENCV_VERSION@"
def openCVersionCode = @OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@@OPENCV_VERSION_PATCH@0
println "OpenCV: " +openCVersionName + " " + project.buildscript.sourceFile
android { android {
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@ compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@
//buildToolsVersion "x.y.z" // not needed since com.android.tools.build:gradle:3.0.0
defaultConfig { defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@ minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@ targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
versionCode openCVersionCode
versionName openCVersionName
externalNativeBuild { externalNativeBuild {
cmake { cmake {
arguments "-DANDROID_STL=@ANDROID_STL@" arguments "-DANDROID_STL=@ANDROID_STL@"
......
...@@ -2,6 +2,8 @@ package org.opencv.android; ...@@ -2,6 +2,8 @@ package org.opencv.android;
import android.content.Context; import android.content.Context;
import org.opencv.BuildConfig;
/** /**
* Helper class provides common initialization methods for OpenCV library. * Helper class provides common initialization methods for OpenCV library.
*/ */
...@@ -95,7 +97,7 @@ public class OpenCVLoader ...@@ -95,7 +97,7 @@ public class OpenCVLoader
/** /**
* Current OpenCV Library version * Current OpenCV Library version
*/ */
public static final String OPENCV_VERSION = "@OPENCV_VERSION_MAJOR@.@OPENCV_VERSION_MINOR@.@OPENCV_VERSION_PATCH@"; public static final String OPENCV_VERSION = BuildConfig.VERSION_NAME;
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment