-
Notifications
You must be signed in to change notification settings - Fork 19
package.json Reference
jDeploy uses the package.json file to store all of its configuration details for a project. When you run jdeploy init
it will create a default package.json file in the current working directory with default settings.
Note
|
For full documentation on the package.json file and its standard properties, see the npm package.json documentation. |
Most of the jDeploy-related settings are located inside the "jDeploy" object. E.g.
{
...
"jDeploy" : {
"jar" : "dist/my-app.jar"
...
}
}
However, there are a few properties at the "root" level that will affect how jDeploy deploys your application.
The following standard properties are important to jDeploy.
Property | Description | Required | Default |
---|---|---|---|
name |
The name used to install your app from NPM. This must be unique in the NPM registry. E.g. If your "name" is |
Yes |
|
bin |
An map containing the binaries for your application. This must contain at least one entry whose key is the name of your app as it will be called on the command-line, and value is "jdeploy-bundle/jdeploy.js" |
Yes |
|
dependencies |
Must include a dependency on the "shelljs" library. |
Yes |
For other root-level properties see npm package.json documentation
The following properties should be placed inside the "jDeploy" object of the package.json, and are almost always used.
Property | Description | Required | Default |
---|---|---|---|
javaVersion |
The Major java version to use for your app’s runtime. Accepted values: 8, 9, 10, 11, 12, 13 |
No |
11 |
jar |
Relative path to the executable jar file that contains your app. You should supply either "war" or "jar", but not both. This value may be the path to a file, or a glob pattern (e.g. using |
No |
|
war |
Relative path to a war file, or web-app directory that contains your web app. You should supply either "war" or "jar", but not both. This value may be the path to a file, or a glob pattern (e.g. using |
No |
The following properties may be placed in the "jDeploy" object of the package.json file.
Property | Description | Required | Default |
---|---|---|---|
files |
List of copy rules for copying files into the the deployed application bundle. By default, for executable jar deployments, it will copy the jar file and all files listed in the jar’s class path (from its manifest file); and for war deployments, it will just copy what is inside the war file. If you need additional files to be deployed (e.g. native libs or resources), then you should specify them in this list. See Copy Rules. |
No |
|
port |
For war deployments, this specifies the port that the Jetty wrapper should bind to. This can be overridden at runtime using the |
No |
0 |
antFile |
Set the ant build file to use for the |
No |
build.xml |
preCopyTarget |
You can optionally specify ANT to run a target before copying files to the |
No |
|
postCopyTarget |
Optional ANT target to be run after files have been copied to the |
No |
|
preCopyScript |
Optional script to be executed before copying files to the |
No |
|
postCopyScript |
Optional script to be executed after copying files to the |
No |
The "jDeploy/files" array includes zero or more copy rules. Each copy rule is an object that may contain the following properties:
Property | Description | Required | Default |
---|---|---|---|
dir |
The relative path to the directory from which files are to be copied. |
Yes |
|
includes |
Specifies files to be included in the copy. Either an array of glob patterns, or a comma-delimited string of glob patterns. The glob pattern uses PathMatcher globs. E.g. "*/.dll". |
No |
All files in dir |
excludes |
Specifies files to be excluded from the copy. Either an array of glob patterns, or a comma-delimited string of glob patterns. The glob pattern uses PathMatcher globs. |
No |
None |
Example Copy Rules*
{
...
"jDeploy" : {
"files" : [
{"dir" : "dist", "includes": "lib/*.dll,lib/*.so,lib/*.dylib"}
]
}
...
}
This would copy all of the dll, so, and dylib files from "dist/lib" into the jdeploy-bundle directory for deployment.
The "jDeploy/jar" and "jDeploy/war" properties specify the location of the jar or war file that constitutes the application. jdeploy init
will scan the current directory for eligible jar, war, and web app directories and set the shallowest candidate in the "jDeploy/jar" or "jDeploy/war" directive of the package.json. If you delete this value, or you omit it from the package.json, jdeploy install
and jdeploy publish
will perform the same search for an appropriate candidate.
{
"bin": {"hellojdeploy": "jdeploy-bundle/jdeploy.js"}, // (1)
"preferGlobal": true, (2)
"version": "1.0.1",
"jdeploy": {"jar": "dist/HelloJDeploy.jar"}, (3)
"dependencies": {"shelljs": "^0.8.4"},
"license": "ISC",
"name": "hello-jdeploy", (4)
"files": ["jdeploy-bundle"] (5)
}
-
Once installed, the binary name of our app will be "hellojdeploy". I.e. we would start the app by typing "hellojdeploy" at the command prompt.
-
Indicates that NPM should prefer to install the app globally. If people forget to include the "-g" flag when they try to install the app, they will get a warning.
-
The executable Jar file that we are deploying is located at "dist/HelloJDeploy.jar".
-
The command to install the app would be
npm install -g jdeploy-bundle
The above package.json deploys an app such that it would be installed with
npm install -g hello-jdeploy
And it would be installed as "hellojdeploy", so that it could be run on the command line:
hellojdeploy