2017-08-10 54 views
0

当我尝试从理念我有一个错误理念调试或运行

失败gradle这个项目:建立失败,一个例外。

  • 出了什么问题:任务运行应用程序“根项目”应用程序的搜索找不到。

  • 尝试:运行gradle任务以获取可用任务的列表。使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。创建映像构建失败

总时间:0.153秒任务“跑SearchApplication”根 项目“应用程序的搜索找不到。

请问如何解决。

+0

我在这里发现了同样的问题 - 但任何答案http://techqa.info/programming/question/41475477/task-%27run %27-not-in-root-project-%27 ...%27 –

+0

你的build.gradle是否指定了'application'插件和'mainClassName'? – Bajal

+0

你可能想在这里发布你的build.gradle – Bajal

回答

0

这是我的build.gradle的主要部分

apply plugin: 'application' 
    apply plugin: 'java' 
    apply plugin: 'docker' 
    apply plugin: 'com.github.johnrengelman.shadow' 

    sourceCompatibility = 1.8 

    ext { 
     dropwizardVersion = '1.1.2' 
     mainClass = "com.jobservice.search.AppLauncher" 
     mapstructVersion = '1.1.0.Final' 
    } 
    mainClassName = mainClass 

    repositories { 
     mavenLocal() 
     jcenter() 
     mavenCentral() 
    } 


    buildscript { 
     repositories { jcenter() } 
     dependencies { 
      classpath 'se.transmode.gradle:gradle-docker:1.2' 
      classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4' 
     } 
    } 


    // add logging into test stream 
    test { 
     testLogging.showStandardStreams = true 
    } 

    dependencies { 

     compile group: 'org.bouncycastle', name: 'bcprov-jdk16', version: '1.46' 
     compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.1' 
     compile group: 'org.slf4j', name: 'slf4j-ext', version: '1.7.25' 
     compile group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.25' 
     compile 'com.google.inject:guice:3.0' 
     compile group: 'io.swagger', name: 'swagger-jersey2-jaxrs', version: '1.5.15' 
     compile group: 'io.swagger', name: 'swagger-annotations', version: '1.5.15' 
     compile group: 'com.hubspot.dropwizard', name: 'dropwizard-guice', version: '1.0.6.0' 
     compile group: 'org.liquibase', name: 'liquibase-core', version: '3.5.3' 

     compile (
       'io.dropwizard:dropwizard-core:' + dropwizardVersion, 
       'io.dropwizard:dropwizard-hibernate:' + dropwizardVersion, 
       'org.postgresql:postgresql:9.4.1208.jre7', 
       'io.dropwizard:dropwizard-testing:' + dropwizardVersion 
     ) 
     compile 'org.mapstruct:mapstruct-jdk8:' + mapstructVersion 
     compile group: 'org.apache.commons', name: 'commons-collections4', version: '4.1' 


     testCompile group: 'junit', name: 'junit', version: '4.12' 
     testCompile group: 'org.hamcrest', name: 'hamcrest-junit', version: '2.0.0.0' 
     testCompile 'org.mockito:mockito-core:2.0.54-beta' 
     testCompile group: 'com.h2database', name: 'h2', version: '1.4.194' 
     testCompile('org.glassfish.jersey.test-framework.providers:jersey-test-framework-provider-grizzly2:2.23.2') { 
      exclude group: 'javax.servlet', module: 'javax.servlet-api' 
      exclude group: 'junit', module: 'junit' 
     } 
    } 

    // Configure the shadow jar task 
    shadowJar { 
     classifier = 'dist' 
     baseName = 'jobs-search' 
     version = "1.0" 
     mergeServiceFiles() 
     manifest { 
      attributes 'Main-Class': mainClassName 
     } 
     version = '' 
    } 
    jar { 
     manifest { 
      attributes 'Main-Class': mainClassName 
     } 
    }