Skip to content

Commit b92300d

Browse files
committed
Merge pull request NativeScript#222 from NativeScript/plamen5kov/link_plugin_specifics
removed android speciffic docs, still need to add link to android spe…
2 parents 3e0b280 + 80f7b69 commit b92300d

File tree

1 file changed

+4
-40
lines changed

1 file changed

+4
-40
lines changed

plugins/plugins.md

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Starting with NativeScript CLI 1.1.0, you can develop or use plugins in your Nat
1515
* [Create a Plugin](#create-a-plugin)
1616
* [Directory Structure](#directory-structure)
1717
* [Package.json Specification](#packagejson-specification)
18-
* [Include.gradle Specification](#includegradle-specification)
1918
* [Install a Plugin](#install-a-plugin)
2019
* [Valid Plugin Sources](#valid-plugin-sources)
2120
* [Installation Specifics](#installation-specifics)
@@ -32,7 +31,7 @@ A NativeScript plugin is any npm package, published or not, that exposes a nativ
3231
* A `package.json` file which contains the following metadata: name, version, supported runtime versions, dependencies and others. For more information, see the [Package.json Specification](#packagejson-specification) section.
3332
* One or more CommonJS modules that expose a native API via a unified JavaScript API. For more information about Common JS modules, see the [CommonJS Wiki](http://wiki.commonjs.org/wiki/CommonJS).
3433
* `AndroidManifest.xml` and `Info.plist` which describe the permissions, features or other configurations required or used by your app for Android and iOS, respectively.
35-
* (Optional) Native Android libraries and the native Android `include.gradle` configuration file which describes the native dependencies. For more information, see the [Include.gradle Specification](#includegradle-specification) section
34+
* (Optional) Native Android libraries and the native Android `include.gradle` configuration file which describes the native dependencies. See android specific structure [here]({% slug android-plugins-infrastructure% }).
3635
* (Optional) Native iOS dynamic libraries.
3736

3837
The plugin must have the directory structure, described in the [Directory Structure](#directory-structure) section.
@@ -47,7 +46,7 @@ If the NativeScript framework does not expose a native API that you need, you ca
4746
* The plugin directory structure must comply with the specification described below.
4847
* The plugin must contain a valid `package.json` which complies with the specification described below.
4948
* If the plugin requires any permissions, features or other configuration specifics, it must contain `AndroidManifest.xml` and `Info.plist` file which describe them.
50-
* (Android-only) If the plugin depends on native libraries, it must contain a valid `include.gradle file`, which describes the dependencies.
49+
* (Android-only) If the plugin depends on native libraries, it must contain a valid `include.gradle file`, which describes the dependencies. See android specific structure [here]({% slug android-plugins-infrastructure% }).
5150

5251
### Directory Structure
5352

@@ -59,7 +58,6 @@ my-plugin/
5958
├── package.json
6059
└── platforms/
6160
├── android/
62-
│ └── res/
6361
│ └── AndroidManifest.xml
6462
└── ios/
6563
└── Info.plist
@@ -78,7 +76,6 @@ my-plugin/
7876
│ └── package.json
7977
└── platforms/
8078
├── android/
81-
│ └── res/
8279
│ └── AndroidManifest.xml
8380
└── ios/
8481
└── Info.plist
@@ -88,21 +85,16 @@ my-plugin/
8885
* `index.js`: This file is the CommonJS module which exposes the native API. You can use platform-specific `*.platform.js` files. For example: `index.ios.js` and `index.android.js`. During the plugin installation, the NativeScript CLI will copy the platform resources to the `tns_modules` subdirectory in the correct platform destination in the `platforms` directory of your project.<br/>Alternatively, you can give any name to this CommonJS module. In this case, however, you need to point to this file by setting the `main` key in the `package.json` for the plugin. For more information, see [Folders as Modules](https://nodejs.org/api/modules.html#modules_folders_as_modules).
8986
* `package.json`: This file contains the metadata for your plugin. It sets the supported runtimes, the plugin name and version and any dependencies. The `package.json` specification is described in detail below.
9087
* `platforms\android\AndroidManifest.xml`: This file describes any specific configuration changes required for your plugin to work. For example: required permissions. For more information about the format of `AndroidManifest.xml`, see [App Manifest](http://developer.android.com/guide/topics/manifest/manifest-intro.html).<br/>During build, gradle will merge the plugin `AndroidManifest.xml` with the `AndroidManifest.xml` for your project. The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues.
91-
* `platforms\android\include.gradle`: This file modifies the native Android configuration of your NativeScript project such as native dependencies, build types and configurations. For more information about the format of `include.gradle`, see [include.gradle file](#includegradle-specification).
92-
* `platforms/android/res`: (Optional) This directory contains resources declared by the `AndroidManifest.xml` file. You can look at the folder structure [here](http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes).
9388
* `platforms/ios/Info.plist`: This file describes any specific configuration changes required for your plugin to work. For example: required permissions. For more information about the format of `Info.plist`, see [About Information Property List Files](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/AboutInformationPropertyListFiles.html).<br/>During the plugin installation, the NativeScript CLI will merge the plugin `Info.plist` with the `Info.plist` for your project. The NativeScript CLI will not resolve any contradicting or duplicate entries during the merge. After the plugin is installed, you need to manually resolve such issues.
9489
* `platforms/ios/Podfile`: This file describes the dependency to the library that you want to use. For more information, see [the CocoaPods article](CocoaPods.md).
9590

96-
NativeScript plugins which contain both native Android and iOS libraries might have the following directory structure.
91+
NativeScript plugins can contain both native Android and iOS libraries. See android specific structure [here]({% slug android-plugins-infrastructure% }).
9792

9893
```
9994
my-plugin/
10095
├── ...
10196
└── platforms/
10297
├── android/
103-
│ └── res/
104-
│ └── MyLibrary.jar
105-
│ └── MyLibrary.aar
10698
│ └── include.gradle
10799
│ └── AndroidManifest.xml
108100
└── ios/
@@ -111,9 +103,8 @@ my-plugin/
111103
```
112104

113105
* `platforms\android`: This directory contains any native Android libraries packaged as `*.jar` and `*.aar` packages. These native libraries can reside in the root of this directory or in a user-created sub-directory. During the plugin installation, the NativeScript CLI will configure the Android project in `platforms\android` to work with the plugin.
114-
* `platforms\android\res`: (Optional) This directory contains resources declared by the `AndroidManifest.xml` file. You can look at the folder structure [here](http://developer.android.com/guide/topics/resources/providing-resources.html#ResourceTypes).
115-
* `platforms\ios`: This directory contains native iOS dynamic libraries (`.framework`). During the plugin installation, the NativeScript CLI will copy these files to `lib\iOS` in your project and will configure the Android project in `platforms\ios` to work with the library.
116106
* `platforms\android\include.gradle`: This file modifies the native Android configuration of your NativeScript project such as native dependencies, build types and configurations. For more information about the format of `include.gradle`, see [include.gradle file](#includegradle-specification).
107+
* `platforms\ios`: This directory contains native iOS dynamic libraries (`.framework`). During the plugin installation, the NativeScript CLI will copy these files to `lib\iOS` in your project and will configure the Android project in `platforms\ios` to work with the library.
117108

118109
### Package.json Specification
119110

@@ -140,33 +131,6 @@ The following is an example of a `package.json` file for a NativeScript plugin w
140131
}
141132
```
142133

143-
### Include.gradle Specification
144-
145-
Every NativeScript plugin, which contains native Android dependencies, should also contain a valid `include.gradle` file in the root of its `platforms\android` directory. This `include.gradle` file must meet the following requirements.
146-
147-
* It must contain its own [configuration](http://developer.android.com/tools/building/configuring-gradle.html).
148-
* It might contain native dependencies required to build the plugin properly.
149-
* Any native dependencies should be available in [jcenter](https://bintray.com/bintray/jcenter) or from the Android SDK installed on your machine.
150-
151-
> **IMPORTANT:** If you don't have an `include.gradle` file, at build time, gradle will create a default one containing all default elements.
152-
153-
#### Include.gradle Example
154-
```
155-
//default elements
156-
android {
157-
productFlavors {
158-
"my-plugin" {
159-
dimension "my-plugin"
160-
}
161-
}
162-
}
163-
164-
//optional elements
165-
dependencies {
166-
compile "groupName:pluginName:ver"
167-
}
168-
```
169-
170134
## Install a Plugin
171135

172136
To install a plugin for your project, inside your project, run the following command.

0 commit comments

Comments
 (0)