Gradle (i) Use Gradle to fight a war package in an existing Web project __web

Source: Internet
Author: User
Tags tomcat
GRADLE official website Download the latest compression package, after decompression set environment variable Gradle_home to extract the directory, in the path before adding%gradle_home%\lib;  Open cmd run gradle-v  view version currently used 2.14


Build Build.gradle content under the original project as follows

Apply plugin: ' War '
  
sourcecompatibility = 1.6   //Set JDK version
Webappdirname = ' webcontent '    //Set WEBAPP root directory 
  //set Java source directory
sourcesets {
    main {
            srcdir ' src '
        }
        Resources {
            Srcdir ' Resources '}}
  
//Set MAVEN library address
repositories { 
    maven {URL ' http://maven.oschina.net/ content/groups/public/'}
}

dependencies {
	Tasks.withtype (javacompile) {
		options.encoding = " UTF-8 "
	}
    Compile Filetree (dir: ' Webcontent/web-inf/lib ', include: [' *.jar '])
    //Use this
    when there is no network compileonly files (' C:/java/tomcat/apache-tomcat-6.0.37/lib/servlet-api.jar ')
    
    //network is with MAVEN
    // Providedcompile ' javax.servlet:servlet-api:2.5 '//compile period
}
  
Finally, under CMD, enter project ROOT to run Gradle build and generate war package under Build/lib

Gradle can run like ant in a network environment or download a dependency package like Maven

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.