gpt4 book ai didi

gradle - java和travis-ci的问题,编码覆盖率和gradle

转载 作者:行者123 更新时间:2023-12-03 04:58:19 25 4
gpt4 key购买 nike

我曾在多个地方尝试过如何使用gradle在travis-ci中配置Codacy的覆盖范围。

我发现如何在没有travis-CI的情况下配置Gradle。我想自动做些事情。
有人可以帮忙吗?

加:

我的build.gradle

buildscript {
ext {
springBootVersion = '2.0.5.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}


plugins {
id "org.sonarqube" version "2.6"
id 'com.gradle.build-scan' version '1.16'
}
configurations { codacy }
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.rjdesenvolvimento'
version = '0.0.1'
sourceCompatibility = 1.11

repositories {
mavenCentral()
}

tasks.withType(Test) { enabled = false }

dependencies {
testImplementation 'junit:junit:4.12'
compile group: 'org.hibernate', name: 'hibernate-core', version: '5.3.6.Final'
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-security')
implementation('org.springframework.boot:spring-boot-starter-web')
runtimeOnly('org.springframework.boot:spring-boot-devtools')
runtimeOnly('org.postgresql:postgresql')
annotationProcessor("org.projectlombok:lombok:1.18.2")
compileOnly('org.projectlombok:lombok')
compileOnly('org.sonarsource.sonarqube:sonar-plugin-api:7.3')
compileOnly('org.jacoco:org.jacoco.core:0.8.2')
compileOnly('org.jacoco:org.jacoco.agent:0.8.2')
compileOnly('com.codacy:codacy-coverage-reporter:5.0.310')
testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
testImplementation('org.springframework.boot:spring-boot-starter-test')
testImplementation('org.springframework.security:spring-security-test')
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.4.0-b180830.0359'
codacy 'com.github.codacy:codacy-coverage-reporter:-SNAPSHOT'
}

buildScan {
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
termsOfServiceAgree = 'yes'
}

task sendCoverageToCodacy(type: JavaExec, dependsOn: jacocoTestReport) {
main = "com.codacy.CodacyCoverageReporter"
classpath = configurations.codacy
args = [
"report",
"-l",
"Java",
"-r",
"${buildDir}/reports/jacoco/test/jacocoTestReport.xml"
]
}

jacocoTestReport{
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)
reports {
xml.enabled false
csv.enabled false
html.destination "${buildDir}/reports/jacoco/html"
}
executionData = files('build/jacoco/test.exec')
}

test {
finalizedBy jacocoTestReport
}

和travis.yml
env:
- CODACY_PROJECT_TOKEN=c8f9b1f6aab444018dd4e3...
language: java
install: true

jdk:
- oraclejdk11
before_install:
- chmod +x gradlew
- sudo apt-get install jq
- wget -O ~/codacy-coverage-reporter-assembly-latest.jar $(curl https://api.github.com/repos/codacy/codacy-coverage-reporter/releases/latest | jq -r '.assets[0].browser_download_url')

dist: trusty
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
addons:
sonarcloud:
organization: "rjdesenvolvimento-github"
token:
secure: 5150fa5cbf1f86006a140e0b8a96e...
script:
- ./gradlew build --scan -s sonarqube -Dsonar.projectKey=rjdesenvolvimento_apipessoas -Dsonar.organization=rjdesenvolvimento-github -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=5150fa5cbf1f86006a140e0b8a96e...

after_success:
- bash <(curl -s https://codecov.io/bash)>
  • java -jar〜/ codacy-coverage-reporter-assembly-latest.jar报告-l Java -r build / reports / jacoco / test / jacocoTestReport.xml

  • 和travis-ci
    > Task :compileJava
    > Task :processResources
    > Task :classes
    > Task :bootJar
    > Task :jar SKIPPED
    > Task :assemble
    > Task :compileTestJava
    > Task :processTestResources NO-SOURCE
    > Task :testClasses
    > Task :test SKIPPED
    > Task :jacocoTestReport SKIPPED
    > Task :check UP-TO-DATE
    > Task :build
    > Task :sonarqube
    $ java -jar ~/codacy-coverage-reporter-assembly-latest.jar report -l Java -r build/reports/jacoco/test/jacocoTestReport.xml
    10/24 23:51:49 INFO c.c.rules.ConfigurationRules:101 - Using API base URL: https://api.codacy.com
    10/24 23:51:49 ERROR c.c.CodacyCoverageReporter$:28 - File /home/travis/build/rjdesenvolvimento/apipessoas/build/reports/jacoco/test/jacocoTestReport.xml does not exist.

    到目前为止,还没有覆盖

    最佳答案

    您是否尝试过按照此处的说明创建Gradle任务? https://github.com/codacy/codacy-coverage-reporter/blob/master/README.md#gradle-task

    关于gradle - java和travis-ci的问题,编码覆盖率和gradle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52974252/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com