You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2018/11/23 18:10:12 UTC

[GitHub] Jule- commented on issue #578: Plugin target-dir error handling for source-file element

Jule- commented on issue #578: Plugin target-dir error handling for source-file element
URL: https://github.com/apache/cordova-android/issues/578#issuecomment-441297644
 
 
   As mentioned in #576 I made a draft for this function with some unknown variables from my point of vue.
   For clarity and readability of this issue I copy it here:
   ```js
   function getInstallDestination(obj) {
     var APP_MAIN_PREFIX = 'app/src/main';
   
     if (obj.targetDir.startsWith('app/src/main/')) {
       // plugin targets explicitly source file root => use targetDir as it is.
       return path.join(obj.targetDir, path.basename(obj.src));
     } else {
       // plugin ignores underlying android app structure
       // @deprecated: BACKWARD COMPATIBILITY
   
       // I don't have enough history on this part so I don't know if there is specific
       // folder to put files into in order to compile correctly but I guess:
       if (obj.src.endsWith('.java')) {
         return path.join(APP_MAIN_PREFIX, 'java', obj.targetDir.replace(/^src\//, ''),
           path.basename(obj.src));
       } else if (obj.src.endsWith('.aidl')) {
         return path.join(APP_MAIN_PREFIX, 'aidl', obj.targetDir.replace(/^src\//, ''),
           path.basename(obj.src));
       } else if (obj.targetDir.startsWith('libs/')) {
         if (obj.src.endsWith('.so')) {
           // Here we should have kept the old form with .substring(5) since it is safe 
           // after .startsWith('libs/').
           // But I don't think we need optimization here more than readability.
           return path.join(APP_MAIN_PREFIX, 'jniLibs', obj.targetDir.replace(/^libs\//, ''),
             path.basename(obj.src));
         } else {
           // Don't know what sort of lib this should be handling
           return path.join('app', obj.targetDir, path.basename(obj.src));
         }
       } else if (obj.targetDir.startsWith('src/main/')) {
         // Seems to be an awkward form handling
         return path.join('app', obj.targetDir, path.basename(obj.src));
       }
   
       // For all other source files not using the new app directory structure,
       // add 'app/src/main' to the targetDir
       return path.join(APP_MAIN_PREFIX, obj.targetDir, path.basename(obj.src));
     }
   }
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org