Using Gradle to build Java Web projects in eclipse

Source: Internet
Author: User
Tags jcenter

Gradle is an automated construction tool that uses a DSL to declare project settings. With Gradle, you can configure the dependencies of your project and automatically download the files you depend on, making it much more efficient to build your project.

1. Installing Gradle

Download the latest version of GRADLE, unzip it, set the environment variable gradle_home, and add%gradle_home%\bin to the path;

2. Installing the Gradle Plugin

Search for Gradle in Eclipse's help->eclipse marketplace, install buildship;

3. Create a Gradle project

Select File->new->other->gradle->gradle Project to create a new Gradle project:

Set the Gradle path and Java path:

4. Convert Project to Web project

Right-click the project, select Properties->project Facets, select dynamic Web Module:

5. Configure Gradle

Open the Build.gradle file for the following edits:

/* * This build file is auto generated by running the Gradle ' init ' task * by ' Simon ' at ' 16-11-17 Juan example 崍 2:49 ' with Gradle 3 .2 * * This generated file contains a sample Java project to get started. * For more details take a look at the Java Quickstart chapter in the Gradle * User Guide available at https://docs.gradle. org/3.2/userguide/tutorial_java_projects.html *///Apply The Java plugin to add support for javaapply plugin: ' java '//' This section, you declare, where to find the dependencies of your projectrepositories {//use ' jcenter ' for resolving yo    ur dependencies.    You can declare any maven/ivy/file repository here. Jcenter ()}//in this section declare the dependencies for your production and test codedependencies {//Struts Lib Rary compile group: ' Org.apache.struts ', Name: ' Struts2-core ', version: ' 2.3.24.1 ' compile ' org.apache.struts:struts 2-spring-plugin:2.3.24.1 ' compile ' org.apache.struts:struts2-json-plugin:2.3.24.1 '//Spring library COmpile group: ' Org.springframework ', Name: ' Spring-core ', version: ' 4.2.3.RELEASE ' compile group: ' Org.springframework ' , name: ' Spring-web ', version: ' 4.2.3.RELEASE ' compile group: ' Org.springframework ', Name: ' Spring-orm ', version: ' 4.2. 3.RELEASE ' compile group: ' Org.springframework ', Name: ' Spring-aop ', version: ' 4.2.3.RELEASE ' compile group: ' ORG.SP Ringframework ', Name: ' Spring-aspects ', version: ' 4.2.3.RELEASE ' compile group: ' Org.springframework ', Name: ' Spring-jd BC ', version: ' 4.2.3.RELEASE '//Hibernate library Compile group: ' Org.hibernate ', Name: ' Hibernate-core ', ve Rsion: ' 5.0.1.Final '//Common library compile ' org.slf4j:slf4j-api:1.7.13 ' testcompile ' junit:junit:4.12 '}

The warehouse uses Jcenter () or mavencentral (), but Jcenter () is better, including mavencentral (). The dependencies are configured with struts, Spring, hibernate files, and some other commonly used files.

Is it more convenient to start automatically downloading the dependent files for the above configuration by clicking the Run button of gradle executions? Of course, if you already have these files, you can also rely on the local files.

Using Gradle to build Java Web projects in eclipse

Related 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.