From 29015e1cd704d0c59f9ecd7059260a6593f166a7 Mon Sep 17 00:00:00 2001 From: halx99 Date: Wed, 2 Jun 2021 06:27:19 +0800 Subject: [PATCH] Make gradle utils file as shared [ci build] --- .../android/libcocos2dx}/adxetools.gradle | 0 .../proj.android/app/build.gradle | 2 +- .../proj.android/app/adxetools.gradle | 142 ------------------ .../runtime-src/proj.android/app/build.gradle | 2 +- .../proj.android/app/adxetools.gradle | 142 ------------------ .../proj.android/app/build.gradle | 2 +- .../proj.android/app/adxetools.gradle | 142 ------------------ tests/cpp-tests/proj.android/app/build.gradle | 2 +- .../proj.android/app/adxetools.gradle | 142 ------------------ .../proj.android/app/build.gradle | 2 +- .../project/proj.android/app/adxetools.gradle | 142 ------------------ .../project/proj.android/app/build.gradle | 2 +- .../project/proj.android/app/adxetools.gradle | 142 ------------------ .../project/proj.android/app/build.gradle | 2 +- 14 files changed, 7 insertions(+), 859 deletions(-) rename {templates/cpp-template-default/proj.android/app => cocos/platform/android/libcocos2dx}/adxetools.gradle (100%) delete mode 100644 templates/lua-template-default/frameworks/runtime-src/proj.android/app/adxetools.gradle delete mode 100644 tests/cpp-empty-test/proj.android/app/adxetools.gradle delete mode 100644 tests/cpp-tests/proj.android/app/adxetools.gradle delete mode 100644 tests/fairygui-tests/proj.android/app/adxetools.gradle delete mode 100644 tests/lua-empty-test/project/proj.android/app/adxetools.gradle delete mode 100644 tests/lua-tests/project/proj.android/app/adxetools.gradle diff --git a/templates/cpp-template-default/proj.android/app/adxetools.gradle b/cocos/platform/android/libcocos2dx/adxetools.gradle similarity index 100% rename from templates/cpp-template-default/proj.android/app/adxetools.gradle rename to cocos/platform/android/libcocos2dx/adxetools.gradle diff --git a/templates/cpp-template-default/proj.android/app/build.gradle b/templates/cpp-template-default/proj.android/app/build.gradle index b342cc56ba6d..558f050dee10 100644 --- a/templates/cpp-template-default/proj.android/app/build.gradle +++ b/templates/cpp-template-default/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/adxetools.gradle b/templates/lua-template-default/frameworks/runtime-src/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle b/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle index 4e3d844a4b21..91528ada78c8 100644 --- a/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle +++ b/templates/lua-template-default/frameworks/runtime-src/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/tests/cpp-empty-test/proj.android/app/adxetools.gradle b/tests/cpp-empty-test/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/tests/cpp-empty-test/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/tests/cpp-empty-test/proj.android/app/build.gradle b/tests/cpp-empty-test/proj.android/app/build.gradle index b8b6aaae54fa..0289b194c38d 100644 --- a/tests/cpp-empty-test/proj.android/app/build.gradle +++ b/tests/cpp-empty-test/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/tests/cpp-tests/proj.android/app/adxetools.gradle b/tests/cpp-tests/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/tests/cpp-tests/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/tests/cpp-tests/proj.android/app/build.gradle b/tests/cpp-tests/proj.android/app/build.gradle index 1579d222fa02..3a2b1a282c38 100644 --- a/tests/cpp-tests/proj.android/app/build.gradle +++ b/tests/cpp-tests/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/tests/fairygui-tests/proj.android/app/adxetools.gradle b/tests/fairygui-tests/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/tests/fairygui-tests/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/tests/fairygui-tests/proj.android/app/build.gradle b/tests/fairygui-tests/proj.android/app/build.gradle index f47a64d1f330..fcd886cb9247 100644 --- a/tests/fairygui-tests/proj.android/app/build.gradle +++ b/tests/fairygui-tests/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/tests/lua-empty-test/project/proj.android/app/adxetools.gradle b/tests/lua-empty-test/project/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/tests/lua-empty-test/project/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/tests/lua-empty-test/project/proj.android/app/build.gradle b/tests/lua-empty-test/project/proj.android/app/build.gradle index 9b3bf4f35b02..bd0ea6b7bbbf 100644 --- a/tests/lua-empty-test/project/proj.android/app/build.gradle +++ b/tests/lua-empty-test/project/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() diff --git a/tests/lua-tests/project/proj.android/app/adxetools.gradle b/tests/lua-tests/project/proj.android/app/adxetools.gradle deleted file mode 100644 index a9feb623bc7f..000000000000 --- a/tests/lua-tests/project/proj.android/app/adxetools.gradle +++ /dev/null @@ -1,142 +0,0 @@ -import java.nio.file.Files -import java.nio.file.Paths - -class VersionComparator implements Comparator { - - static private final List SNAPSHOT_SUFFIXES = ["-SNAPSHOT", ".BUILD-SNAPSHOT"].asImmutable() - - int compare(String o1, String o2) { - int result = 0 - if (o1 == '*') { - result = 1 - } - else if (o2 == '*') { - result = -1 - } - else { - def nums1 - try { - def tokens = deSnapshot(o1).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums1 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, left side [$o1] is invalid: ${e.message}") - } - def nums2 - try { - def tokens = deSnapshot(o2).split(/\./) - tokens = tokens.findAll { String it -> it.trim() ==~ /\d+/ } - nums2 = tokens*.toInteger() - } - catch (NumberFormatException e) { - throw new Exception("Cannot compare versions, right side [$o2] is invalid: ${e.message}") - } - boolean bigRight = nums2.size() > nums1.size() - boolean bigLeft = nums1.size() > nums2.size() - for (int i in 0.. i) { - result = nums1[i].compareTo(nums2[i]) - if (result != 0) { - break - } - if (i == (nums1.size()-1) && bigRight) { - if (nums2[i+1] != 0) - result = -1; break - } - } - else if (bigLeft) { - if (nums1[i] != 0) - result = 1; break - } - } - } - - if (result == 0) { - // Versions are equal, but one may be a snapshot. - // A snapshot version is considered less than a non snapshot version - def o1IsSnapshot = isSnapshot(o1) - def o2IsSnapshot = isSnapshot(o2) - - if (o1IsSnapshot && !o2IsSnapshot) { - result = -1 - } else if (!o1IsSnapshot && o2IsSnapshot) { - result = 1 - } - } - - result - } - - boolean equals(obj) { false } - - /** - * Removes any suffixes that indicate that the version is a kind of snapshot - */ - protected String deSnapshot(String version) { - String suffix = SNAPSHOT_SUFFIXES.find { String it -> version?.endsWith(it) } - if (suffix) { - return version[0..-(suffix.size() + 1)] - } else { - return version - } - } - - protected boolean isSnapshot(String version) { - SNAPSHOT_SUFFIXES.any { String it -> version?.endsWith(it) } - } - - -} - -class adxetools { - static int compareVersion(String ver1, String ver2) { - return new VersionComparator().compare(ver1, ver2); - } - - static String[] findNDK(String ndkVer){ - def allowNewerNdk = false - if(ndkVer.endsWith('+')) { - allowNewerNdk = true - ndkVer = ndkVer.substring(0, ndkVer.length() - 1) - } - - def ndkRoot = Paths.get("${System.env.ANDROID_NDK}") - if(Files.exists(ndkRoot)) { - ndkRoot = ndkRoot.toAbsolutePath().toString() - def properties = new Properties() - File propertiesFile = new File("$ndkRoot/source.properties") - propertiesFile.withInputStream { - properties.load(it) - def foundNdkVer = properties['Pkg.Revision'] - def ret = adxetools.compareVersion(foundNdkVer, ndkVer) - if(ret == 0) { - println("Using found ndk revision=$foundNdkVer") - } - else if(ret > 0){ - if(allowNewerNdk) { - println("Using found newer ndk revision=$foundNdkVer, required is: ${ndkVer}") - ndkVer = foundNdkVer - } - else { - throw new GradleException("${ndkVer} is required, but $foundNdkVer found!") - } - } - else { - throw new GradleException("${ndkVer}+ is required, but $foundNdkVer found!") - } - } - } - else { - ndkRoot = null - println("The gradle will install ndk: $ndkVer automatically") - } - - def rets = new String[2] - rets[0] = ndkVer - rets[1] = ndkRoot - return rets - } -} - -ext.adxetools = adxetools diff --git a/tests/lua-tests/project/proj.android/app/build.gradle b/tests/lua-tests/project/proj.android/app/build.gradle index d76b9d1fd7c8..5a7446c3bc6c 100644 --- a/tests/lua-tests/project/proj.android/app/build.gradle +++ b/tests/lua-tests/project/proj.android/app/build.gradle @@ -3,7 +3,7 @@ import java.nio.file.Paths import java.nio.file.Files apply plugin: 'com.android.application' -apply from: 'adxetools.gradle' +apply from: project(':libcocos2dx').projectDir.toString() + "/adxetools.gradle" android { compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger()