Skip to content
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Mapbox welcomes participation and contributions from everyone.
#### Features

#### Bug fixes and improvements
- Added a workaround for [`ConnectivityManager`'s occasional security exception on Android 11 and older](https://issuetracker.google.com/issues/175055271). [#5492](https://github.com/mapbox/mapbox-navigation-android/pull/5492)

## Mapbox Navigation SDK 2.3.0-rc.1 - February 17, 2022

Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ subprojects {
}

apply from: "${rootDir}/gradle/kdoc-settings.gradle"
apply from: "${rootDir}/gradle/verify-common-sdk-version.gradle"

dokkaHtmlMultiModule {
outputDirectory.set(kdocPath)
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ext {
mapboxEvents : '8.1.1',
mapboxCore : '5.0.1',
mapboxNavigator : "${mapboxNavigatorVersion}",
mapboxCommonNative : '21.1.0',
mapboxCommonNative : '21.1.1',
mapboxCrashMonitor : '2.0.0',
mapboxAnnotationPlugin : '0.8.0',
mapboxBaseAndroid : '0.5.0',
Expand Down
113 changes: 56 additions & 57 deletions gradle/verify-common-sdk-version.gradle
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
def navigatorModuleName = "libnavigator"
def moduleNames = ["libnavigation-core", navigatorModuleName]
import java.util.regex.Matcher
import java.util.regex.Pattern

task verifyCommonSdkVersion {
moduleNames.each { moduleName ->
dependsOn ":" + moduleName + ":generateDependencyReportFile"
}
doLast {
def moduleDependencyMap = [:]
moduleNames.each { moduleName ->
String commonDependency
if (moduleName == navigatorModuleName) {
commonDependency = parseNavigatorCommonLibDependency()
} else {
commonDependency = parseCommonLibDependency(moduleName)
}
moduleDependencyMap[moduleName] = commonDependency
}
moduleNames.each { moduleName ->
if (moduleName != navigatorModuleName
&& moduleDependencyMap[moduleName] != moduleDependencyMap[navigatorModuleName]) {
throw new GradleException(moduleName + " (" + moduleDependencyMap[moduleName] + ") " +
"and " + navigatorModuleName + " (" + moduleDependencyMap[navigatorModuleName] + ") " +
"have different versions of Common SDK library. " +
"Please align Common SDK version in both SDKs before push changes.")
}
}
println("Common SDK versions are equal for Navigation SDK and for Navigation Native")
println(moduleDependencyMap)
}
task generateDependencyReportFile(type: DependencyReportTask) {
outputFile = file("build/reports/dependencies_report.txt")
}

allprojects.findAll {it.name in moduleNames}.each { p ->
configure(p) {
task generateDependencyReportFile(type: DependencyReportTask) {
outputFile = file("build/reports/dependencies_report.txt")
/**
* Task that verifies that Nav SDK and all transitive dependencies use the same major and minor versions of the Common SDK.
* Different patch versions are allowed.
*/
task verifyCommonSdkVersion(dependsOn: generateDependencyReportFile) {
doLast {
File dependenciesFile = new File(projectDir.toString() + "/build/reports/dependencies_report.txt")
// find main classpath
int startIndex = dependenciesFile.text.indexOf("releaseCompileClasspath")
// find the end of the classpath definition
int lastIndex = dependenciesFile.text.indexOf("\n\n", startIndex)
String dependenciesString = dependenciesFile.text.substring(startIndex, lastIndex)

// find all Common SDK versions
Set<String> commonVersions = new ArrayList<>()
Pattern p = Pattern.compile("com.mapbox.common:common:\\d+\\.\\d+\\.\\d+")
Matcher m = p.matcher(dependenciesString)
while (m.find()) {
String[] elements = m.group().split(":")
commonVersions.add(elements[elements.length - 1])
}
}
}

static def parseCommonLibDependency(String moduleName) {
File dependenciesFile = new File(moduleName + "/build/reports/dependencies_report.txt")
int startSearchIndex = dependenciesFile.text.indexOf("releaseCompileClasspath")
return getCommonLibDependency(dependenciesFile, startSearchIndex)
}
if (commonVersions.size() > 1) {
// verify that major and minor versions are consistent
String mismatchArea = null

static def parseNavigatorCommonLibDependency() {
File dependenciesFile = new File("libnavigator/build/reports/dependencies_report.txt")
int configurationStartIndex = dependenciesFile.text.indexOf("releaseCompileClasspath")
int startSearchIndex = dependenciesFile.text.indexOf(
"com.mapbox.navigator:mapbox-navigation-native",
configurationStartIndex
)
return getCommonLibDependency(dependenciesFile, startSearchIndex)
}
// splitting up each versioning component and counting distinct occurrences
// example of versionComponents with mismatched MINOR version: [[21, 2, 0], [21, 1, 0]]
String[][] versionComponents = commonVersions.stream().map({ it.split("\\.") }).toArray()
if (Arrays.stream(versionComponents).map({ it[0] }).distinct().count() != 1) {
mismatchArea = "MAJOR"
} else if (Arrays.stream(versionComponents).map({ it[1] }).distinct().count() != 1) {
mismatchArea = "MINOR"
}

static def getCommonLibDependency(File dependenciesFile, int startSearchIndex) {
int firstIndexCommonLib = dependenciesFile.text.indexOf("com.mapbox.common:common:", startSearchIndex)
int lastIndexCommonLib = Math.min(
dependenciesFile.text.indexOf("\n", firstIndexCommonLib),
dependenciesFile.text.indexOf(" ", firstIndexCommonLib)
)
String commonLibDependency = dependenciesFile.text.substring(firstIndexCommonLib, lastIndexCommonLib)
return commonLibDependency
if (mismatchArea != null) {
println("Dependencies for " + project.toString() + ":")
println(dependenciesString)
throw new IllegalArgumentException(
mismatchArea + " Common SDK versions across dependencies are mismatched."
+ " All projects should use the same major and minor versions of the Common SDK.\n"
+ " Found versions: " + commonVersions
)
} else if (Arrays.stream(versionComponents).map({ it[2] }).distinct().count() != 1) {
println(
"INFO: Common SDK versions across all dependencies use different patches (which is acceptable).\n"
+ "Found versions: " + commonVersions
)
}
} else {
println(
"Common SDK version is consistent across all dependencies.\n"
+ "Found version: " + commonVersions
)
}
}
}
1 change: 1 addition & 0 deletions libnavigation-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ dependencies {
apply from: "${rootDir}/gradle/track-public-apis.gradle"
apply from: "${rootDir}/gradle/jacoco.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
apply from: "${rootDir}/gradle/verify-common-sdk-version.gradle"