Spring boot Gradle Build Java编译器问题java.lang.IllegalStateException: endPosTable已经设置

问题描述 投票:0回答:1

我在运行 gradle build 时遇到 java 编译器问题。当我在本地重新运行它时它就过去了。但我无法在詹金斯上重新运行,并且构建总是失败。

gradle版本:6.9 爪哇1.8 春季启动:2.7.15

运行

clean build
后,
compileJava
任务出现以下异常。

重试后构建成功,然后在启动应用程序时

同样的例外情况出现,但对于

compileQuerydsl
任务。我做错了什么,或者我需要在 gradle 文件中更新任何标志

例外:

java.lang.IllegalStateException: endPosTable already set
        at com.sun.tools.javac.util.DiagnosticSource.setEndPosTable(DiagnosticSource.java:136)
        at com.sun.tools.javac.util.Log.setEndPosTable(Log.java:350)
        at com.sun.tools.javac.main.JavaCompiler.parse(JavaCompiler.java:667)
        at com.sun.tools.javac.main.JavaCompiler.parseFiles(JavaCompiler.java:950)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.<init>(JavacProcessingEnvironment.java:900)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.next(JavacProcessingEnvironment.java:929)
        at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1195)
        at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)
        at com.sun.tools.javac.main.Main.compile(Main.java:523)
        at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129)
        at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)
        at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:77)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:94)
        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:55)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:40)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.delegateAndHandleErrors(NormalizingJavaCompiler.java:97)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:51)
        at org.gradle.api.internal.tasks.compile.NormalizingJavaCompiler.execute(NormalizingJavaCompiler.java:37)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:51)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessorDiscoveringCompiler.execute(AnnotationProcessorDiscoveringCompiler.java:37)
        at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:46)
        at org.gradle.api.internal.tasks.compile.ModuleApplicationNameWritingCompiler.execute(ModuleApplicationNameWritingCompiler.java:36)
        at org.gradle.api.internal.tasks.compile.CleaningJavaCompiler.execute(CleaningJavaCompiler.java:53)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalCompilerFactory.lambda$createRebuildAllCompiler$0(IncrementalCompilerFactory.java:98)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:61)
        at org.gradle.api.internal.tasks.compile.incremental.IncrementalResultStoringCompiler.execute(IncrementalResultStoringCompiler.java:45)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:59)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler$2.call(CompileJavaBuildOperationReportingCompiler.java:51)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.api.internal.tasks.compile.CompileJavaBuildOperationReportingCompiler.execute(CompileJavaBuildOperationReportingCompiler.java:51)
        at org.gradle.api.tasks.compile.JavaCompile.performCompilation(JavaCompile.java:345)
        at org.gradle.api.tasks.compile.JavaCompile.performIncrementalCompilation(JavaCompile.java:239)
        at org.gradle.api.tasks.compile.JavaCompile.compile(JavaCompile.java:211)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
        at org.gradle.api.internal.project.taskfactory.IncrementalInputsTaskAction.doExecute(IncrementalInputsTaskAction.java:32)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
        at org.gradle.api.internal.project.taskfactory.AbstractIncrementalTaskAction.execute(AbstractIncrementalTaskAction.java:25)
        at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$2.run(ExecuteActionsTaskExecuter.java:494)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:56)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$run$1(DefaultBuildOperationExecutor.java:71)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.runWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:45)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:71)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:479)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:462)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.access$400(ExecuteActionsTaskExecuter.java:105)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.executeWithPreviousOutputFiles(ExecuteActionsTaskExecuter.java:273)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution.execute(ExecuteActionsTaskExecuter.java:251)
        at org.gradle.internal.execution.steps.ExecuteStep.lambda$executeOperation$0(ExecuteStep.java:65)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.ExecuteStep.executeOperation(ExecuteStep.java:65)
        at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:34)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:47)
        at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:44)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:44)
        at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:34)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:72)
        at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:42)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:53)
        at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:39)
        at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:44)
        at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:77)
        at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:58)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:54)
        at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:32)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:57)
        at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:38)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:63)
        at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:30)
        at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:176)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:76)
        at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:47)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:43)
        at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:32)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:39)
        at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:25)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:102)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$0(SkipUpToDateStep.java:95)
        at java.util.Optional.map(Optional.java:215)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:55)
        at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:39)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:83)
        at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:96)
        at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:52)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:83)
        at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:54)
        at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:74)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:88)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:88)
        at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
        at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:46)
        at org.gradle.internal.execution.steps.LoadExecutionStateStep.execute(LoadExecutionStateStep.java:34)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:43)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$TaskExecution$3.withWorkspace(ExecuteActionsTaskExecuter.java:286)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:43)
        at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:33)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:40)
        at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:30)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:54)
        at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:40)
        at org.gradle.internal.execution.impl.DefaultExecutionEngine.execute(DefaultExecutionEngine.java:41)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:183)
        at java.util.Optional.orElseGet(Optional.java:267)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:183)
        at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:173)
        at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:109)
        at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
        at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:62)
        at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
        at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
        at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:200)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:195)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:75)
        at org.gradle.internal.operations.DefaultBuildOperationRunner$3.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:153)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:68)
        at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:62)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.lambda$call$2(DefaultBuildOperationExecutor.java:76)
        at org.gradle.internal.operations.UnmanagedBuildOperationWrapper.callWithUnmanagedSupport(UnmanagedBuildOperationWrapper.java:54)
        at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:76)
        at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
        at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:41)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:411)
        at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:398)
        

