Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get started with gradle

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

In this issue, the editor will bring you about how to get started with gradle. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

Gradle installation project code

Https://gitee.com/trial-run/gradle

Https://gitee.com/kcnf

Download gradle

Https://gradle.org/releases/

Gradle-v

Download jdk

Jdk8

Download groovy

Http://www.groovy-lang.org

Groovy-2.5.8

The relationship between groovy and gradle

Pom like maven relies on xml syntax

Case tool ideagradle vs maven

In the Maven world, there are six types of scope for a dependency, namely complie (default), provided, runtime, test, system, and import. Grade simplified it to four types: compile (compile time), runtime (run time), testCompile (test compile time) and testRuntime (test run time).

Gradle supports dynamic version dependencies. Dynamic version management can be achieved by using the + sign after the version number.

Gradle-sample project construction

Common points of gradle Calibration maven

Replace pom with build.gradle and settings.gradle

Reuse the bosses' code pom and build.gradle, the impact is quite strong.

2.3 com.google.code.kaptcha kaptcha ${kaptcha.version} jdk15 org.springframework spring-core org.springframework spring-beans org.springframework spring-context junit junit

Dependencies {compile ('org.springframework:spring-core:2.5.6') compile (' org.springframework:spring-beans:2.5.6') compile ('org.springframework:spring-context:2.5.6') compile (' com.google.code.kaptcha:kaptcha:2.3:jdk15') testCompile ('junit:junit:4.7')}

Settings.gradle and build.gradle

Build.gradle-the file contains the scripts used to build the project

Settings.gradle-the file will contain the necessary settings such as lazy relationships between tasks or projects, etc.

Build script summary

[gradle-script]

Project is commonly used

Groupname (artifact) version project version (global) sourceCompatibility = 1.8 / jdk version used by source targetCompatibility = 1.8 / / jdk version used at compilation or updated java virtual machine compatible compileJava.options.encoding = 'UTF-8' compileTestJava.options.encoding =' UTF-8'apply application plug-in dependencies add dependency repositories add repository task definition task buildscriptallprojectssubprojectsconfigurations

Method

Attributes:

Dependency management

[gradle-sample]

The difference between api/apiElements and implementation

Gradle has been abandoned since 3.4.It has been replaced by api | implementation, both of which we can use

Api-Local dependence of the same module is open to the outside world

Implementation-dependency isolation when local dependencies on the same module

Multi-project construction

[gradle-module]

Publish

[gradle-deploy]

Gradle provides the maven-publish plug-in by default

Version conflict resolution

Exclude

Force a version to be specified

Detailed dependencies can be queried through the help-> dependencies task

Common configuration changes

External configuration of sensitive information

Gradle.properties mechanism

Change the location of the local warehouse like maven

D:\ gradle\ gradleRepository\ caches\ modules-2\ files-2.1

GRADLE_USER_HOME

D:\ gradle\ gradleRepository

Configuration through system environment variables

Specified by idea

The local cache path is

Specify remote private server as with maven

Repositories {mavenLocal () maven {url "https://maven.aliyun.com/repository/public"} maven {url" https://oss.sonatype.org/content/repositories/snapshots/"} jcenter ()}

Same as maven configuration, profile

The same parent dependency mechanism as maven

Commonly used tripartite plug-ins

Types of plug-ins, script plug-ins and binary plug-ins

Custom script plug-in [gradle-script]

Binary plug-in

Plugins {id 'java'}

Automated test custom task to solve the problem that local maven and gradle exist at the same time. The above is how to get started with the gradle shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report