breautek commented on issue #1753:
URL: 
https://github.com/apache/cordova-android/issues/1753#issuecomment-2567028042

   > Could this path nevertheless automatically calculated for build variants?
   
   I don't think so. Android has a few reserved ones, `main`, `androidTest` 
(for connected android device/simulator testing), and `test` (unit tests that 
runs in a standard JVM, for code that doesn't depend on android SDKs). `main` 
is the default/fallback. All other build variants will get merged with `main`'s 
assets and configurations.
   
   So outside of those 3, the build variant name is entirely up to the 
developer. Cordova CLI only ever uses `main` and doesn't make use of build 
variants, not even the test variants, but it doesn't mean that complex projects 
adds their own build variants and projects using `resource-file` would assume 
current behaviour.
   
   Even if we conditionally prefix and assume `main` build variant there is 
going to be a lot of ambiguity as android assets are split into several 
folders, depending on the purpose, for example:
   
   - res/values/x.xml
   - res/xml/x.xml
   - res/layouts/x.xml
   - res/drawable/x.xml
   
   And each one of those directories can have variants as well, for 
localization, themes, device form factors, etc:
   
   - res/values-fr/x.xml (for french)
   - res/values-night/x.xml (for dark mode)
   
   And each of these variants can be compounded, for example: 
`res/values-fr-night/x.xml` for dark mode, french locale device configuration, 
or `res/values-fr-night-v24/x.xml` for french, dark mode, on API 24+ devices. 
Android about 20 different variant types, so I trust you can see how this can 
be problematic.
   
   I think if we WERE going to do any sort of prefixing, the path must begin 
with `/res/...` (or `res/...`) then we can assume `app/src/main/` should be 
prefixed. Otherwise we should attempt to use the path as is. The resource type 
(`xml`, `drawable`, `values`, etc) must be explicitly defined along with the 
resource file name.
   
   ```xml
   <resource-file src="Foo.xml" target="res/values/Foo.xml" /> <!-- goes to 
app/src/main/res/values/Foo.xml -->
   <resource-file src="Foo.xml" target="/res/values/Foo.xml" /> <!-- goes to 
app/src/main/res/values/Foo.xml -->
   <resource-file src="Foo.xml" target="app/src/main/res/xml/Foo.xml" /> <!-- 
goes to app/src/main/res/xml/Foo.xml -->
   <resource-file src="Foo.xml" target="/bar/res/values/Foo.xml" /> <!-- goes 
to bar/res/values/Foo.xml which is not really a valid location -->
   <resource-file src="Foo.xml" target="app/src/bar/res/values/Foo.xml" /> <!-- 
goes to app/src/bar/res/values/Foo.xml -->
   <resource-file src="Foo.xml" target="foobar/src/main/res/values/Foo.xml" /> 
<!-- goes to foobar/src/main/res/values/Foo.xml which is valid only if 
something has created the foobar android module -->
   ```
   
   The key point here is we should be careful not to prefix something seems be 
an absolute path to a particular android module and/or build variant.
   
   > Does cordova-android support build variants anyway?
   
   We don't have any explicit directives or anything to create build variants 
but it can be done via `<config-file>` or `<edit-config>` or hooks, etc.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to