Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/388.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
未找到类:javax.annotation和未找到资源:<;java测试类>;在运行gradlebuild时_Java_Gradle_Sonarqube - Fatal编程技术网

未找到类:javax.annotation和未找到资源:<;java测试类>;在运行gradlebuild时

未找到类:javax.annotation和未找到资源:<;java测试类>;在运行gradlebuild时,java,gradle,sonarqube,Java,Gradle,Sonarqube,使用gradle对SonarQube 5.3运行SonarScanner 1.2时,我遇到如下错误: Class not found: javax.annotation.Nullable Class not found: javax.annotation.CheckReturnValue Class not found: javax.annotation.Nullable Class not found: org.joda.convert.FromString Class not found:

使用gradle对SonarQube 5.3运行SonarScanner 1.2时,我遇到如下错误:

Class not found: javax.annotation.Nullable
Class not found: javax.annotation.CheckReturnValue
Class not found: javax.annotation.Nullable
Class not found: org.joda.convert.FromString
Class not found: org.joda.convert.ToString
Class not found: org.joda.convert.FromString
Class not found: org.joda.convert.ToString
Class not found: org.joda.convert.FromString
Class not found: org.joda.convert.ToString
Class not found: javax.annotation.Nullable

and:
Resource not found: a.b.c.d.ControllerTest
and the likes ( all Integration tests ) 
我试过:

 dependencies {
      classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2'
      classpath 'javax.annotation:javax.annotation-api:1.2'    }
但这似乎不起作用

