添加依赖关系导致找不到主类

时间:2020-09-17 08:44:13

标签: java gradle

com.spotify:docker-client:3.5.12依赖项添加到build.gradle时,它导致找不到我的主类“ com.gamedash.daemon.Main”。我完全不知道这可能会引起什么。消除依赖关系可以解决问题。

build.gradle

group 'com.gamedash.daemon'
version '0.1'
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'

sourceCompatibility = 9
targetCompatibility = 9

repositories {

    mavenCentral()
    maven {

        url 'https://jetbrains.bintray.com/pty4j'

    }

}

application {

    mainClassName = 'com.gamedash.daemon.Main'

}

jar {

    manifest {

        attributes(

            'Main-Class': 'com.gamedash.daemon.Main'

        )
    }
    from {

        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }

    }

}

sourceSets {

    main {

        resources {

            srcDirs "src/main/resources", "src/main/configs"

        }

    }

}

buildscript {

    repositories {

        mavenCentral()

    }
    dependencies {

        classpath 'net.sf.proguard:proguard-gradle:6.2.2'

    }

}

dependencies {

    implementation('me.tongfei:progressbar:0.7.4')
    implementation('com.google.guava:guava:28.2-jre')
    implementation('com.corundumstudio.socketio:netty-socketio:1.7.17')
    implementation('org.jetbrains.pty4j:pty4j:0.8.6')
    implementation('commons-io:commons-io:2.6')
    implementation('org.zeroturnaround:zt-zip:1.13')
    implementation('org.apache.httpcomponents:httpclient:4.5.8')
    implementation('com.beust:jcommander:1.78')
    implementation('com.google.code.gson:gson:2.8.5')
    implementation('com.github.oshi:oshi-core:4.4.2')
    implementation('net.java.dev.jna:jna:5.3.1')
    implementation('net.java.dev.jna:jna-platform:5.3.1')
    implementation('org.apache.commons:commons-lang3:3.9')
    implementation('com.sparkjava:spark-core:2.9.1')
    implementation('org.slf4j:slf4j-api:1.7.6')
    implementation('org.slf4j:slf4j-log4j12:1.7.5')
    implementation('org.apache.mina:mina-core:2.0.0-M2')
    implementation('org.apache.ftpserver:ftplet-api:1.1.1')
    implementation('org.apache.ftpserver:ftpserver-core:1.1.1')
    implementation('org.apache.sshd:sshd-core:2.4.0')
    implementation('org.apache.sshd:sshd-sftp:2.4.0')
    compile('com.spotify:docker-client:3.5.12:shaded')
    implementation('org.beryx:text-io:3.3.0')
    implementation('com.fasterxml.jackson.core:jackson-core:2.9.8')
    implementation('com.fasterxml.jackson.core:jackson-annotations:2.9.8')
    implementation('com.fasterxml.jackson.core:jackson-databind:2.9.8')
    compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4'
    implementation group: 'commons-validator', name: 'commons-validator', version: '1.4.0'
    implementation files('lib/icmp4j-all.jar')
    implementation files('lib/Schokker-IT-Rest-Client.jar')
    implementation files('lib/com.gamedash.daemon.common.jar')

}

task obfuscate(type: proguard.gradle.ProGuardTask) {

    configuration 'proguard.txt'
    injars "build/libs/gamedash-daemon-${ version }.jar"
    outjars "build/libs/gamedash-daemon-${ version }-obfuscated.jar"

}

1 个答案:

答案 0 :(得分:1)

事实证明,该库使用Bouncycastle,因此需要运行签名的jar。如果错误消息会这样说,那会更加令人愉快,而不是告诉我未找到该类。

通过在我的build.gradle中添加以下规则来修复它

struct S;

S foo();  // 1

struct S { virtual void bar() = 0; };  // 2