You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cordova.apache.org by mbektchiev <gi...@git.apache.org> on 2014/05/28 16:13:03 UTC

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

GitHub user mbektchiev opened a pull request:

    https://github.com/apache/cordova-lib/pull/21

    CB-6698: Support library references for Android via the framework tag

    The framework tag can be contain the following attributes:
    	
    * **src** - (**required**) relative path to the directory containing the referenced library project.
    * **custom** - (optional) specifies how to treat **src**. If **true** it is a relative path from the application project's directory, otherwise -- the Android SDK directory.
    * **parent** - (optional) relative path to the directory containing the project to which to add the reference. The default is the application project.
    
    Example: A plugin that installs a library (**FeedbackLib**) which refers another library from the Android SDK (**appcompat**)
    
    ```xml
    <source-file src="src/android/FeedbackLib" target-dir="./" />
    
    <framework src="FeedbackLib" custom="true" />
    <framework src="extras/android/support/v7/appcompat" parent="FeedbackLib" />
    ```
    
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/Icenium/cordova-lib bektchiev/framework-tag-for-android

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/cordova-lib/pull/21.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #21
    
----
commit 0227d7bb7831ad1dfe0c6531e319bf8106256a03
Author: Martin Bektchiev <ma...@telerik.com>
Date:   2014-05-27T11:53:19Z

    CB-6698: Support library references for Android via the framework tag

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Re: [GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by Jesse <pu...@gmail.com>.
Thanks Mark,

I have updated the doc with details for windows8.  I will be testing to
make sure there is no regression.

@purplecabbage
risingj.com


On Wed, May 28, 2014 at 10:59 AM, Mark Koudritsky <ka...@google.com> wrote:

> The plugin.xml spec is here
> http://docs.phonegap.com/en/3.4.0/plugin_ref_spec.md.html
>
>
>
> On Wed, May 28, 2014 at 1:56 PM, Jesse <pu...@gmail.com> wrote:
>
> > Where is the document that outlines all of the tags supported in
> > plugin.xml, the expected meaning of those tags, and what attributes they
> > support.
> >
> > Other than that, I can only assume this doesn't break <framework
> > custom="true"> on iOS + Windows 8.
> >
> >
> >
> > @purplecabbage
> > risingj.com
> >
> >
> > On Wed, May 28, 2014 at 8:34 AM, kamrik <gi...@git.apache.org> wrote:
> >
> > > Github user kamrik commented on a diff in the pull request:
> > >
> > >     https://github.com/apache/cordova-lib/pull/21#discussion_r13137628
> > >
> > >     --- Diff: cordova-lib/src/plugman/platforms/android.js ---
> > >     @@ -80,10 +84,115 @@ module.exports = {
> > >          },
> > >          "framework": {
> > >              install:function(source_el, plugin_dir, project_dir,
> > > plugin_id) {
> > >     -            events.emit('verbose', 'framework.install is not
> > > supported for android');
> > >     +            var src = source_el.attrib.src;
> > >     +            var custom = source_el.attrib.custom;
> > >     +            if (!src) throw new Error('src not specified in
> > framework
> > > element');
> > >     +
> > >     +            events.emit('verbose', "Installing Android library: "
> +
> > > src);
> > >     +            var parent = source_el.attrib.parent;
> > >     +            var parentDir = parent ? path.resolve(project_dir,
> > > parent) : project_dir;
> > >     +            var subDir;
> > >     +            if (custom) {
> > >     +                subDir = path.resolve(project_dir, src);
> > >     +            } else {
> > >     +                var localProperties =
> > > properties_parser.createEditor(path.resolve(project_dir,
> > > "local.properties"));
> > >     +                subDir =
> > path.resolve(localProperties.get("sdk.dir"),
> > > src);
> > >     +            }
> > >     +            var projectConfig =
> > > module.exports.parseProjectFile(project_dir);
> > >     +            projectConfig.addSubProject(parentDir, subDir);
> > >              },
> > >              uninstall:function(source_el, project_dir, plugin_id) {
> > >     -            events.emit('verbose', 'framework.uninstall is not
> > > supported for android');
> > >     +            var src = source_el.attrib.src;
> > >     +            if (!src) throw new Error('src not specified in
> > framework
> > > element');
> > >     +
> > >     +            events.emit('verbose', "Uninstalling Android library:
> "
> > +
> > > src);
> > >     +            var parent = source_el.attrib.parent;
> > >     +            var parentDir = parent ? path.resolve(project_dir,
> > > parent) : project_dir;
> > >     +            var subDir = path.resolve(project_dir, src);
> > >     +            var projectConfig =
> > > module.exports.parseProjectFile(project_dir);
> > >     +            projectConfig.removeSubProject(parentDir, subDir);
> > >              }
> > >     +    },
> > >     +    parseProjectFile: function(project_dir){
> > >     +        if (!projectFileCache[project_dir]) {
> > >     +            projectFileCache[project_dir] = {
> > >     --- End diff --
> > >
> > >     This is an inline definition of a pretty rich object with non
> trivial
> > > methods. I think it will be way more readable to define a separate
> class
> > > like AndroidProjectFile (naming is up to you) and have this line look
> > like
> > > this:
> > >     projectFileCache[project_dir] = new AndroidProjectFile(...);
> > >
> > >     I would even define the AndroidProjectFile class in a separate js
> > > file, this way other platforms similar to Android might reuse or
> subclass
> > > it if they want.
> > >     The windows8 parser does something similar with the
> util/w8jsproj.js
> > >
> > >     Otherwise LGTM.
> > >
> > >
> > > ---
> > > If your project is set up for it, you can reply to this email and have
> > your
> > > reply appear on GitHub as well. If your project does not have this
> > feature
> > > enabled and wishes so, or if the feature is enabled but not working,
> > please
> > > contact infrastructure at infrastructure@apache.org or file a JIRA
> > ticket
> > > with INFRA.
> > > ---
> > >
> >
>

Re: [GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by Mark Koudritsky <ka...@google.com>.
The plugin.xml spec is here
http://docs.phonegap.com/en/3.4.0/plugin_ref_spec.md.html



On Wed, May 28, 2014 at 1:56 PM, Jesse <pu...@gmail.com> wrote:

> Where is the document that outlines all of the tags supported in
> plugin.xml, the expected meaning of those tags, and what attributes they
> support.
>
> Other than that, I can only assume this doesn't break <framework
> custom="true"> on iOS + Windows 8.
>
>
>
> @purplecabbage
> risingj.com
>
>
> On Wed, May 28, 2014 at 8:34 AM, kamrik <gi...@git.apache.org> wrote:
>
> > Github user kamrik commented on a diff in the pull request:
> >
> >     https://github.com/apache/cordova-lib/pull/21#discussion_r13137628
> >
> >     --- Diff: cordova-lib/src/plugman/platforms/android.js ---
> >     @@ -80,10 +84,115 @@ module.exports = {
> >          },
> >          "framework": {
> >              install:function(source_el, plugin_dir, project_dir,
> > plugin_id) {
> >     -            events.emit('verbose', 'framework.install is not
> > supported for android');
> >     +            var src = source_el.attrib.src;
> >     +            var custom = source_el.attrib.custom;
> >     +            if (!src) throw new Error('src not specified in
> framework
> > element');
> >     +
> >     +            events.emit('verbose', "Installing Android library: " +
> > src);
> >     +            var parent = source_el.attrib.parent;
> >     +            var parentDir = parent ? path.resolve(project_dir,
> > parent) : project_dir;
> >     +            var subDir;
> >     +            if (custom) {
> >     +                subDir = path.resolve(project_dir, src);
> >     +            } else {
> >     +                var localProperties =
> > properties_parser.createEditor(path.resolve(project_dir,
> > "local.properties"));
> >     +                subDir =
> path.resolve(localProperties.get("sdk.dir"),
> > src);
> >     +            }
> >     +            var projectConfig =
> > module.exports.parseProjectFile(project_dir);
> >     +            projectConfig.addSubProject(parentDir, subDir);
> >              },
> >              uninstall:function(source_el, project_dir, plugin_id) {
> >     -            events.emit('verbose', 'framework.uninstall is not
> > supported for android');
> >     +            var src = source_el.attrib.src;
> >     +            if (!src) throw new Error('src not specified in
> framework
> > element');
> >     +
> >     +            events.emit('verbose', "Uninstalling Android library: "
> +
> > src);
> >     +            var parent = source_el.attrib.parent;
> >     +            var parentDir = parent ? path.resolve(project_dir,
> > parent) : project_dir;
> >     +            var subDir = path.resolve(project_dir, src);
> >     +            var projectConfig =
> > module.exports.parseProjectFile(project_dir);
> >     +            projectConfig.removeSubProject(parentDir, subDir);
> >              }
> >     +    },
> >     +    parseProjectFile: function(project_dir){
> >     +        if (!projectFileCache[project_dir]) {
> >     +            projectFileCache[project_dir] = {
> >     --- End diff --
> >
> >     This is an inline definition of a pretty rich object with non trivial
> > methods. I think it will be way more readable to define a separate class
> > like AndroidProjectFile (naming is up to you) and have this line look
> like
> > this:
> >     projectFileCache[project_dir] = new AndroidProjectFile(...);
> >
> >     I would even define the AndroidProjectFile class in a separate js
> > file, this way other platforms similar to Android might reuse or subclass
> > it if they want.
> >     The windows8 parser does something similar with the util/w8jsproj.js
> >
> >     Otherwise LGTM.
> >
> >
> > ---
> > If your project is set up for it, you can reply to this email and have
> your
> > reply appear on GitHub as well. If your project does not have this
> feature
> > enabled and wishes so, or if the feature is enabled but not working,
> please
> > contact infrastructure at infrastructure@apache.org or file a JIRA
> ticket
> > with INFRA.
> > ---
> >
>

Re: [GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by Jesse <pu...@gmail.com>.
Where is the document that outlines all of the tags supported in
plugin.xml, the expected meaning of those tags, and what attributes they
support.

Other than that, I can only assume this doesn't break <framework
custom="true"> on iOS + Windows 8.



@purplecabbage
risingj.com


On Wed, May 28, 2014 at 8:34 AM, kamrik <gi...@git.apache.org> wrote:

> Github user kamrik commented on a diff in the pull request:
>
>     https://github.com/apache/cordova-lib/pull/21#discussion_r13137628
>
>     --- Diff: cordova-lib/src/plugman/platforms/android.js ---
>     @@ -80,10 +84,115 @@ module.exports = {
>          },
>          "framework": {
>              install:function(source_el, plugin_dir, project_dir,
> plugin_id) {
>     -            events.emit('verbose', 'framework.install is not
> supported for android');
>     +            var src = source_el.attrib.src;
>     +            var custom = source_el.attrib.custom;
>     +            if (!src) throw new Error('src not specified in framework
> element');
>     +
>     +            events.emit('verbose', "Installing Android library: " +
> src);
>     +            var parent = source_el.attrib.parent;
>     +            var parentDir = parent ? path.resolve(project_dir,
> parent) : project_dir;
>     +            var subDir;
>     +            if (custom) {
>     +                subDir = path.resolve(project_dir, src);
>     +            } else {
>     +                var localProperties =
> properties_parser.createEditor(path.resolve(project_dir,
> "local.properties"));
>     +                subDir = path.resolve(localProperties.get("sdk.dir"),
> src);
>     +            }
>     +            var projectConfig =
> module.exports.parseProjectFile(project_dir);
>     +            projectConfig.addSubProject(parentDir, subDir);
>              },
>              uninstall:function(source_el, project_dir, plugin_id) {
>     -            events.emit('verbose', 'framework.uninstall is not
> supported for android');
>     +            var src = source_el.attrib.src;
>     +            if (!src) throw new Error('src not specified in framework
> element');
>     +
>     +            events.emit('verbose', "Uninstalling Android library: " +
> src);
>     +            var parent = source_el.attrib.parent;
>     +            var parentDir = parent ? path.resolve(project_dir,
> parent) : project_dir;
>     +            var subDir = path.resolve(project_dir, src);
>     +            var projectConfig =
> module.exports.parseProjectFile(project_dir);
>     +            projectConfig.removeSubProject(parentDir, subDir);
>              }
>     +    },
>     +    parseProjectFile: function(project_dir){
>     +        if (!projectFileCache[project_dir]) {
>     +            projectFileCache[project_dir] = {
>     --- End diff --
>
>     This is an inline definition of a pretty rich object with non trivial
> methods. I think it will be way more readable to define a separate class
> like AndroidProjectFile (naming is up to you) and have this line look like
> this:
>     projectFileCache[project_dir] = new AndroidProjectFile(...);
>
>     I would even define the AndroidProjectFile class in a separate js
> file, this way other platforms similar to Android might reuse or subclass
> it if they want.
>     The windows8 parser does something similar with the util/w8jsproj.js
>
>     Otherwise LGTM.
>
>
> ---
> If your project is set up for it, you can reply to this email and have your
> reply appear on GitHub as well. If your project does not have this feature
> enabled and wishes so, or if the feature is enabled but not working, please
> contact infrastructure at infrastructure@apache.org or file a JIRA ticket
> with INFRA.
> ---
>

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by kamrik <gi...@git.apache.org>.
Github user kamrik commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/21#discussion_r13137628
  
    --- Diff: cordova-lib/src/plugman/platforms/android.js ---
    @@ -80,10 +84,115 @@ module.exports = {
         },
         "framework": {
             install:function(source_el, plugin_dir, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.install is not supported for android');
    +            var src = source_el.attrib.src;
    +            var custom = source_el.attrib.custom;
    +            if (!src) throw new Error('src not specified in framework element');
    +
    +            events.emit('verbose', "Installing Android library: " + src);
    +            var parent = source_el.attrib.parent;
    +            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
    +            var subDir;
    +            if (custom) {
    +                subDir = path.resolve(project_dir, src);
    +            } else {
    +                var localProperties = properties_parser.createEditor(path.resolve(project_dir, "local.properties"));
    +                subDir = path.resolve(localProperties.get("sdk.dir"), src);
    +            }
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.addSubProject(parentDir, subDir);
             },
             uninstall:function(source_el, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.uninstall is not supported for android');
    +            var src = source_el.attrib.src;
    +            if (!src) throw new Error('src not specified in framework element');
    +
    +            events.emit('verbose', "Uninstalling Android library: " + src);
    +            var parent = source_el.attrib.parent;
    +            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
    +            var subDir = path.resolve(project_dir, src);
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.removeSubProject(parentDir, subDir);
             }
    +    },
    +    parseProjectFile: function(project_dir){
    +        if (!projectFileCache[project_dir]) {
    +            projectFileCache[project_dir] = {
    --- End diff --
    
    This is an inline definition of a pretty rich object with non trivial methods. I think it will be way more readable to define a separate class like AndroidProjectFile (naming is up to you) and have this line look like this:
    projectFileCache[project_dir] = new AndroidProjectFile(...);
    
    I would even define the AndroidProjectFile class in a separate js file, this way other platforms similar to Android might reuse or subclass it if they want.
    The windows8 parser does something similar with the util/w8jsproj.js
    
    Otherwise LGTM.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by mbektchiev <gi...@git.apache.org>.
Github user mbektchiev closed the pull request at:

    https://github.com/apache/cordova-lib/pull/21


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:

    https://github.com/apache/cordova-lib/pull/21#issuecomment-45009544
  
    Please also make the appropriate changes to the docs[1] and send a pull request there also.
    
    [1] https://github.com/apache/cordova-docs/blob/master/docs/en/edge/plugin_ref/spec.md



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by mbektchiev <gi...@git.apache.org>.
Github user mbektchiev commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/21#discussion_r13329193
  
    --- Diff: cordova-lib/src/plugman/platforms/android.js ---
    @@ -80,10 +84,115 @@ module.exports = {
         },
         "framework": {
             install:function(source_el, plugin_dir, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.install is not supported for android');
    +            var src = source_el.attrib.src;
    +            var custom = source_el.attrib.custom;
    +            if (!src) throw new Error('src not specified in framework element');
    +
    +            events.emit('verbose', "Installing Android library: " + src);
    +            var parent = source_el.attrib.parent;
    +            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
    +            var subDir;
    +            if (custom) {
    +                subDir = path.resolve(project_dir, src);
    +            } else {
    +                var localProperties = properties_parser.createEditor(path.resolve(project_dir, "local.properties"));
    +                subDir = path.resolve(localProperties.get("sdk.dir"), src);
    +            }
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.addSubProject(parentDir, subDir);
             },
             uninstall:function(source_el, project_dir, plugin_id) {
    -            events.emit('verbose', 'framework.uninstall is not supported for android');
    +            var src = source_el.attrib.src;
    +            if (!src) throw new Error('src not specified in framework element');
    +
    +            events.emit('verbose', "Uninstalling Android library: " + src);
    +            var parent = source_el.attrib.parent;
    +            var parentDir = parent ? path.resolve(project_dir, parent) : project_dir;
    +            var subDir = path.resolve(project_dir, src);
    +            var projectConfig = module.exports.parseProjectFile(project_dir);
    +            projectConfig.removeSubProject(parentDir, subDir);
             }
    +    },
    +    parseProjectFile: function(project_dir){
    +        if (!projectFileCache[project_dir]) {
    +            projectFileCache[project_dir] = {
    --- End diff --
    
    I totally agree! I extracted it in a separate js.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by kamrik <gi...@git.apache.org>.
Github user kamrik commented on the pull request:

    https://github.com/apache/cordova-lib/pull/21#issuecomment-44973356
  
    Looks good, will merge later today.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by mbektchiev <gi...@git.apache.org>.
Github user mbektchiev commented on the pull request:

    https://github.com/apache/cordova-lib/pull/21#issuecomment-45105399
  
    Thank you for merging and tipping me for the docs! I created a pull request for the docs: https://github.com/apache/cordova-docs/pull/210 and I am closing this one. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by kamrik <gi...@git.apache.org>.
Github user kamrik commented on the pull request:

    https://github.com/apache/cordova-lib/pull/21#issuecomment-45005347
  
    Merged, but to forgot to add the magic words for the apache robots to auto-close this pull request. @mbektchiev , could you please close it.
    Thanks.
    
    The change on apache gitweb
    https://git-wip-us.apache.org/repos/asf?p=cordova-lib.git;h=85974b0f9bac6769e3f0fe4e4a61a84f554b6e5d


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] cordova-lib pull request: CB-6698: Support library references for ...

Posted by purplecabbage <gi...@git.apache.org>.
Github user purplecabbage commented on the pull request:

    https://github.com/apache/cordova-lib/pull/21#issuecomment-45106692
  
    Thanks Martin!
    
    
    > On Jun 4, 2014, at 8:27 AM, Martin Bektchiev <no...@github.com> wrote:
    > 
    > Closed #21.
    > 
    > —
    > Reply to this email directly or view it on GitHub.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---