为什么我在rome-utils-1.15.0.jar中没有得到主清单属性



我正在尝试使用rome rss库。然而,当我去执行我的jar时,我得到了错误。

我认为这与我的build.gradle.kts文件有关。我已经把它复制到这里

buildscript {
repositories {
maven("https://plugins.gradle.org/m2/")
maven(url = "https://www.jitpack.io") {
name = "jitpack"
}
flatDir {
dirs("libs")
}
}
dependencies {
}
}
plugins {
application
kotlin("jvm") version "1.4.0"
id("com.github.johnrengelman.shadow") version "6.1.0"
}
application {
mainClassName = "io.ktor.server.netty.EngineMain"
}
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url = uri("https://kotlin.bintray.com/ktor") }
maven(url = "https://www.jitpack.io") {
name = "jitpack"
}
}
tasks {
withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
archiveBaseName.set("freedom")
archiveClassifier.set("")
archiveVersion.set("1.1.0")
manifest {
attributes(mapOf("Main-Class" to application.mainClassName))
}
}
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
implementation("io.ktor:ktor-server-netty:$ktor_version")
implementation("com.rometools:rome:1.15.0")
implementation("ch.qos.logback:logback-classic:$logback_version")
implementation("io.ktor:ktor-client-core:$ktor_version")
implementation("io.ktor:ktor-client-core-jvm:$ktor_version")
implementation("io.ktor:ktor-gson:$ktor_version")
implementation("io.ktor:ktor-client-apache:$ktor_version")
implementation("io.ktor:ktor-html-builder:$ktor_version")
implementation("com.github.chimbori:crux:2.2.0")
implementation("org.jsoup:jsoup:1.13.1")
implementation("io.lettuce:lettuce-core:6.0.1.RELEASE")
implementation("org.jetbrains.exposed", "exposed-core", "0.28.1")
implementation("org.jetbrains.exposed", "exposed-dao", "0.28.1")
implementation("org.jetbrains.exposed", "exposed-jdbc", "0.28.1")
implementation("com.google.firebase:firebase-admin:7.0.1")
implementation("org.postgresql", "postgresql", "42.2.18")
implementation("com.zaxxer:HikariCP:3.4.5")
implementation("com.github.kittinunf.fuel:fuel:2.3.0")
implementation("com.github.kittinunf.fuel:fuel-gson:2.3.0")
testImplementation("io.ktor:ktor-server-tests:$ktor_version")
}
kotlin.sourceSets["main"].kotlin.srcDirs("src")
kotlin.sourceSets["test"].kotlin.srcDirs("test")
sourceSets["main"].resources.srcDirs("resources")
sourceSets["test"].resources.srcDirs("testresources")

没有这个库,我的应用程序构建良好。但是,我需要使用这个特定的库。我在类似的问题上尝试过一些步骤,但都不起作用。当尝试执行我的程序时,我得到了no main manifest attribute, in rome-utils-1.15.0.jar

问题在于shadowJar不正确地构建了Rome jar。这是必须在shadowJar的github上处理的事情。

我遇到了同样的问题,我确信问题不在build.gradle文件中。

根据Gradle用户指南,我相信您想要的是mainClass而不是mainClassName

所以试试

application {
mainClass = "io.ktor.server.netty.EngineMain"
}

最新更新