找不到类:javax.annotation和找不到资源:<java test =“”classes =“”>运行gradle build时

时间:2016-07-03 16:59:22

标签: 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: 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}"

0 个答案:

没有答案