bootRepackage classifier is not working when upgrade to gradle 6.6.1 (also gralde 5) - spring-boot

Our project still worked well in gradle 4.10.2 (Spring boot 1.5.22), but when i have upgraded gradle to 6.6.1 it thrown exception
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':my-app'.
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener
Caused by: java.lang.NoSuchMethodError: org.gradle.api.tasks.TaskInputs.file(Ljava/lang/Object;)Lorg/gradle/api/tasks/TaskInputs;
at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.setupInputOutputs(RepackagePluginFeatures.java:150)
at org.springframework.boot.gradle.repackage.RepackagePluginFeatures$RegisterInputsOutputsAction.execute(RepackagePluginFeatures.java:136)
I have tried with gradle 5 it still happend.
This is my gradle.build bootRepackage section, when i removed classifier = "boot" it work without classifier feature
bootRepackage {
enabled = true
classifier = "boot"
doLast{
//some tasks
}
}
Why could this be?

Gradle 5 has removed a method that Spring Boot 1.5’s Gradle plugin requires. Spring Boot 1.5 supports Gradle 2.x or 3.x so it isn’t surprising that it does not work with Gradle 5.
If you want to use a more up-to-date version of Gradle, you’ll have to upgrade to a more up-to-date version of Spring Boot as well. At the time of writing 2.3.x is the oldest generation of Spring Boot that is still supported.

Related

Gradle: Could not resolve all files for configuration ':compileClasspath'

Gradle build is throwing the following error
What went wrong:
Execution failed for task ':compileJava'.
Could not resolve all files for configuration ':compileClasspath'.
Could not find com.oracle:ons:19.3.
Required by:
project :
project : > com.xyz.abc.utils:openshift-utils:2.0.30
I have added the below dependency
implementation('com.oracle:ons:19.3')
Also the below repository
mavenCentral()
maven { url 'http://repository.xyz.com:8081/artifactory/gradle-plugins'; allowInsecureProtocol true
metadataSources {
mavenPom()
artifact()
}
}
I can see this dependency under Project and External Dependencies
The project that is needing this dependency has the below line in build.gradle
compile("com.oracle:ons:19.3")
I'm using gradle wrapper and gradle version is 7.4.2
Can you please help in resolving this error?
I was also facing similar issue. This resolved for me when I used a compatible spring boot version for particular JAVA version you are using in your project.I was getting similar issue-
For example - version 3.0.0 is not compatible with JAVA 11
But when I used version 3.0.0 with JAVA 17 and rebuild the project, it was resolved

Usage of BootJar instead of BootRepackage in Gradle as part of Spring Boot Migration from 1..5.x to 2.x

I am working on Spring Boot migration from 1.5.12 to 2.1.14. We are using Gradle as a build tool, so as part of Spring Boot migration we had to change
Gradle from 3.x to 4.x and trying to update the build.gradle as required. In Spring Boot 2.x migration we have to change the following task in build.gradle
task msnServiceBoot(type: BootRepackage, dependsOn:msnJar) {
println " Executing MsnServiceBoot task"
mainClassName = 'com.msn.service.MsnApplication'
customConfiguration = "cloudconfigexclusion"
withJarTask = msnJar
}
In the above code we have to update BootRepackage to BootJar as per the latest Spring documentation.
The error, I'm getting after changing from BootRepackage to BootJar is customConfiguration is unknown property.
May I know how to make customConfiguration for Spring Boot 2.x with gradle 4.x

Spring boot gradle project with kotlin setup issue

Hello i want to create a Spring boot app with kotlin and Gradle but i have this issue in the plugins line, it doens't recognize any plugin i add ,i couldn't undrestand what's missing, i'm using Gradle 6.3v , jdk 8
Error:
Error
And that's the build.gradle file
build.gradle.kts
Your first plugin declaration has a typo in the version:
kotlin("jvm") version "1.3.11" needs to be kotlin("jvm") version "1.3.71"
I would start by changing that so all usages of kotlin plugins are aligned on a recent version.
If that does not resolve the problem, try running the build from the CLI with the added flag --stacktrace which may tell you more about why is the plugin not found.

How to use JPA metamodel with gradle, intellij IDEA?