另外-Dsonar.java.libraries=**/lib/* 作为gradle论证也不起作用

使用gradle 2.2.1、jdk 7、sonarscanner 1.2和SonarQube 5.3

下面是build.gradle:

apply plugin: 'crypto'

buildDir='gradlebuild'

apply from: "graphviz.gradle"
//apply plugin: 'findbugs'
apply plugin: 'org.sonarqube'
//apply plugin: 'net.saliman.cobertura'
apply plugin: 'jacoco'

def currentJvm = org.gradle.internal.jvm.Jvm.current()
println "ELIS - Loading Gradle Files"
println "Using JVM: ${currentJvm}"

//def version
if(releaseDeploy.toLowerCase() == "true"){
        version = archiveBranch + "." + archiveBuildNumber
}else{
        version = archiveBranch + "." + archiveBuildNumber + "." + "SNAPSHOT"
}
group = "a.b.c.d"

rootProject.ext.uploads = [
    ':Build:FT',
        ':Backend:ServicesApp',
        ':Backend:ExternalAPI',
        ':Shared:Interfaces',
        ':Shared:Domain',
        ':Shared:TestUtils',
        ':Shared:Libs',
        ':Shared:RulesLib',
        ':Shared:security',
        ':Shared:DataLoader',
        ':Tests:SharedFunctionalTestAssets',
        ':Workspace:javakeystore',
]

rootProject.ext.sonarProjects = [
    ':Backend:BenefitRequestProcessModels',
    ':InternalApp:InternalApp',
    ':Backend:ServicesApp',
    ':InternalApp:InternalAppDomain',
    ':Shared:Domain',
    ':Shared:FormRepository',
    ':Shared:Libs',
    ':Shared:Resources',
    ':Shared:RulesLib',
    ':Shared:security',
]

apply from: rootProject.rootDir.getPath()+'/common.dependencies.gradle'

import groovy.text.SimpleTemplateEngine

boolean RunFunctionalTests=false

repositories {
   maven {
       url "http://${project.ext.nexus}/nexus/content/groups/public"
   }
}
buildscript {
   repositories {
      maven {
         url "http://${project.ext.nexus}/nexus/content/groups/public"
       }
   }
   dependencies {
      classpath 'a.b.c.d:crypto-plugin:0.1.4'
      //classpath 'org.codehaus.sonar.runner:sonar-runner-dist:2.4'
      //classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.0.1'
      classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:1.2'
      classpath 'net.saliman:gradle-cobertura-plugin:2.2.7'
      //classpath 'net.saliman:gradle-cobertura-plugin:2.3.2'
      //classpath 'com.google.code.findbugs:jsr305:3.0.1'
      //classpath 'org.joda:joda-convert:1.8'
      //classpath 'javax.interceptor:javax.interceptor-api:3.1'
      //classpath 'com.mysema.querydsl:querydsl-jpa:3.6.0'
      // Spring dependency-management-plugin used to manage all BOMs
      classpath "io.spring.gradle:dependency-management-plugin:0.5.7.RELEASE"
   }
}

subprojects {
   apply plugin: 'java'
   apply plugin: 'maven'
   apply plugin: 'groovy'
   apply plugin: 'eclipse-wtp'

   apply from: rootProject.rootDir.getPath()+'/common.dependencies.gradle'

   project.version = rootProject.version
   project.archiveBranch = rootProject.archiveBranch
   project.archiveBuildNumber = rootProject.archiveBuildNumber
   project.group = rootProject.group

   eclipse.project {
      natures 'org.springsource.ide.eclipse.gradle.core.nature'
   }

   tasks.compileJava {
      options.encoding = 'ISO-8859-1'
      options.incremental = true
   }

   tasks.compileTestJava {
      options.encoding = 'ISO-8859-1'
      options.incremental = true
   }

   task json {
      project.ext.snap_id_file = new File(project.projectDir.getPath()+'/snapshot_id.json')
      clean.delete.add(snap_id_file)
      project.tasks.getByName("build").dependsOn(json)

      doLast { task ->
         if(releaseDeploy.toLowerCase() == "true") {
            snap_id_file.write(
               "{\"ELIS2_VERSION\" : " + "\"" + archiveBranch + "-" + archiveBuildNumber + "\"}" )
         } else {
            // Snapshot release
            snap_id_file.write(
               "{\"ELIS2_VERSION\" : " + "\"" + archiveBranch + ".SNAPSHOT-" + archiveBuildNumber + "\"}"
            )
         }
      }
   }

   if(sonarProjects.contains(project.getPath()) && rootProject.hasProperty('sonar') ){
      //apply plugin: 'net.saliman.cobertura'
      apply plugin: 'org.sonarqube'

      cobertura {
         coverageDirs << file("${projectDir}/build/classes/main")
         coverageFormats = ['xml','html']
         coverageIncludes = [".*a.b.c.*"]
         coverageIgnoreTrivial = true
         //coverageReportDir = new File("${projectDir}/build/reports/cobertura")
      }
      project.tasks.generateCoberturaReport.outputs.file file("${projectDir}/build/reports/cobertura/coverage.xml")
      project.tasks.cobertura.outputs.dir  file("${projectDir}/build/cobertura")

      sonarqube{
         //toolVersion = "1.2"
         properties{
            property "sonar.issuesReport.html.enable", "true"
            //property "sonar.analysis.mode", "preview"
            property "sonar.cobertura.reportPath", file("${projectDir}/build/reports/cobertura/coverage.xml")

            //moved old properties to sonarscanner format
            //property "sonar.projectBaseDir", "${projectDir}"
            //property "sonar.working.directory", "${projectDir}/build/sonar"
            //property "sonar.cobertura.reportPath", "${projectDir}/build/reports/cobertura/coverage.xml"
            //property "project.settings","${projectDir}/build/tmp/sonarRunner/sonar-project.properties"

            properties["sonar.sources"] += "src/main/java"
            properties["sonar.test"] += ["src/intTest/java", "src/test/java"]
         }
         //forkOptions {
         //   systemProperty "sonar.projectBaseDir", "${projectDir}"
         //   systemProperty "sonar.working.directory", "${projectDir}/build/sonar"
         //   systemProperty "sonar.analysis.mode", System.properties["sonar.analysis.mode"] ?: "preview"
         //   systemProperty "sonar.cobertura.reportPath", "${projectDir}/build/reports/cobertura/coverage.xml"
         //   systemProperty "sonar.host.url", "http://${sonar}"
         //   systemProperty "project.settings","${projectDir}/build/tmp/sonarRunner/sonar-project.properties"
         //   environment = System.getenv()
         //   maxHeapSize = '768m'
         //   jvmArgs '-XX:MaxPermSize=256m'
         // }

      }
      project.tasks.sonarqube.dependsOn(project.tasks.cobertura)

   }
}

allprojects{
        apply plugin: "io.spring.dependency-management"
        dependencyManagement {
                /* This is required by the spring dependency management plugin.
                 * If the 'copy' action is not provided, the plugin will attempt
                 * to reach out to maven central to pull the BOM file that is
                 * being used by the plugin to manage spring versions. */
                generatedPomCustomization {
                        importedBomAction = 'copy'
                }
        }
   task dumpProps <<{
      project.ext.properties.each {
         log.lifecycle(project.name +"  "+it.key+"="+it.value)
      }
   }
}

