gradle项目打包到maven仓库
引入插件:
apply plugin: ‘java’
apply plugin: “jacoco”
//maven-publish 插件 提交到本地仓库
apply plugin: ‘java-library’
apply plugin: ‘maven’
apply plugin: ‘org.springframework.boot’
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| sourceCompatibility = '1.8' targetCompatibility = '1.8'
tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }
group 'com.eudemon' version '0.1.7-SNAPSHOT'
jacoco { toolVersion = "0.8.1" reportsDir = file("$buildDir/customJacocoReportDir") }
jacocoTestReport { reports { xml.enabled false csv.enabled false html.destination file("${buildDir}/jacocoHtml") } }
configurations { all*.exclude group: 'ch.qos.logback' all*.exclude module: 'slf4j-log4j12' all*.exclude module: 'slf4j-simple' all*.exclude group: 'log4j', module: 'log4j' }
test { useTestNG() finalizedBy jacocoTestReport }
repositories { // maven { // url 'http://maven.aliyun.com/nexus/content/groups/public/' // } mavenLocal() mavenCentral() }
buildscript { ext { springBootVersion = '1.5.6.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") } } // 指定上传的路径 //def localMavenRepo = 'file://' + new File(System.getProperty('user.home'), '.m2/repository').absolutePath def localMavenRepo = 'file:///F:/Env/maven/m2' // 上传Task,Gradle会生成并上传pom.xml文件。 uploadArchives { repositories { mavenDeployer { repository(url: localMavenRepo) //构造项目的Pom文件 pom.project { name = project.name packaging = 'jar' description = 'description' } } } }
dependencies { compile 'org.apache.curator:curator-recipes:4.0.0' compile 'org.slf4j:slf4j-api:1.7.25' compile 'redis.clients:jedis:2.9.0' compile 'commons-codec:commons-codec:1.10' compile 'org.apache.commons:commons-lang3:3.7' compile 'org.yaml:snakeyaml:1.17' compile 'com.google.guava:guava:23.0' compile 'com.fasterxml.jackson.core:jackson-core:2.9.6' compile 'com.fasterxml.jackson.core:jackson-annotations:2.9.6' compile 'com.fasterxml.jackson.core:jackson-databind:2.9.6'
testCompile 'org.testng:testng:6.14.3' testCompile 'org.hamcrest:hamcrest-library:1.3' testCompile 'org.hamcrest:hamcrest-core:1.3' testCompile 'org.mockito:mockito-core:2.18.3' }
|