Closed 256p closed 1 year ago
Hi @256p Thank you so much for contributing this patch for EDM4U! We are doing very similar things in #610 with some additional touches
**DIR_UNITYPROJECT**
unfortunately. Therefore we added two settings to force EDM4U to always use absolute path.Still we appreciate your effort to put together this change for the community. And kudos to you to also add integration tests! The proper fix for this is a bit involved so we spent some time to make sure the experience is right.
I will close this PR for now.
Regards, Shawn
This PR fixes https://github.com/googlesamples/unity-jar-resolver/issues/594#issue-1553387077
Changes influence only builds when main Gradle template patching is enabled.
Changes:
settingsTemplate.gradle
/resolve/gradlesettingstemplate
report URL to the analytics. (Not sure if it is needed)The logic of repositories injection depends on the project state:
mainTemplate.gradle
andsettingsTemplate.gradle
are enabled and mainTemplate patching and settingsTemplate patching in Android Resolver settings are enabled:settingsTemplate.gradle
containsdependencyResolutionManagement
block withRepositoriesMode.PREFER_SETTINGS
orRepositoriesMode.FAIL_ON_PROJECT_REPOS
. If the match is successful it would mean that Gradle is configured to read repositories fromsettingsTemplate.gradle
and will not read repositories specified inmainTemplate.gradle
.settingsTemplate.gradle
beforedependencyResolutionManagement
line. Injected repositories are in separatedependencyResolutionManagement
block and look like this:mainTemplate.gradle
mainTemplate.gradle
andsettingsTemplate.gradle
are enabled and mainTemplate patching is enabled but settingsTemplate patching in Android Resolver settings is disabled, Android Resolver will not patchsettingsTemplate.gradle
this will lead to the build fail and the user will need to manage repositories manually.mainTemplate.gradle
is enabled and mainTemplate patching and settingsTemplate patching in Android Resolver settings are enabled butsettingsTemplate.gradle
is disabled:settingsTemplate.gradle
inPlaybackEngines/AndroidPlayer/Tools/GradleTemplates
containsdependencyResolutionManagement
block. Effectively this will match any Unity version equal to or above the 2022.2 version becausedependencyResolutionManagement
was introduced in the 2022.2 version. 2.1. If the previous check didn't match then Android Resolver will work as in the previous versions. 2.2. If the previous check is successful then Android Resolver will enablesettingsTemplate.gradle
automatically (by copying the default template). Decided to do it in such a way because Unity >=2022.2 and <2022.2.10 uses a settings template for repositories but don't have an option in "Project Settings" to enable a custom settings template. This option appeared only in 2022.2.10.