为什么gradle模块不生成jar文件?

时间:2019-03-26 08:23:31

标签: gradle

我在项目中有2个Java模块,问题是依赖模块(这里是通用模块)没有生成jar文件,并且dist jar包不包含依赖jar(可能导致运行时错误)。这是我的构建.gradle配置:

buildscript {
    ext {
        springBootVersion = '2.1.3.RELEASE'
    }

    repositories {
        mavenCentral()
        jcenter{
            url 'http://jcenter.bintray.com'
        }
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }

    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath "io.freefair.gradle:lombok-plugin:3.1.4"
    }
}

plugins {
    id 'java'
    id 'java-library'
    id "org.springframework.boot" version "2.1.3.RELEASE"
    id "io.spring.dependency-management" version "1.0.5.RELEASE"
}

group 'dolphin'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

allprojects {
    apply plugin: 'java'
    apply plugin: 'java-library'
    apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    repositories {
        mavenCentral()
    }
}

project(":common") {

}

project(":web") {
    jar {
        // Will include every single one of your dependencies, project or not
        from {
            configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
        }
    }

    dependencies {
        api project(':common')
    }
}

setting.gradle配置:

rootProject.name = 'monitor'
include 'web'
include 'common

'

我注意到公共模块已经编译(生成了classes文件夹和tmp文件夹,但是没有libs文件夹)。当我使用此命令构建公共模块时,它可以生成公共jar文件:

./gradlew -p common -x test build

如何使依赖项目自动生成jar。

0 个答案:

没有答案