- 安装并配置maven
- 安装gradle,并配置环境变量
- 配置init.gradle,主要是配置仓库
- 配置项目中build.gradle,配置仓库和其他
init.gradle
allprojects {
repositories {
mavenLocal()
maven { name "Alibaba" ; url "https://maven.aliyun.com/repository/public" }
maven { name "Bstek" ; url "https://nexus.bsdn.org/content/groups/public/" }
mavenCentral()
}
buildscript {
repositories {
maven { name "Alibaba" ; url 'https://maven.aliyun.com/repository/public' }
maven { name "Bstek" ; url 'https://nexus.bsdn.org/content/groups/public/' }
maven { name "M2" ; url 'https://plugins.gradle.org/m2/' }
}
}
}
build.gradle
plugins {
id 'java'
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenLocal()
maven {url 'https://maven.aliyun.com/repository/public/'}
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'io.netty', name: 'netty-all', version: '4.1.47.Final'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
jar{
manifestContentCharset 'utf-8'
metadataCharset 'utf-8'
manifest{
attributes "Main-Class":"com.example.Main"
}
from {
configurations.compile.collect {
it.isDirectory() ? it : zipTree(it)
}
}
}
有用的链接