Use Gradle to package project jar files

Source: Internet
Author: User

Use Gradle to package project jar files

Both Ant and Maven build tools use xml to describe the task structure. In general, You can package projects and other tasks, but xml is slightly less flexible after all,

The new enterprise build tool Gradle is similar to the shell script on linux and uses Groovy Dynamic Language to write scripts.

Version: Gradle in version 2.2

 

// Date 20141220 apply plugin: 'java' version = '0. 1 'archivesbasename = "myfirstpj" // if this parameter is left blank, the project name + version repositories {mavenCentral ()} sourceSets {main {java {srcDirs = ['src'] }}dependencies {compile fileTree (dir: 'lib', include :'*. jar ')} // compile dependencies, and then package JARtask taskJar (type: Jar, dependsOn: compileJava) {from 'build/classes 'destinationdir = file ('build/libs ')} // clear the last compiled file task clearPj (type: Delete) {delete 'build ', 'target'} // Copy the JAR file to the target directory task release (type: Copy, dependsOn: [clearPj, taskJar]) {from ('build/libs') {include '*. jar '} into ('target ')}

Run Gradle releaseYou can.

 

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.