def loadConfiguration(String dir) {
  def browser = System.getenv()['browser']
  def environment = (browser != null) ? browser : 'ff'
  ext.set 'environment', environment
  logger.info("Environment is set to $environment")

  def configFile = file(dir+'/config.groovy')
  def config = new ConfigSlurper(environment).parse(configFile.toURL())
  ext.set 'config', config
}

task FT {
   rootProject.ext.RunFunctionalTests = false

   doFirst {
      rootProject.ext.RunFunctionalTests = true
      logger.quiet( "Environment: ${System.properties['ENVIRONMENT']}")
      logger.quiet( "ftWebHost: ${ftWebHost}")
      logger.quiet("databaseServer: ${databaseServer}")
   }
}

task noINT {
   rootProject.ext.RunIntegrationTests = true

   Set<Task> intTests = project.getTasksByName("intTest",true)
   intTests.each(){
      it.mustRunAfter rootProject.noINT
      it.onlyIf { rootProject.ext.RunIntegrationTests }
      it.project.tasks.getByName("check").dependsOn(it)
      it.dependsOn(project.tasks.getByPath(":Database:baseline"))
      it.dependsOn(project.tasks.getByPath(":Database:update"))
   }


   doFirst {
      rootProject.ext.RunIntegrationTests = false
      rootProject.ext.RunDBInit=false
   }
}

task noDB {
   rootProject.ext.RunDBInit = true

   def dbProj = project.getChildProjects()["Database"]
   if(dbProj) dbProj.tasks.each {
      it.mustRunAfter rootProject.noINT
      it.onlyIf { rootProject.ext.RunDBInit}
   }

   Set<Task> dbTasks = project.getTasksByName("baseline",true)
   dbTasks.addAll project.getTasksByName("update",true)
   dbTasks.each {
      it.mustRunAfter rootProject.noDB
      it.onlyIf { rootProject.ext.RunDBInit }
   }

   doFirst {
      rootProject.ext.RunDBInit = false
   }
}

task uploadAll (){
        dependsOn = rootProject.ext.uploads.collect{"${it}:uploadArchives"}
}

task copyDeps(type: Copy) {

    subprojects.each { subproject -> subproject.configurations.compile
        if(subproject.name != 'Metis') {
            from(subproject.configurations.compile)
            into project.file("gradlebuild/lib")
        }
    }

    into project.file('gradlebuild/libs')
}

ext {
  jacocoVersion = '0.7.5.201505241946'
}

jacoco {
  toolVersion = jacocoVersion
}
jacocoTestReport {
  reports {
    html.enabled = true
    xml.enabled = true
    csv.enabled = true
  }
}
test.finalizedBy jacocoTestReport