> Task :compileJava FAILED

Build.gradle 文件

buildscript {
    repositories {
        maven {
            url "https://plugins.gradle.org/m2/"
        }
    }
    dependencies {
        classpath 'org.hibernate:hibernate-gradle-plugin:5.6.0.Final'
    }
}

plugins {
    id 'java'
    id 'org.springframework.boot' version "${springBootVersion}"
    id 'io.spring.dependency-management' version "${springDependencyMgmt}"
    id 'org.hidetake.swagger.generator' version "${hideTakeSwaggerGen}"
    id 'java-library'
    id 'maven-publish'
    id 'groovy'
    id 'com.palantir.docker' version "${dockerPlugin}"
    id "org.sonarqube" version "3.3"
    id 'jacoco'
    id 'io.franzbecker.gradle-lombok' version '5.0.0'
    id 'com.ewerk.gradle.plugins.querydsl' version '1.0.10'
}

apply plugin: 'jacoco'
apply plugin: "application"
apply plugin: 'org.hibernate.orm'

group 'com.abcxyz'
version '1.1.5-SNAPSHOT'

sourceCompatibility = 1.8

springBoot {
    buildInfo()
}

bootJar {
    launchScript()
}
mainClassName = "com.abcxyz.items.ItemApplication"

loadConfiguration()

hibernate {
    sourceSets = [project.sourceSets.main]
    enhance {
        enableLazyInitialization = true
        enableDirtyTracking = true
    }
}
ext['mockito.version'] = '4.3.1'
ext['snakeyaml.version'] = '1.33'


def loadConfiguration() {
    def environment = hasProperty('env') ? env : 'local'
    println "Environment is set to $environment"

    def configFile = file('environment.groovy')
    def config = new ConfigSlurper(environment).parse(configFile.toURL())

    config.forEach { k, v ->
        project.ext[k] = v
    }
}

repositories {
    mavenLocal()
    mavenCentral()
    maven {
        url artifactory_build_url
        credentials {
            username System.env.CODEARTIFACT_USER
            password System.env.CODEARTIFACT_AUTH_TOKEN
        }
    }

    maven {
        url "https://packages.confluent.io/maven/"
    }
}

jacoco {
    toolVersion = "0.8.4"
    reportsDir = file("$buildDir/jacoco")
}

docker {
    name "items_ms"
    dockerfile file("Dockerfile-local")
    copySpec.from(jar).rename(".*", "items.jar")
    buildArgs(['JAR_FILE': "items.jar"])

}


sourceSets.main.java.srcDirs = ['src/main/java', 'build/generated/sources/annotationProcessor/java/main']
sourceSets {
    integration {
        groovy.srcDir "$projectDir/src/integrationTest/groovy"
        resources.srcDir "$projectDir/src/integrationTest/resources"
        compileClasspath += main.output + test.output
        runtimeClasspath += main.output + test.output
    }
}

configurations {
    integrationImplementation.extendsFrom testImplementation
    integrationRuntime.extendsFrom testRuntime
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${hoxton}"
    }
}

