gradlew complie没有lib.jar
我正在使用gradle(gradle 4.7)编译一个项目(Java 1.8),该项目具有多模块:gradlew complie没有lib.jar,gradle,Gradle,我正在使用gradle(gradle 4.7)编译一个项目(Java 1.8),该项目具有多模块: ./gradlew -p web -x test build 其中一个没有dist jar,其他的有,有什么问题吗?编译输出的正常dir结构: --build ----classes ----libs ----tmp 以及异常的dir结构: --build ----classes ----tmp 这是build.gradle(异常模块): PS:all模块不生成libs文件夹,libs是缓存
./gradlew -p web -x test build
其中一个没有dist jar,其他的有,有什么问题吗?编译输出的正常dir结构:
--build
----classes
----libs
----tmp
以及异常的dir结构:
--build
----classes
----tmp
这是build.gradle(异常模块):
PS:all模块不生成libs文件夹,libs是缓存。为什么模块不生成dis jar文件,如何配置我的gradle项目。这是我的项目的完整配置:
group 'dolphin'
version '1.0-SNAPSHOT'
buildscript {
ext {
springBootVersion = '2.1.3.RELEASE'
springVersion = '4.3.7.RELEASE'
springfoxVersion = '2.6.1'
jacksonVersion = '2.8.7'
lombokVersion = '1.16.14'
}
ext['tomcat.version'] = '9.0.16'
repositories {
mavenCentral()
jcenter{
url 'http://jcenter.bintray.com'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
def getVersionCode() {
def versionFile = file("$rootDir/version.properties")
if (!versionFile.canRead()) {
throw new GradleException("Could not find version.properties!")
}
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
def versionCode = versionProps['VERSION'].toString()
return versionCode
}
repositories {
mavenCentral()
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
}
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '4.7'
}
project(":common") {
description = ''
dependencies {
api("org.springframework:spring-context:" + springVersion)
api("commons-codec:commons-codec:1.10")
api("org.apache.tomcat:tomcat-juli:" + property('tomcat.version'))
api 'org.springframework.boot:spring-boot-starter-web'
api group: 'io.swagger', name: 'swagger-annotations', version: '1.5.20'
api("org.projectlombok:lombok:${lombokVersion}")
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
api group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '1.3.0'
api group: 'org.mybatis', name: 'mybatis', version: '3.4.4'
api group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
}
}
project(":composite") {
description = 'dolphin-composite'
dependencies {
implementation project(":monitor-business")
api project(":data")
implementation("org.springframework:spring-context:" + springVersion)
}
}
project(":web") {
description = "web"
archivesBaseName = "dolphin-web-" + getVersionCode()
jar {
// Will include every single one of your dependencies, project or not
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
dependencies {
api project(':monitor-business')
api project(':api')
api project(':common')
api project(':data')
api project(':composite')
implementation("com.zaxxer:HikariCP:2.6.0")
api("org.mybatis:mybatis-spring:1.3.0")
implementation("mysql:mysql-connector-java:5.1.24")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter")
implementation("io.springfox:springfox-swagger2:2.9.2")
implementation("io.springfox:springfox-swagger-ui:2.9.2")
implementation group: 'org.apache.tomcat', name: 'tomcat-juli', version: property('tomcat.version')
implementation("org.projectlombok:lombok:1.16.14")
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
implementation group: 'org.mybatis', name: 'mybatis', version: '3.4.2'
implementation group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
}
project(":monitor-business") {
description = "business"
dependencies {
api project(':data')
api project(':common')
implementation('org.springframework.boot:spring-boot-starter-web')
}
}
project(":data") {
description = "data"
dependencies {
api project(':common')
api("org.projectlombok:lombok:${lombokVersion}")
implementation("com.zaxxer:HikariCP:2.6.0")
implementation group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
api("org.hibernate:hibernate-validator:5.2.4.Final")
api("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1")
api("org.apache.commons:commons-lang3:3.5")
api group: 'org.springframework', name: 'spring-jdbc', version: '5.1.5.RELEASE'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
api group: 'org.mybatis', name: 'mybatis', version: '3.4.2'
api group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
}
}
PS:我的问题是这样的备忘录:
我已经解决了这个问题,但不知道为什么……为了解决这个问题,使用这个命令来构建项目(它将生成libs文件夹和jar文件):
Gradle版本:4.7。(Gradle 5.3不工作)要解决此问题,请使用此命令构建项目(它将生成libs文件夹和jar文件): 渐变版本:4.7。(渐变5.3不工作)
group 'dolphin'
version '1.0-SNAPSHOT'
buildscript {
ext {
springBootVersion = '2.1.3.RELEASE'
springVersion = '4.3.7.RELEASE'
springfoxVersion = '2.6.1'
jacksonVersion = '2.8.7'
lombokVersion = '1.16.14'
}
ext['tomcat.version'] = '9.0.16'
repositories {
mavenCentral()
jcenter{
url 'http://jcenter.bintray.com'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
def getVersionCode() {
def versionFile = file("$rootDir/version.properties")
if (!versionFile.canRead()) {
throw new GradleException("Could not find version.properties!")
}
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
def versionCode = versionProps['VERSION'].toString()
return versionCode
}
repositories {
mavenCentral()
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
repositories {
mavenCentral()
}
}
task wrapper(type: Wrapper) {
description = 'Generates gradlew[.bat] scripts'
gradleVersion = '4.7'
}
project(":common") {
description = ''
dependencies {
api("org.springframework:spring-context:" + springVersion)
api("commons-codec:commons-codec:1.10")
api("org.apache.tomcat:tomcat-juli:" + property('tomcat.version'))
api 'org.springframework.boot:spring-boot-starter-web'
api group: 'io.swagger', name: 'swagger-annotations', version: '1.5.20'
api("org.projectlombok:lombok:${lombokVersion}")
api group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
api group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '1.3.0'
api group: 'org.mybatis', name: 'mybatis', version: '3.4.4'
api group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
}
}
project(":composite") {
description = 'dolphin-composite'
dependencies {
implementation project(":monitor-business")
api project(":data")
implementation("org.springframework:spring-context:" + springVersion)
}
}
project(":web") {
description = "web"
archivesBaseName = "dolphin-web-" + getVersionCode()
jar {
// Will include every single one of your dependencies, project or not
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
dependencies {
api project(':monitor-business')
api project(':api')
api project(':common')
api project(':data')
api project(':composite')
implementation("com.zaxxer:HikariCP:2.6.0")
api("org.mybatis:mybatis-spring:1.3.0")
implementation("mysql:mysql-connector-java:5.1.24")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter")
implementation("io.springfox:springfox-swagger2:2.9.2")
implementation("io.springfox:springfox-swagger-ui:2.9.2")
implementation group: 'org.apache.tomcat', name: 'tomcat-juli', version: property('tomcat.version')
implementation("org.projectlombok:lombok:1.16.14")
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.5'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
implementation group: 'org.mybatis', name: 'mybatis', version: '3.4.2'
implementation group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
testCompile group: 'junit', name: 'junit', version: '4.12'
}
}
project(":monitor-business") {
description = "business"
dependencies {
api project(':data')
api project(':common')
implementation('org.springframework.boot:spring-boot-starter-web')
}
}
project(":data") {
description = "data"
dependencies {
api project(':common')
api("org.projectlombok:lombok:${lombokVersion}")
implementation("com.zaxxer:HikariCP:2.6.0")
implementation group: 'org.postgresql', name: 'postgresql', version: '42.1.4'
api("org.hibernate:hibernate-validator:5.2.4.Final")
api("org.mybatis.spring.boot:mybatis-spring-boot-starter:1.1.1")
api("org.apache.commons:commons-lang3:3.5")
api group: 'org.springframework', name: 'spring-jdbc', version: '5.1.5.RELEASE'
api group: 'org.slf4j', name: 'slf4j-api', version: '1.7.24'
api group: 'org.mybatis', name: 'mybatis', version: '3.4.2'
api group: 'org.mybatis', name: 'mybatis-typehandlers-jsr310', version: '1.0.2'
testCompile group: 'junit', name: 'junit', version: '4.11'
api("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
}
}
./gradlew -p web -x test -x jar build