-
Notifications
You must be signed in to change notification settings - Fork 4
06. Packaging and Distribution
In this page we describe how to package and distribute SCD4J projects.
It is important to have both package name and version set in the build.gradle file of your SCD4J project. This allows a better control of the version being run.
archivesBaseName='MyPackName'
version = 0.1If you don't set the above properties, SCD4J will use as the package name the name of directory AND unspecified as version number.
Once you are going to run the same module in different environments (probably in development, testing, staging and production) and each environment has its own config file, you should let the config property dynamic to avoid changing build.gradle file before running it against a different environment. Take the below content as an example:
scd4j {
install {
modules = ...
config project.hasProperty("envconfig") ? envconfig : ""
}
}As you may notice, the value assigned to the property config is a variable called envconfig or an empty string if it was not set. Doing that you can decide which will be your config file at run time setting it at line command.
./gradlew -Penvconfig=example-stagging.conf
OR
./gradlew -Penvconfig=example-production.conf
SCD4J has no crystal ball, so it is important that you provide your infra-structure environments. In order to do so, you need to fill out each environment with all IP addresses in the env definition. For example:
scd4j {
install {
modules = ...
config project.hasProperty("envconfig") ? envconfig : ""
env {
production "192.168.10.18", "192.168.10.18"
staging "192.168.7.20", "192.168.7.21"
testing "192.168.6.20", "127.0.1.1"
}
}
}Note that, by default, SCD4J understand 4 different environments (i.e. development, testing, staging and production) and every IP address that is not in testing, stating and production will be considered as development. Moreover, if you have a simpler infra-structure, let say you do not have an staging environment, just do not fill out this information and everything will be good.
Note: this information is super important because it is used as a security lock. In other words, if you try to execute a development configuration against a production environment SCD4J will not allow you to do so if you have configured correctly env definition.
You need to go to the project directory and type in the line command
- ./gradlew tasks for Linux
- gradlew.bat tasks for Windows
This will print something like that:
...
Scd4j tasks
-----------
pack - Generates a zip to be installed in another environment. Triggered in the default gradle artifacts generation.
scd4j - Automatically isntall and configure the environment
...As the description says, the task pack will generate a zip to be installed in another environment. Then what you need to to is type the below in the command line:
./gradlew pack
:pack
BUILD SUCCESSFUL
Total time: 5.318 secs
This will create a zip file at build/distributions/.
To install exactly the same modules in other environments, just copy the zip file generated with pack task to the desired server. Then, unzip and execute it.
You don't have to commit directories .gradle, build, log and backup in the source code repository once they are generated automatically and are specific for each machine.