当前位置:网站首页>Gradle的安装配置
Gradle的安装配置
2022-08-03 05:09:00 【*super】
一、下载与安装
下载并解压(CSDN4文件夹或者官网:Gradle Build Tool)
二、配置环境变量
1.新建变量GRADLE_HOME,变量值为文件夹路径。
2.Path中新增%GRADLE_HOME%\bin
3.测试:cmd---gradle -v
(指定仓库配置:GRADLE_USER_HOME,仓库地址)
三、配置Gradle
1.Gradle文件夹---init.d文件夹---新建init.gradle文件
内容:
allprojects {
repositories{
maven { url 'file:D:/JAVA3/1.21/maven/localrepository'}//maven本地仓库地址
mavenLocal()
maven { name "Alibaba"; url"https://maven.aliyun.com/repository/public"}
mavenCentral()
}
}
2.idea配置
类似Maven,找到Gradle,修改仓库地址为Maven仓库地址。
四、创建Gradle工程
参考Maven工程创建。
五、依赖导入
1.更改配置地址
2.复制Maven依赖,会自动识别并更改格式,如:implementation 'org.apache.poi:poi:5.2.0'
注意:低版本的Gradle需要将
implementation替换成compile
3.刷新依赖
六、文件打包
1.打开bulid.gradle,在plugins中添加id 'application'
2.增加jar选项并修改配置
七、其他知识点
1.mirrors 镜像仓库
<mirrors>
<!--阿里云镜像-->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>repo2</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://repo2.maven.org/maven2/</url>
</mirror>
</mirrors>2.仓库repositories
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>3.pluginRepositories插件仓库
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>4.pom文件配置
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>pom-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<!-- 依赖管理,添加在其中的依赖会被导入-->
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
<!-- 依赖管理,这里配置了之后不会实际导入,只是指定了导入版本,其子模块就可以直接使用而不需要指定版本了-->
<dependencyManagement>
</dependencyManagement>
<!-- maven编译和打包处理-->
<build>
<!-- 插件配置,将项目打包成一个可执行的jar包,并将依赖打包进去-->
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!-- 此处指定main方法入口的class -->
<mainClass>pom.demo.PomDemo</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<!-- 指定jar包名称-->
<finalName>pom-demo</finalName>
</build>
</project>边栏推荐
猜你喜欢

Windows 安装PostgreSQL

Exception (abnormal) and Error (error) difference analysis

接口和协议

链动2+1模式简单,奖励结构丰厚,自主裂变?

常见荧光染料修饰多种基团及其激发和发射波长数据一览数据

【Harmony OS】【FAQ】鸿蒙问题合集1

Interface Test Framework Practice (4) | Get Schema Assertion

BIOTIN ALKYNE CAS: 773888-45-2 Price, Supplier

Secondary development of WinForm controls

Fluorescent marker peptides FITC/AMC/FAM/Rhodamine TAMRA/Cy3 / Cy5 / Cy7 - Peptide
随机推荐
Detailed explanation of MOSN reverse channel
js garbage collection mechanism
【生物素叠氮化物|cas:908007-17-0】价格_厂家
数字孪生园区场景中的坐标知识
3. 无重复字符的最长子串
shell script loop statement
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
探索性测试的概念及方法
1060 爱丁顿数 (25 分)
Modified BiotinDIAZO-Biotin-PEG3-DBCO|diazo-biotin-tripolyethylene glycol-diphenylcyclooctyne
接口测试框架实战 | 流程封装与基于加密接口的测试用例设计
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
接口和抽象
Unity2D horizontal board game tutorial 6 - enemy AI and attack animation
C#异步和多线程
在树莓派上搭建属于自己的网页(2)
【HMS core】【Ads Kit】华为广告——海外应用在国内测试正式广告无法展示
WinForm的控件二次开发
Tributyl-mercaptophosphane "tBuBrettPhos Pd(allyl)" OTf), 1798782-17-8
Power button 561. An array of split