logger.quiet "archiveBranch(inside dinks)='${archiveBranch}'"
logger.quiet "databaseServer=${databaseServer}"
logger.quiet "ftWebHost=${ftWebHost}"
logger.quiet "version=${version}"
应用插件:“加密”
buildDir='gradlebuild'
申请者:“graphviz.gradle”
//应用插件:“findbugs”
应用插件:“org.sonarqube”
//应用插件:“net.saliman.cobertura”
应用插件:“jacoco”
def currentJvm=org.gradle.internal.jvm.jvm.current()
println“ELIS-加载渐变文件”
println“使用JVM:${currentJvm}”
//def版本
if(releaseDeploy.toLowerCase()=“true”){
版本=archiveBranch+“+”archiveBuildNumber
}否则{
版本=archiveBranch+“+”archiveBuildNumber+“+”快照”
}
group=“a.b.c.d”
rootProject.ext.uploads=[
“:Build:FT”,
“:后端:ServicesApp”,
“:后端:外部API”,
“:共享:接口”,
“:共享:域”,
“:Shared:TestUtils”,
“:共享:Libs”,
':Shared:RulesLib',
“:共享:安全性”,
“:共享:数据加载器”,
“:测试:SharedFunctionalTestAssets”,
“:Workspace:javakeystore”,
]
rootProject.ext.projects=[
“:后端:BenefitRequestProcessModels”,
“:InternalApp:InternalApp”,
“:后端:ServicesApp”,
“:InternalApp:InternalAppDomain”,
“:共享:域”,
“:共享:FormRepository”,
“:共享:Libs”,
“:共享:资源”,
':Shared:RulesLib',
“:共享:安全性”,
]
应用于:rootProject.rootDir.getPath()+'/common.dependencies.gradle'
导入groovy.text.SimpleTemplateEngine
布尔函数RunFunctionalTests=false
存储库{
马文{
url“http://${project.ext.nexus}/nexus/content/groups/public”
}
}
构建脚本{
存储库{
马文{
url“http://${project.ext.nexus}/nexus/content/groups/public”
}
}
依赖关系{
类路径“a.b.c.d:加密插件:0.1.4”
//classpath'org.codehaus.sonar.runner:sonar runner dist:2.4'
//classpath'org.sonarsource.scanner.gradle:sonarqube-gradle插件:2.0.1'
classpath'org.sonarsource.scanner.gradle:sonarqube-gradle插件:1.2'
类路径“net.saliman:gradle cobertura插件:2.2.7”
//类路径“net.saliman:gradle-cobertura插件:2.3.2”

//classpath'com.google.code.findbugs:jsr305:3.0.1' //类路径'org.joda:joda convert:1.8' //类路径“javax.interceptor:javax.interceptor api:3.1” //类路径'com.mysema.querydsl:querydsl jpa:3.6.0' //用于管理所有BOM的Spring依赖项管理插件 classpath“io.spring.gradle:依赖项管理插件:0.5.7.RELEASE” } } 子项目{ 应用插件:“java” 应用插件:“maven” 应用插件:“groovy” 应用插件:“EclipseWTP” 应用于:rootProject.rootDir.getPath()+'/common.dependencies.gradle' project.version=rootProject.version project.archiveBranch=rootProject.archiveBranch project.archiveBuildNumber=rootProject.archiveBuildNumber project.group=rootProject.group eclipse.project{ natures'org.springsource.ide.eclipse.gradle.core.nature' } tasks.compileJava{ options.encoding='ISO-8859-1' options.incremental=true } tasks.compileTestJava{ options.encoding='ISO-8859-1' options.incremental=true } 任务json{ project.ext.snap_id_file=新文件(project.projectDir.getPath()+'/snapshot_id.json') clean.delete.add(快照id文件) project.tasks.getByName(“构建”).dependsOn(json) 多拉斯特{任务-> if(releaseDeploy.toLowerCase()=“true”){ snap_id_file.write( “{\'ELIS2\u VERSION\”:“+”\“+archiveBranch+”-“+archiveBuildNumber+”\“}”) }否则{ //快照发布 snap_id_file.write( “{\'ELIS2\u VERSION\”:“+”\“+archiveBranch+”。快照-“+archiveBuildNumber+“\”}” ) } } } if(sonarProjects.contains(project.getPath())&&rootProject.hasProperty('sonar')){ //应用插件:“net.saliman.cobertura” 应用插件:“org.sonarqube” 科贝图拉{
Coverage目录通常我们使用“compile”或“testcompile”目录来包含外部依赖项,如果这些依赖项用于编译源代码。只有当引用仅在运行时使用时,才使用“classpath”指令。may help实际上没有帮助,因为它与mvn plus相关。我认为这些指令在编译时没有使用,因此将使用classpath指令。有人建议使用jsr305的classpath,但删除了帖子。也不确定如何处理“未找到资源”对于集成测试,尝试dependenciesclasspath'com.google.code.findbugs:jsr305:2.0.3'中的类路径'com.google.code.findbugs:jsr305:2.0.3'在dependencies中无效