/* * This file was generated by the Gradle 'init' task. */ plugins { id 'java' id 'maven-publish' } repositories { mavenLocal() maven { url = uri('https://repo.maven.apache.org/maven2/') } } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web:2.5.4' implementation 'org.projectlombok:lombok:1.18.20' implementation 'com.github.binarywang:wx-java-mp-spring-boot-starter:4.1.0' implementation 'io.github.biezhi:oh-my-email:0.0.4' testImplementation 'org.springframework.boot:spring-boot-starter-test:2.5.4' // json 依赖库 implementation 'org.json:json:20210307' } group = 'cn.xuthus83' version = '0.0.1' description = 'wx_post' java.sourceCompatibility = JavaVersion.VERSION_1_8 publishing { publications { maven(MavenPublication) { from(components.java) } } } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } //用于添加Java插件,以及一些内置任务,打包jar就要用到这里的插件 apply plugin: 'java' //用于把项目构建成idea项目 apply plugin: 'idea' //定义项目的一些信息 group = "com.jiliang" version = "1.1" description = "hello, this demo for gradle." repositories { mavenCentral() } java { archivesBaseName = "gradle-project" sourceCompatibility = JavaVersion.VERSION_1_8 } jar { String someString = '' //通过configurations.runtime拿到所有的运行时的依赖jar包,然后.each遍历他,通过it.name获取到每个的jar包的name,赋值 //遍历项目的所有依赖的jar包赋值给变量 configurations.runtimeClasspath.each {someString = someString + " lib\\"+it.name}someString manifest { attributes 'Main-Class': 'com.each.dubboMainEnd' attributes 'Class-Path': someString } } //建立函数copyJar 用于把依赖的jar复制到对应的目录下 task copyJar(type:Copy){ from configurations.runtime into ('build/libs/lib') } //函数release即是我们打包的时候的执行的函数,dependsOn[build,copyJar]这里会让执行relese函数的时候先执行build(系统自带的函数) 和copyJar task release(type: Copy,dependsOn: [build,copyJar]) { // from 'conf' // into ('build/libs/eachend/conf') }