Eclipse gradle Configuration

Source: Internet
Author: User

I. Introduction of Gradle

Gradle is based on the Groovy language and is oriented toward Java applications. Automated building tools based on DSL (domain-specific language) syntax.

Second, the configuration steps are as follows :

1. Download resources:

Grandle official website Download Gradle, address: http://www.gradle.org/downloads

Tip: If just run can download bin only, in order to expand the development or download all.

2, after downloading, unzip the zip to the installation directory, for example: D:\Program Files

3, set the environment variables, you need to set the following 2 environment variables

1. Add gradle_home to the root directory of the installation directory that points to Gradle

Gradle_home=d:\program files\gradle-2.0

2. Path variable add gradle Bin directory

D:\Program files\gradle-2.0\ Bin

4, the above steps are set, open cmd, run gradle-v see gradle version information, configuration completed.

5. Open Eclipse,help-->install new software, enter Http://dist.springsource.com/release/TOOLS/gradle

If the prompt cannot find the address, it is estimated that the wall dropped, need to FQ. If you find an address, select the installation and then continue to the next step until the installation is complete, and then restart Eclipse.

6. Create a Web project and create a Build.gradle file in the root directory

The contents of the Build.gradle file are as follows:ImportOrg.gradle.plugins.ide.eclipse.model.Facet

Apply plugin:' Maven '
Apply plugin:' Java '
Apply plugin:' War '
Apply plugin:' ECLIPSE-WTP '


Sourcecompatibility= 1.8//Set JDK version
Webappdirname = ' webcontent '//Setting the WebApp root directory
SourceSets.main.java.srcDir ' src '//set the directory where Java source code resides


//set MAVEN Library address
Repositories {
Mavencentral ()//Central Library
Maven {URL ' http://localhost:8081/nexus/content/groups/public '}//Custom Library Address
}


//Setting Dependencies
Dependencies {
Providedcompile' javax.servlet:servlet-api:2.5 '//Compile time
Providedruntime ' javax.servlet:jstl:1.2 '//Run-time
}


//set up Project Facets
Eclipse {
WTP {
Facet {
Facet Name:' Jst.web ', type:Facet.FacetType.fixed
Facet Name:' Wst.jsdt.web ', type:Facet.FacetType.fixed
Facet Name:' Jst.java ', type:Facet.FacetType.fixed
Facet Name:' Jst.web ', version: ' 2.5 '
Facet Name:' Jst.java ', version: ' 1.8 '
Facet Name:' Wst.jsdt.web ', Version: ' 1.0 '
}
}
}

Tip: The project has a G, under normal circumstances is not, you need to right-click the project "Configure->convert to Gradle project.", wait a moment OK, you can like I have this icon G,

Add Dependency Package: You need to right-click the project "Gradle->refresh All", "gradle->dependency->management".

8. Possible error

Unable to start the daemon process. This problem might is caused by incorrect configuration of the daemon. For example, a unrecognized JVM option is used. Referto the User Guide chapter on the daemon at http://gradle.org/docs/2.2.1/userguide/gradle_daemon.htm Lplease read the following process output to find out more:-----------------------Error occurred during initialization of Vmcould not reserve enough space for object heaperror:could not create the Java Virtual machine.error:a Fatal exception Has occurred. Program would exit. Could not fetch model of type ' hierarchicaleclipseproject ' using Gradle distribution ' https://services.gradle.org/ distributions/gradle-2.2.1-bin.zip '.
Workaround
1,2, create the file gradle.properties    content: Org.gradle.jvmargs=3, restart your Android studio project, you can.

9, set Gradle the storage address of the jar package, "Window->preferences->gradle", as follows:

Eclipse gradle Configuration

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.