没有Main Maifest属性Gradle

时间:2016-07-16 16:43:00

标签: java eclipse gradle

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

非常感谢!

这是我的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以防万一。

1 个答案:

答案 0 :(得分:0)

你期待你的" fatJar"任务会这样做吗?仅定义任务并不会将其放入任务执行树中。您必须直接运行任务,或指定包括任务的任务依赖关系。例如,说另一项任务取决于它。

你可能最好只指定一个" jar"配置块,它将配置已经存在的" jar"任务,已经定义了适当的依赖关系。

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

下载Gradle发行版可能更方便,它提供了用户指南的PDF,可能更容易搜索。