首页 > 解决方案 > gradlew kts 多项目输出 jar

问题描述

我如何从多项目创建 jar。

gradlew -q 项目输出:

在此处输入图像描述

根文件夹中的build.gradle.kts (test)

plugins {
    java
}

version = "0.0.1"
group = "up"

allprojects {
    repositories {
        mavenCentral()
    }

    plugins.apply("java")

    java.sourceCompatibility = JavaVersion.VERSION_1_10

    tasks {
        compileJava {
            options.encoding = "UTF-8"
        }

        compileTestJava {
            options.encoding = "UTF-8"
        }
    }

}

settings.gradle.kts :

rootProject.name = "test"
include("config","gitrawdata","analyzer","webgen","cli")

分析器的 build.gradle.kts:


plugins {
    `java-library`
}

dependencies {
    implementation(project(":config"))
    implementation(project(":gitrawdata"))
    testImplementation("junit:junit:4.+")
}

cli的build.gradle.kts:

plugins {
    java
    application
}

application.mainClass.set("up.visulog.cli.CLILauncher")

dependencies {
    implementation(project(":analyzer"))
    implementation(project(":config"))
    implementation(project(":gitrawdata"))
    testImplementation("junit:junit:4.+")
}

config、gitrawdata、webgen的build.gradle.kts:


plugins {
    `java-library`
}

dependencies {
    testImplementation("junit:junit:4.+")
}

如何从多模块项目创建一个 jar?

gradlew build 生成空的 jar 文件。

标签: gradlebuild.gradlegradle-kotlin-dsl

解决方案


推荐阅读