gpt4 book ai didi

java - 没有主要Maifest属性Gradle

转载 作者:行者123 更新时间:2023-12-03 06:06:37 25 4
gpt4 key购买 nike

我已经阅读了有关此问题的所有其他主题,并应用了所有可以找到的解决方案。没有任何帮助。当我运行gradle.build任务时,我得到一个.jar文件。但是当运行文件时,我得到no main manifest attribute, in DiscordBotJDA-1.0.jarannyone可以提供帮助吗?

非常感谢!

这是我的gradle.buidl文件:

/*
* This build file was auto generated by running the Gradle 'init' task
* by 'Timbo' at '7/13/16 2:08 PM' with Gradle 2.9
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/2.9/userguide/tutorial_java_projects.html
*/

// Apply the java plugin to add support for Java
apply plugin: 'java'

apply plugin: 'application'
mainClassName = 'start.StartUp'
version = '1.0'


task fatJar(type: Jar) {
manifest {
attributes 'Implementation-Title': 'MCI_Bot',
'Implementation-Version': version,
'Main-Class': 'start.StartUp'
manifest.attributes("Main-Class": 'start.startUp')
}
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}

// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.13'

compile 'net.dv8tion:JDA:2.1.3_327'


// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile 'junit:junit:4.12'
}

我正在使用Eclipse以防万一。

最佳答案

您是否期望您的“fatJar”任务会这样做?仅定义任务并不会将其放入任务执行树中。您必须直接运行任务,或者指定包含任务的任务依赖关系。例如,说另一个任务取决于它。

您最好指定一个“jar”配置块,以配置已经存在的“jar”任务,该任务已经定义了适当的依赖关系。

阅读User Guide以获取配置“jar”任务的示例。

下载Gradle发行版可能更方便,该发行版提供了User Guide的PDF,这可能更易于搜索。

关于java - 没有主要Maifest属性Gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38413343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com