我使用的是JDK 17(temurin-17.jdk),所以我需要使用gradle版本7〉(我使用的是https://services.gradle.org/distributions/gradle-7.4.2-bin.zip);
当我尝试构建我的项目时,我得到以下错误:
**
任务:compileJava注意:某些输入文件使用未经检查或不安全的操作。使用-Xlint:unchecked重新编译以获取详细信息。
任务:bootJar失败
失败:生成失败,出现异常。
出了什么问题:在任务“:bootJar”(类型“BootJar”)的配置中发现问题。在插件“org.springframework.boot”中,“type”org.springframework.boot.gradle.tasks.bundling.BootJar”属性“bootInf”缺少输入或输出注解。
原因:在最新检查期间不考虑没有注解的属性。
可能的解决办法:
添加输入或输出注解。将其标记为@internal。https://docs.gradle.org/7.4.2/userguide/validation_problems.html#missing_annotation有关此问题的详细信息,请参阅www.example.com。
**
我的build.gradle看起来像这样:
buildscript {
repositories {
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
mavenCentral()
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE")
classpath("net.researchgate:gradle-release:2.8.1")
classpath("com.bmuschko:gradle-docker-plugin:3.1.0")
classpath("gradle.plugin.org.hidetake:gradle-swagger-generator-plugin:2.18.1")
}
}
//Technically any privileged credentials will work, but intended to be the service account
def service_username = System.getenv('SERVICE_USERNAME')
def service_password = System.getenv('SERVICE_PASSWORD')
def configDir = "$project.projectDir/config"
repositories {
mavenLocal()
maven { url "https://ci1.mycwt.com/nexus/repository/Development_Artifacts/" }
mavenCentral()
maven { url "https://plugins.gradle.org/m2/" }
jcenter()
}
group = 'com.somethingSomething'
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'idea'
apply plugin: 'pmd'
apply plugin: 'checkstyle'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'net.researchgate.release'
apply plugin: 'org.hidetake.swagger.generator'
bootRun {
jvmArgs '-javaagent:AppServerAgent-1.8-20.8.0.30686/ver20.8.0.30686/javaagent.jar'
}
test{
jvmArgs '-javaagent:AppServerAgent-1.8-20.8.0.30686/ver20.8.0.30686/javaagent.jar'
}
/**
* PMD Configurations
*/
pmd {
toolVersion = '6.22.0'
ruleSetFiles = files('config/cwtRuleSet.xml')
ruleSets = []
ignoreFailures = false
pmdTest.enabled = false
}
tasks.withType(Pmd) {
reports {
xml.enabled = true
html.enabled = true
}
}
/**
* Jacoco Configurations
*/
jacoco {
toolVersion = "0.8.7"
}
jacocoTestCoverageVerification{
violationRules {
rule {
limit {
minimum = 0.93
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: ['**/com/somethingSomething/config/**',
'**/com/somethingSomething//nextgen/config/**',
'**/com/somethingSomething/model/**',
'**/com/somethingSomething/*Application*',
'**/com/somethingSomething//nextgen/web/**',
'**/com/somethingSomething/preferencing/service/Invalid*'])
}))
}
}
}
jacocoTestReport {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, excludes: ['**/com/somethingSomething/config/**',
'**/com/somethingSomething//nextgen/config/**',
'**/com/somethingSomething/model/**',
'**/com/somethingSomething/*Application*',
'**/com/somethingSomething//nextgen/web/**',
'**/com/somethingSomething/preferencing/service/Invalid*'])
}))
}
}
build.dependsOn jacocoTestCoverageVerification
build.dependsOn jacocoTestReport
jacocoTestCoverageVerification.shouldRunAfter jacocoTestReport
/**
* Checkstyle Configurations
*/
checkstyle {
toolVersion = 8.30
ignoreFailures = false
maxErrors = 0
maxWarnings = 5 //There are known issues with lambdas and line wraps not being evaluated correctly in checkstyle
configFile = project(':').file("$configDir/checkstyle/checkstyle.xml")
configProperties = ['suppressionFile': project(':').file("$configDir/checkstyle/suppressions.xml")]
}
task generateJavaDocs(type: Javadoc) {
source = sourceSets.main.allJava
failOnError = false
title= "Service"
}
release {
afterReleaseBuild.dependsOn publish
}
publish {
dependsOn build
repositories {
maven {
{
url= nexusReleaseURL
credentials {
username = service_username
password = service_password
}
}
{
url= nexusSnapshotURL
credentials {
username = service_username
password = service_password
}
}
}
}
}
bootJar {
baseName = "${jarBaseName}"
enabled = true
//classifier = "${grgit.head().id}"
}
springBoot {
mainClassName = "com.somethingSomething.ServiceApplication"
buildInfo()
}
sourceCompatibility = 17
targetCompatibility = 17
dependencyManagement {
imports {
mavenBom 'com.amazonaws:aws-java-sdk-bom:1.11.1034'
}
}
task bootRunWithLocalProfile {
description 'This runs the application with the local profile activated, which uses local redis, logs to ' +
'the console, and disables AppDynamics.'
doFirst {
bootRun.configure {
systemProperty 'spring.profiles.active', 'local'
}
}
group 'application'
finalizedBy bootRun
}
task bootRunWithMockDataSources {
description 'This runs the application with the local and mockdata profiles activated, which uses local redis, ' +
'logs to the console, disables AppDynamics, and replaces select external integrations with mock ' +
'services from mock-services'
doFirst {
println 'Make sure you have the appropriate mock-services running, or the server ' +
'won\'t function properly...'
bootRun.configure {
systemProperty 'spring.profiles.active', 'local,mockdata'
}
}
group 'application'
finalizedBy bootRun
}
dependencies {
implementation('com.amazonaws:aws-java-sdk-translate')
implementation("org.springframework.boot:spring-boot-gradle-plugin:2.1.1.RELEASE")
implementation("com.somethingSomething:commons:1.0-SNAPSHOT")
// implementation("com.google.protobuf:protobuf-gradle-plugin:0.8.18")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-json")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.data:spring-data-redis")
implementation("org.aspectj:aspectjweaver:1.8.8")
implementation("org.apache.sis.core:sis-referencing:0.7")
implementation("com.cwt.eit.springboot.utils:load-balancer-control:1.0.8")
implementation("org.jblas:jblas:1.2.4");
compileOnly('org.projectlombok:lombok:1.18.20')
annotationProcessor('org.projectlombok:lombok:1.18.20')
implementation('org.apache.commons:commons-lang3:3.4')
implementation('io.dropwizard.metrics:metrics-core')
implementation('com.ryantenney.metrics:metrics-spring:3.1.3')
implementation('com.appdynamics.agent:agent-api:4.5.18.29239')
implementation("org.apache.commons:commons-collections4:4.2")
implementation("org.apache.commons:commons-pool2:2.6.0")
implementation("org.json:json:20180813")
implementation('com.cwt.dna:amenity-parser:2.3.16')
implementation('javax.xml.bind:jaxb-api:2.3.1')
implementation('org.glassfish.jaxb:jaxb-runtime:2.3.1')
implementation('org.glassfish.metro:webservices-rt:2.4.4')
implementation('org.glassfish.metro:webservices-api:2.4.4')
implementation('com.cwt.bpg.services.common:security-jwt:3.11.0'){
exclude(group: 'org.apache.camel')
exclude(group: 'org.springframework')
}
implementation('com.cwt.bpg.services.common:security-model:3.11.0'){
exclude(group: 'org.apache.camel')
exclude(group: 'org.springframework')
}
testImplementation("org.powermock:powermock-classloading-xstream:1.7.4")
testImplementation('junit:junit:4.12')
testImplementation('org.mockito:mockito-core:4.0.0')
testImplementation('net.bytebuddy:byte-buddy:1.11.21')
testImplementation('com.appdynamics.agent:agent-api:4.5.18.29239')
testImplementation('commons-io:commons-io:2.6')
testImplementation("org.springframework.boot:spring-boot-starter-test:2.1.1.RELEASE")
testImplementation("org.projectlombok:lombok:1.16.16")
swaggerUI 'org.webjars:swagger-ui:3.23.0'
}
swaggerSources {
swagger {
inputFile = file('swagger.yaml')
}
}
谢谢你调查这件事。
我希望该项目能够成功地构建和运行。
1条答案
按热度按时间0sgqnhkj1#
看看upgrade guide from Gradle。你有很多东西需要在你的构建中改变。例如,
compileOnly
被弃用,你的一些插件也是如此。这都在链接指南中概述,以及修复它的步骤。