使用特定包时无法找到或加载主类

时间:2017-08-22 11:45:44

标签: java intellij-idea gradle jar kotlin

我需要使用browsermob-proxy

我的项目可以从IDE运行,但是当我通过gradle构建它并将compile 'net.lightbody.bmp:browsermob-core:2.1.4'添加到我的gradle配置文件中时,jar已成功构建(没有任何错误),但主函数未加载:

#gradle clean jar

#java -jar build/proxy-0.1.jar

  

“错误:无法找到或加载主类myproject.MainKt”

如果我将此实用程序添加到我现有的包中(可以构建并作为胖罐运行),则无法构建它。

我做错了什么?

可能是browsermob-proxy中的错误吗?

感谢。

我的gradle文件如下:

group 'proxy'

version '0.1'

buildscript {
    ext.kotlin_version = '1.1.3'
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath group: 'org.jetbrains.kotlin', name: 'kotlin-gradle-plugin', version: kotlin_version
        classpath 'org.junit.platform:junit-platform-gradle-plugin:1.0.0-M6'
    }
}

apply plugin: 'kotlin'
apply plugin: 'java'
apply plugin: 'org.junit.platform.gradle.plugin'

repositories {
    mavenCentral()
    jcenter()
    maven { url 'https://jitpack.io' }
}


dependencies {
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8'
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version'
    compile 'net.lightbody.bmp:browsermob-core:2.1.4'
    testCompile("org.junit.jupiter:junit-jupiter-api:5.0.0-M6")
    testCompile("org.junit.jupiter:junit-jupiter-params:5.0.0-M6")
    testRuntime("org.junit.jupiter:junit-jupiter-engine:5.0.0-M6")
}

jar {
    destinationDir = file('build/')
    manifest {
        attributes 'Main-Class': 'myproject.MainKt'
    }
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

0 个答案:

没有答案