dependencies {

    // spring dependencies
    compile 'org.springframework.boot:spring-boot-starter-validation'
    compile 'org.springframework.boot:spring-boot-configuration-processor'
    compile 'org.springframework:spring-context-support'
    compile 'org.springframework.boot:spring-boot-starter-actuator'
    compile 'org.springframework.boot:spring-boot-starter-batch'
    compile('org.springframework.boot:spring-boot-starter-data-jpa') {
        exclude group: "org.hibernate", module: "hibernate-core"
    }
    // https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-jdbc
    implementation 'org.apache.tomcat:tomcat-jdbc:10.0.0'
    implementation "org.hibernate:hibernate-core:5.5.8.Final"
    compile 'org.springframework.boot:spring-boot-starter-security'
    compile 'org.springframework.boot:spring-boot-starter-web'

    implementation 'org.springframework.cloud:spring-cloud-context:3.1.7'
    implementation 'org.springframework.cloud:spring-cloud-commons:3.1.7'
    implementation 'org.springframework.cloud:spring-cloud-starter:3.1.7'
    // spring cloud dependencies
    compile ("org.springframework.cloud:spring-cloud-aws-context:2.2.6.RELEASE") {
        exclude group: "org.springframework.cloud", module: "spring-cloud-commons"
        exclude group: "org.springframework.cloud", module: "spring-cloud-context"
        exclude group: "org.springframework.cloud", module: "spring-cloud-starter"
    }
    compile 'org.springframework.cloud:spring-cloud-aws-messaging:2.2.6.RELEASE'

    // postgres
    compile 'org.postgresql:postgresql'

    
    // lombok dependencies
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    annotationProcessor "com.abcxyz.cb-ms-core:cb-ms-annotation-processor:${msCore}"

    // my dep
    annotationProcessor "javax.persistence:javax.persistence-api:${jpa}"
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'com.querydsl:querydsl-jpa:5.0.0'

    // other annotation processors
    annotationProcessor "com.querydsl:querydsl-apt:${queryDsl}"
    annotationProcessor "com.querydsl:querydsl-jpa:${queryDsl}:apt"


    // mapstruct dependencies
    compile "org.mapstruct:mapstruct:${mapstruct}"
    annotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct}"
    testCompile "org.mapstruct:mapstruct:${mapstruct}"
    testAnnotationProcessor "org.mapstruct:mapstruct-processor:${mapstruct}"

    // unit test dependencies
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation("org.spockframework:spock-core:${spockCore}") {
        exclude group: 'org.codehaus.groovy'
    }
    testImplementation "org.codehaus.groovy:groovy:${codehausGroovy}"
    testImplementation "org.spockframework:spock-spring:${spockCore}"
    testImplementation 'com.h2database:h2:2.2.222'
    testCompile "cglib:cglib-nodep:${cglibNodep}"
    testImplementation "org.mockito:mockito-inline"
    testImplementation 'com.tngtech.archunit:archunit:0.22.0'

    // flyway dependency
    compile "org.flywaydb:flyway-core:${flywayCore}"

    // swagger dependencies
    implementation "org.springdoc:springdoc-openapi-ui:${springDoc}"
    implementation "org.springdoc:springdoc-openapi-webmvc-core:${springDoc}"

    // other dependencies
    compile "javax.inject:javax.inject:${javaxInject}"
    compile "org.json:json:${orgJson}"
    compile "com.google.code.gson:gson:${gson}"
    //compile 'io.swagger.codegen.v3:swagger-codegen-cli:3.0.10'

    //slueth - log tracing dependency
    compile 'org.springframework.cloud:spring-cloud-starter-sleuth'

    //integration test dependencies
    integrationImplementation "org.testcontainers:spock:${testContainers}"
    integrationImplementation "org.testcontainers:postgresql:${testContainers}"
    integrationRuntime "org.codehaus.groovy:groovy-all:${codehausGroovy}"
    integrationImplementation("org.spockframework:spock-core:${spockCore}") {
        exclude group: 'org.codehaus.groovy'
    }
    integrationImplementation "org.spockframework:spock-spring:${spockCore}"
    integrationImplementation 'org.springframework.security:spring-security-test'
    integrationImplementation "org.testcontainers:localstack:${testContainers}"

    //security fix for https://blog.cloudflare.com/cve-2021-44228-log4j-rce-0-day-mitigation/
    implementation 'org.apache.logging.log4j:log4j-to-slf4j:2.16.0'
    implementation 'org.apache.logging.log4j:log4j-api:2.16.0'
    implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'

    //graphql dependencies
    implementation "org.springframework.boot:spring-boot-starter-graphql:${springBootVersion}"
    

}

def generatedClassesPath= "build/generated/sources/annotationProcessor/java/main"

querydsl {
    library = 'com.querydsl:querydsl-apt:5.0.0'
    jpa = true
    querydslSourcesDir = generatedClassesPath
}


configurations {
    querydsl.extendsFrom implementation, compileClasspath
}


compileQuerydsl {
    options.annotationProcessorPath = configurations.querydsl
}

project.afterEvaluate {
    project.tasks.compileQuerydsl.options.compilerArgs = [
            "-proc:only",
            "-processor", project.querydsl.processors() +
                    ',lombok.launch.AnnotationProcessorHider$AnnotationProcessor'
    ]
}


test.finalizedBy jacocoTestReport
check.dependsOn jacocoTestCoverageVerification

task genOperationsModels(type: JavaExec) {
    main = 'com.abcxyz.items.ApiModelGenerator'
    classpath = configurations.compile + configurations.compileOnly + files("${buildDir}/resources/main") + files("${buildDir}/classes/java/main")
    String resourceName = "public/resources/spec.yaml"
    String microServiceName = "plan ms"
    String outputPath = "${project.projectDir}"
    String generatorName = "cb-spring"
    String apiPackage = "com.abcxyz.items.api"
    String modelPackage = "com.abcxyz.items.api.model"
    String callableApis = "false"
    args += [microServiceName, resourceName, outputPath, generatorName, apiPackage, modelPackage, callableApis]
}
genOperationsModels.dependsOn build
java spring-boot gradle build.gradle annotation-processing
1个回答
0
投票

我通过在编译作业之前删除构建目录得到了解决方案,并且它有效

在编译任务中添加 doFirst 块

参考

compileJava {
    options.incremental = true
    
    
//    doFirst {
//        // force a clean of generatedSourceDir to prevent java.lang.IllegalStateException: endPosTable already set
//        project.delete(generatedSourceDir)
//        project.mkdir(generatedSourceDir)
//    }
}

参考 https://github.com/gradle/gradle/pull/4700#issuecomment-378711369

© www.soinside.com 2019 - 2024. All rights reserved.