Gradle Java Simple Project use

Source: Internet
Author: User

Prepare the environment Gradle Configure the variables to facilitate the generation of Project 1. Environment configuration
gradle wrapper生成项目结构├── build.gradle├── gradle│   └── wrapper│       ├── gradle-wrapper.jar│       └── gradle-wrapper.properties├── gradlew├── gradlew.bat
2. Add Java code structure
实际上代码结构类似maven   src/main/java/project参考如下:└── src    └── main        └── java            └── appdemo                └── MainApp.javaMainApp.java 内容package appdemo;public class MainApp {  public static void main(String[] args) {    System.out.println("dalong demo");  }}
3. Add Build Configuration
build.gradle 文件apply plugin: ‘java‘  //java 插件// 打包配置apply plugin: ‘application‘ mainClassName = ‘appdemo.MainApp‘
4. Build Build
./gradlew  buildbuild├── classes│   └── java│       └── main│           └── appdemo│               └── MainApp.class├── distributions│   ├── first.tar│   └── first.zip├── libs│   └── first.jar├── scripts│   ├── first│   └── first.bat└── tmp    ├── compileJava    └── jar        └── MANIFEST.MF总的来说比maven 加单很多,同时为我们生成了运营脚本,实际在太方便了,同时构建速度也比较快maven 的打包配置大家用的话可能会比较熟悉的一个插件是maven-assembly-plugin 同时写一大堆的配置
5. References
https://docs.gradle.org/4.3.1/userguide/userguide.html

Gradle Java Simple Project use

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.