Gradle Packaging for production environment and test environment configuration separation

Source: Internet
Author: User
Tags java web
Gradle Packaging for production environment and test environment configuration separation

Previous: Maven packaging for production environment and test environment configuration separation

The previous article was package management using Maven, and this time we used Gradle for the configuration of the package management of Java Web Server. Configuring the Gradle configuration file

The directory where the associated resources configuration files are configured in Build.gradle. Different resource files are placed in the src/main/filters/$env directory, where $env directory is the environment name, for example: Dev, test, product, and so on. and defines the default environment for the DEV environment.

def env = System.getproperty ("Profile"): "Dev"

sourcesets {  
    Main {
        resources {
            srcdirs = ["src/main/ Resources "," src/main/filters/$env "]}}
}

Put the properties of different environment files, respectively, in the filters directory under the different environment files, as shown below.

When compiling with Gradle, add the parameter-dprofile=dev to specify why the final code of the compilation is the environment. Such as:

# Compile the program into a production environment
./gradlew bootrepackage-dprofile=product
use Intellij idea to launch different Gradle environments

Here's how you can see how MAVEN works in the same way as in the previous article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.