First, install the Gradle plug-in, refer to my other article: MyEclipse Integrated Gradle development environment
Create a new Web project, create a new Build.gradle file under the project root directory, and write the following to it:
1 Import Org.gradle.plugins.ide.eclipse.model.Facet2 3 Apply plugin: ' java '4 Apply plugin: ' War '5 Apply plugin: ' ECLIPSE-WTP '6 7 sourcecompatibility = 1.7//Set JDK version8 webappdirname = ' WebRoot '//Set WEBAPP root directory9 sourceSets.main.java.srcDir ' src '//Set the directory where Java source code residesTen One //Set MAVEN library address A Repositories { - //Central Library - mavencentral () the //Custom library address - //Maven {URL ' http://maven.oschina.net/content/groups/public/'} - } - + //Set dependencies - Dependencies { + providedcompile ' javax.servlet:servlet-api:2.5 '//compile period A providedruntime ' javax.servlet:jstl:1.2 '//Runtime at } - - //Set Project Facets - Eclipse { - WTP { - Facet { in facet name: ' Jst.web ', type:Facet.FacetType.fixed - facet name: ' Wst.jsdt.web ', type:Facet.FacetType.fixed to facet name: ' Jst.java ', type:Facet.FacetType.fixed + facet name: ' Jst.web ', Version: ' 3.0 ' - facet name: ' Jst.java ', version: ' 1.7 ' the facet name: ' Wst.jsdt.web ', Version: ' 1.0 ' * } $ }Panax Notoginseng}
Third, next right click on the project, convert to Gradle project configure
Iv. again on the project right click, Gradle, Refresh all
If there is no web. xml file in the Webroot-to-web-inf directory, then right-click the item--myeclipse--Generate Deployment descriptor Stub
The final deployment project runs to see how it works, or you can right-click on the project, run as, MyEclipse server application to select the Web application server that is running.
How to build a Web application with Gradle under MyEclipse