I am using java 8, spring boot 2.0.0, spring-data-jpa(spring-boot-starter-data-jpa), gradle, intellij. I've been trying to use JPA Metamodel, but having difficulty on finding how to configure.
Metamodels for Entity classes aren't just generated.
I guessed it would be simple, but now it seems that can be wrong. How can I use it?
JDK11 / Gradle 5.0 / Hibernate 5.3.7.Final
sourceSets.main.java.srcDirs += "${buildDir}/generated"
compileJava {
options.annotationProcessorGeneratedSourcesDirectory = file("${buildDir}/generated")
}
dependencies {
annotationProcessor("javax.xml.bind:jaxb-api")
annotationProcessor("org.hibernate:hibernate-jpamodelgen")
}
Generated Metamodel classes will be generated at 'build/generated'
If you are using JDK8 or Hibernate 5.4+, annotationProcessor("javax.xml.bind:jaxb-api") may unnecessary.
I did this the other day using the scalified metamodel gradle plugin (https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.metamodel). I'm using Spring Boot 2.0.5, but I don't see why it wouldn't work the same with Spring Boot 2.0.0. I'm using Gradle 4.8.1 as well.
Below is an excerpt of my build.gradle.
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath (
"org.springframework.boot:spring-boot-gradle-plugin:2.0.0",
"gradle.plugin.com.scalified.plugins.gradle:metamodel:0.0.1");
}
}
apply plugin: "com.scalified.plugins.gradle.metamodel"
// The plugin will default to the latest version of Hibernate if this is not specified
metamodel {
hibernateVersion = '5.2.14.Final' // For Spring Boot 2.0.0
hibernateVersion = '5.2.17.Final' // For Spring Boot 2.0.5
}
This builds the metamodal files under src/generated and they can be used in your code. I had to also change an IntelliJ setting because IntelliJ's Build Automatically excludes some Gradle tasks that could be long running. See Automatically run Gradle task in project build with IntelliJ IDEA and https://youtrack.jetbrains.com/issue/IDEA-175165 for more details.
This setting I changed to overcome this is: Preferences->Build/Execution/Deployment->Gradle->Runner->Delegate IDE build/run actions to Gradle. An alternative would be to run the metamodelCompile gradle task manually as needed. That would lessen the time to rebuild by a little if you aren't frequently change your entities.

Cannot get Spring Boot's buildInfo() to work when Artifactory Gradle plugin is used

Gradle: 2.13
Boot: 1.3.5
Artifactory Gradle Plugin (org.jfrog.buildinfo:build-info-extractor-gradle): 4.5.0
This project has been building for for some time. However, now I'm trying to get some additional build information to display via the /info endpoint so, per the docs, I added:
springBoot {
buildInfo()
}
Now there seems to be some sort of conflict with the Artifactory Gradle plugin:
Caused by: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.jfrog.gradle.plugin.artifactory.dsl.DoubleDelegateWrapper(org.jfrog.build.extractor.clientConfiguration.ArtifactoryClientConfiguration$BuildInfoHandler)
at org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention.buildInfo(ArtifactoryPluginConvention.groovy:64)
at org.jfrog.gradle.plugin.artifactory.dsl.ArtifactoryPluginConvention.invokeMethod(ArtifactoryPluginConvention.groovy)
at org.gradle.api.internal.BeanDynamicObject$GroovyObjectAdapter.invokeMethod(BeanDynamicObject.java:279)
at org.gradle.api.internal.BeanDynamicObject.invokeMethod(BeanDynamicObject.java:130)
at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:212)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:150)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_do1tse3u3lgd8dbntr9ir9lk6$_run_closure5.doCall(/Users/jbisotti/sandbox/fusion/fusion-eureka-service/build.gradle:76)
at org.gradle.api.internal.ClosureBackedAction.execute(ClosureBackedAction.java:67)
at org.gradle.api.internal.plugins.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:145)
at org.gradle.api.internal.plugins.ExtensionsStorage.configureExtension(ExtensionsStorage.java:69)
at org.gradle.api.internal.plugins.DefaultConvention$ExtensionsDynamicObject.invokeMethod(DefaultConvention.java:207)
at org.gradle.api.internal.CompositeDynamicObject.invokeMethod(CompositeDynamicObject.java:150)
at org.gradle.groovy.scripts.BasicScript.methodMissing(BasicScript.java:79)
at build_do1tse3u3lgd8dbntr9ir9lk6.run(/Users/jbisotti/sandbox/fusion/fusion-eureka-service/build.gradle:75)
at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
... 50 more
I'm not sure which of the three suspects are at fault, nor how to fix it. Any help would be greatly appreciated!
Turns out buildInfo() was not added until Spring Boot 1.4.0. D'oh!

Resources