Kotlin 为什么在rome-utils-1.15.0.jar中没有主清单属性?
我正在尝试使用罗马rss库。然而,当我去执行我的jar时,我得到了错误 我假设它与build.gradle.kts文件有关。我把它抄在这里了Kotlin 为什么在rome-utils-1.15.0.jar中没有主清单属性?,kotlin,gradle,rome,Kotlin,Gradle,Rome,我正在尝试使用罗马rss库。然而,当我去执行我的jar时,我得到了错误 我假设它与build.gradle.kts文件有关。我把它抄在这里了 buildscript { repositories { maven("https://plugins.gradle.org/m2/") maven(url = "https://www.jitpack.io") { name = "jitpa
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")
buildscript{
存储库{
马文(“https://plugins.gradle.org/m2/")
maven(url=”https://www.jitpack.io") {
name=“jitpack”
}
弗拉蒂尔{
目录(“libs”)
}
}
依赖关系{
}
}
插件{
应用
kotlin(“jvm”)版本“1.4.0”
id(“com.github.johnrengelman.shadow”)版本“6.1.0”
}
应用{
mainClassName=“io.ktor.server.netty.EngineMain”
}
存储库{
mavenLocal()
jcenter()
mavenCentral()
maven{url=uri(“https://kotlin.bintray.com/ktor") }
maven(url=”https://www.jitpack.io") {
name=“jitpack”
}
}
任务{
withType{
kotlinOptions.jvmTarget=“11”
}
命名为(“阴影jar”){
archiveBaseName.set(“自由”)
archiveClassifier.set(“”)
archiveVersion.set(“1.1.0”)
显示{
属性(mapOf(“主类”到application.mainClassName))
}
}
}
依赖关系{
实现(“org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_版本”)
实现(“io.ktor:ktor服务器净值:$ktor_版本”)
实施(“com.rometools:rome:1.15.0”)
实现(“ch.qos.logback:logbackclassic:$logback\u版本”)
实现(“io.ktor:ktor客户端核心:$ktor_版本”)
实现(“io.ktor:ktor客户端核心jvm:$ktor_版本”)
实现(“io.ktor:ktor gson:$ktor_版本”)
实现(“io.ktor:ktor客户端apache:$ktor_版本”)
实现(“io.ktor:ktor html生成器:$ktor_版本”)
实现(“com.github.chimbori:crux:2.2.0”)
实现(“org.jsoup:jsoup:1.13.1”)
实现(“io.莴苣:莴苣核心:6.0.1.RELEASE”)
实现(“org.jetbrains.exposed”、“exposed core”、“0.28.1”)
实现(“org.jetbrains.exposed”、“exposed dao”、“0.28.1”)
实现(“org.jetbrains.exposed”、“exposed jdbc”、“0.28.1”)
实现(“com.google.firebase:firebase admin:7.0.1”)
实施(“org.postgresql”、“postgresql”、“42.2.18”)
实施(“com.zaxxer:HikariCP:3.4.5”)
实现(“com.github.kittinunf.fuel:fuel:2.3.0”)
实现(“com.github.kittinunf.fuel:fuel-gson:2.3.0”)
测试实现(“io.ktor:ktor服务器测试:$ktor_版本”)
}
kotlin.sourceset[“main”].kotlin.srcDirs(“src”)
kotlin.sourceset[“测试”].kotlin.srcDirs(“测试”)
sourceset[“main”].resources.srcDirs(“资源”)
sourceset[“test”].resources.srcDirs(“testresources”)
没有此库,我的应用程序可以正常运行。但是,我需要使用这个特定的库。我在类似的问题上尝试过一些步骤,但都不起作用。当我试图执行我的程序时,在rome-utils-1.15.0.jar中没有主清单属性,我遇到了相同的问题,我确信问题不在
build.gradle
文件中。我相信你想要mainClass
而不是mainClassName
所以试试看
application {
mainClass = "io.ktor.server.netty.EngineMain"
}
问题在于shadowJar不正确地构建罗马jar。这是必须在shadowJar的github上解决的问题。您遇到了哪一个错误?@thokuest Adddhi,如何在gradle文件中称您为本地.jar文件?@Ric17101我不确定您的意思不,这是根据Ktor说明解决的。您是如何修复的?