Project Config
Project Config
In CloudControl Pro, we sometimes need to run not only single files, but also projects. A project is a folder that contains configuration, code files, resource files (images, etc.).
You can create a new project in CloudControl Pro from the home page, and there are various project modules available (Pro 8.7 and above).
project.json
The project.json
file is used to configure project related parameters, such as master file, startup image, package name and other information.
Parameter name | Meaning | Type | Default value |
---|---|---|---|
androidResources | Android resources, see androidResources | Object | { "resDir": "res", "manifest ": "AndroidManifest.xml" } |
build | Auto-generated build information, no need to modify, see build | Object | |
assets | Reserved field, no effect for now | Array<String> | [] |
encryptLevel | encryptionLevel 0-no encryption, 1-local encryption, 2-online encryption (only supported in 8.7+) | number | 0 |
icon | desktop icon | string | "icons/icon.png" |
ignore | Ignore files when syncing projects from VSCode | Array | ["build"] |
launchConfig | Launch configuration, see launchConfig | Object | |
main | The entry file | string | "main.js" |
name | app name | string | "" |
optimization | Optimization configuration, see optimization | Object | |
packageName | Package name, must conform to Android package name specification, and the package name must be unique when uploading to the store | string | "" |
permissionConfig | Permission Config, see permissionConfig | Object | { "manifestPermissions": [], "requestListOnStartup": [] } |
publish | The publish/upload store configuration, see publish | Object | |
scripts | The configuration of scripts that are automatically triggered to run when building, etc., see scripts | Object | |
versionCode | version number | number | 1 |
versionName | name of the version to show to the user | string | "1.0.0" |
Example of full configuration.
{
"androidResources": {
"resDir": "res",
"manifest": "AndroidManifest.xml"
},
"assets": [],
"build": {
"build_id": "6F47F367-1",
"build_number": 1,
"build_time": 1615553004812,
"release": true
},
"encryptLevel": 0,
"useFeatures": [],
"icon": "res/icon.png",
"ignore": ["build"],
"launchConfig": {
"displaySplash": true,
"hideLogs": false,
"splashIcon": "res/splashIcon.png",
"splashLayoutXml": "splash.xml",
"splashText": "Powered by CloudControl Pro",
"stableMode": false
},
"main": "main.js",
"name": "Shape3.0",
"optimization": {
"removeOpenCv": true,
"unusedResources": true
},
"packageName": "com.suzy.rippledrawable",
"permissionConfig": {
"manifestPermissions": ["android.permission.WRITE_EXTERNAL_STORAGE"],
"requestListOnStartup": ["android.permission.WRITE_EXTERNAL_STORAGE"]
},
"publish": {
"category": "Other",
"details": "control stroke, gradient, ripple, text gradient",
"maxAutoJsVersion": -1,
"minAutoJsVersion": -1,
"maxProVersion": 8059999,
"minProVersion": 8050000,
"minSdkVersion": 2,
"permissions": [],
"summary": "control stroke, gradient, water ripple, text gradient",
"tags": []
},
"scripts": {},
"versionCode": 1,
"versionName": "1.0.0"
}
Minimum configuration example.
{
"name": "New Project",
"main": "main.js",
"ignore": [
"build"
],
"packageName": "com.example",
"versionName": "1.0.0",
"versionCode": 1
}
androidResources
Parameters used to configure Android native interface, see Example->Complex Interface->Android Native Interface.
parameter name | meaning | type | default |
---|---|---|---|
resDir | Android resource folder | string | "res" |
manifest | The path to the AndroidManifest.xml file | string | "AndroidManifest.xml" |
build
The automatically generated build information, including build time, build number, etc., please do not modify.
The package software will determine whether to unpack the files of the installation package to the data path according to the information here. (The confidence here will be updated after each package, so the project files in the local data can be updated automatically after installation)
Parameter Name | Meaning | Type | Default |
---|---|---|---|
build_id | Auto-generated build id | string | "" |
build_number | Build number, incremented by 1 per build | number | 1 |
build_time | last build time | number | current 13-bit timestamp |
release | Whether or not the project is a packaged project, this is an auto-generated field that does not need to be modified | boolean | false |
launchConfig
The launch configuration of the packaged project.
parameter name | meaning | type | default |
---|---|---|---|
displaySplash | Whether or not to display the launch graph after packaging (even if set to false, the launch graph will still be displayed the first time after packaging) | boolean | true |
hideLogs | Hide the logs after packaging | boolean | false |
splashIcon | The splash interface icon after packaging | string | "icons/splashIcon.png" |
splashLayoutXml | SplashLayoutXml | The startup image xml, used to customize the startup image after packaging, see Example->Projects and Packaging->Customizing the startup image (version 8.5 or above) | string |
splashText | Packed startup interface text | string | "Powered by CloudControl Pro" |
stableMode | Whether to run in stable mode after packaging | boolean | false |
permissionConfig
Added in Pro 8.8.1
Custom permission configuration, including the permissions list of the built apk, and the permission list to request when starting up.
You can also use the CloudControl Pro permission settings UI to modify permission config.
parameter | meaning | type | default |
---|---|---|---|
manifestPermissions | The declared permission list. For compatibility with the old version, if the field is null, the default is 122 built-in permissions. | Array<string> | null |
requestListOnStartup | the permission list to request when starting up,permission must be included in manifestPermissions, otherwise it cannot be requested | Array<string> | ["android.permission.WRITE_EXTERNAL_STORAGE"] |
For all permission list, see Manifest.permission
publish
The configuration for uploading the store publish project.
parameter name | meaning | type | default |
---|---|---|---|
maxAutoJsVersion | The maximum autojs version number supported | number | 0 |
maxProVersion | maximum supported autojspro version | number | 0 |
minAutoJsVersion | minimum autojs version supported | number | 0 |
minProVersion | maximum supported autojspro version | number | 0 |
minSdkVersion | Minimum supported Android versions | number | 0 |
category | The category of the project to be used as a category when publishing to the store | string | "Other" |
details | Project details, used as project details when publishing to the store | string | "" |
permissions | A list of permissions, such as "root", which is not available at the moment | Array<Stirng> | [] |
summary | Script feature summary | string | "" |
tags | Script tags, no effect for now since the store doesn't have tag filtering yet | Array<String> | [] |
optimization
Optimize the configuration. Currently used to reduce size when packaging.
parameter name | meaning | type | default |
---|---|---|---|
removeOpenCv | do not need the images module with opencv | boolean | false |
unusedResources | don't need built-in icons | boolean | false |
ignore configuration
Added in Pro 8.7.6
The ignore configuration file is similar to .gitignore
, which is used to configure CloudControl Pro to process the ignored files such as packaging and encryption.
The rules of ignore file are the same as .gitignore
, for example:
# / Indicates the directory where the current file is located
# Ignore all directories and files under public
/public/
#Don’t ignore/public/assets, which means a special case, assets files are not ignored
!/public/assets
# Ignore specific files
index.js
# Ignore all js files
*.js
# Ignore a.js b.js
[ab].js
# Matching rules are the same as linux file matching
# Start with a slash "/" to indicate a directory
# Use an asterisk "*" to wildcard multiple characters
# Use a question mark "?" to wildcard a single character
# Use square brackets "[]" to contain a single character match list
# Use an exclamation mark "!" to indicate not to ignore (track) the matched files or directories
.autojs.source.ignore
File path: .autojs.source.ignore
file in the project folder.
The files matched by the rules of the file configuration will not be regarded as CloudControl Pro JavaScript source files and will not participate in the encryption process.
For example, some js files are used for loading on the Web, and you do not want to encrypt them when packaging, you can configure this file to ignore.
.autojs.build.ignore
File path: .autojs.build.ignore
file under the project folder.
The file matched by the rules of the file configuration will not participate in the CloudControl Pro packaging apk process, and the final generated apk will not contain the specified file.
For example, sometimes node_modules is only used during development, and it has been packaged as a single file by tools such as webpack when it is finally packaged. You can configure to ignore the node_modules folder.
.autojs.sync.ignore
File path: .autojs.sync.ignore
file under the project folder.
The files matched by the rules configured in this file will be ignored when the VSCode plug-in runs, synchronizes, and saves files on the computer. Only available for Pro 9.3+.
scripts
The scripts field is used to configure the shell commands that are automatically executed at times such as building. E.g:
{
//...
"scripts": {
"build-apk-pre-prepare": "sh build.sh"
},
//...
}
The above configuration will automatically run the build.sh script before packaging the apk, so that custom file replacement, obfuscation, etc. can be performed before packaging. In these shell commands, you can use node build.js
to execute js files (pure Node.js environment); currently, it does not support executing js scripts in CloudControl environment.
The following timings are currently supported:
Triggered when building apk
CloudControl Pro builds the apk in several stages:
- Preparation stage: copy project files, apk files, process source files, etc.
- Construction phase: execute aapt compilation, add built-in icon packs, modify and write Manifest files, process plug-ins, etc.
- Optimization phase: remove useless resources, modules, obfuscated components, etc.
- Packaging phase: signing, compressing, cleaning up workspace, etc.
The sh scripts to be executed can be customized at different stages. In these scripts, information can be obtained through the following environment variables:
BUILD_APK_WORKSPACE
: The temporary workspace for the build, that is, the temporary project for decompressing the apkBUILD_APK_WORKSPACE_PROJECT
: The project folder under the workspace, the project will be copied hereBUILD_APK_OUTPUT
: target output path of apk
The current project path can be obtained by commands such as pwd
.
The names corresponding to each stage are:
-
build-apk-pre-prepare
: Triggered before the prepare phase -
build-apk-post-prepare
: Triggered after the exact phase -
build-apk-pre-build
: Triggered before the build phase -
build-apk-post-build
: Triggered after the build phase -
build-apk-pre-optimize
: Triggered before the optimization phase -
build-apk-post-optimize
: Triggered after the optimize phase -
build-apk-pre-package
: Triggered before the packaging phase -
build-apk-post-package
: Triggered after the packaging phase