Gradle-没有主清单属性 [英] Gradle- no main manifest attribute

查看:5168
本文介绍了Gradle-没有主清单属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行一个建立在Gradle之上的JAR文件时,出现了这个错误,我有点疯了。该错误读取没有主清单属性,在RxJavaDemo.jar我试图操纵Manifest属性,但我想我忘记添加依赖关系或其他东西。

I'm kind of going crazy with this error I get when running a JAR file built off Gradle. The error reads "no main manifest attribute, in RxJavaDemo.jar" I tried manipulating the Manifest property but I think I'm forgetting to add the dependencies or something to it. What exactly am I doing wrong?

apply plugin: 'java'
apply plugin: 'application'

mainClassName = 'demo.MainDashboard'

dependencies {

    compile files ("H:/Processes/Development/libraries/hikari-cp/HikariCP-2.4.1.jar")
    compile files ("H:/Processes/Development/libraries/controls-fx/controlsfx.jar")
    compile files ("H:/Processes/Development/libraries/database_connections/sqlite-jdbc-3.8.6.jar")
    compile files ("H:/Processes/Development/libraries/guava/guava-18.0.jar")
    compile files ("H:/Processes/Development/libraries/rxjava/rxjava-1.0.12.jar")
    compile files ("H:/Processes/Development/libraries/rxjava-extras/rxjava-extras-0.5.15.jar")
    compile files ("H:/Processes/Development/libraries/rxjavafx/RxJavaFX-1.0.0-RC1-SNAPSHOT.jar")
    compile files ("H:/Processes/Development/libraries/rxjavaguava/rxjava-guava-1.0.3.jar")
    compile files ("H:/Processes/Development/libraries/rxjava-jdbc/rxjava-jdbc-0.6.3.jar")
    compile files ("H:/Processes/Development/libraries/slf4j/slf4j-api-1.7.12.jar")
    compile files ("H:/Processes/Development/libraries/tom-commons/tom-commons.jar")

}

sourceSets {
    main.java.srcDir "src/main/java"
    main.resources.srcDir "src/main/resources"
}

    jar { 
  manifest {
    attributes(
      "Class-Path": configurations.compile.collect { it.getName() }.join(' '))
  }
    from configurations.compile.collect { entry -> zipTree(entry) }
}


推荐答案

更改您的清单属性,如:

Try to change your manifest attributes like:

jar {
  manifest {
    attributes(
      'Class-Path': configurations.compile.collect { it.getName() }.join(' '),
      'Main-Class': 'hello.HelloWorld'
    )
  }
}

然后改变'hello.helloWorld' code>给你的课程,它有一个主要的方法。在这种情况下,你在你的清单中创建一个属性,指向这个类,然后一个jar正在运行。

And then just change 'hello.helloWorld' to your class, which has a main method. In this case, you make in your manifest an attribute, which point to this class, then a jar is running.

这篇关于Gradle-没有主清单属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