Gradle plugin compatibility - how to find out? - gradle

Can Gradle plugins for 1.11+ be expected to work for 2.+, and if not, how can one find out the state of compatibility?
Specifically, I have had success using Gradle 1.11 in a project spring-boot project. When upgrading to Gradle 2.2, I noticed that the spring-boot plugin does not seem to be available, although I haven't found any references to a particular Gradle version in the Spring Boot Gradle documentation (http://docs.spring.io/autorepo/docs/spring-boot/1.2.0.BUILD-SNAPSHOT/reference/html/build-tool-plugins-gradle-plugin.html).
Using Gradle 2.2, I get:
* What went wrong:
A problem occurred evaluating root project 'NN'.
> Failed to apply plugin [id 'spring-boot']
> A problem occurred configuring project ':webapp'.
> Extension of type 'SpringBootPluginExtension' does not exist. Currently registered extension types: [DefaultExtraPropertiesExtension, DefaultArtifactPub
licationSet_Decorated, ReportingExtension_Decorated, DefaultProjectSourceSet_Decorated, DefaultBinaryContainer_Decorated]

It depends on the particular plugin, and would ideally be tested/documented there. 1.x to 2.x was a big jump in terms of the Groovy version used by Gradle, which can cause compatibility issues for plugins implemented in Groovy. Also, 1.x plugins using deprecated or internal APIs may not work in 2.x.

Related

gradle upgrade from 4 to gradle 6.0 - Replacing an existing task that may have already been used by other plugins is not supported

Failed to apply plugin [id 'com.github.jacobono.wsdl']
Could not create task ':party-request-v2-ws:war'.
> Replacing an existing task that may have already been used by other plugins is not supported. Use a different name for this task ('war').
I get the above error for a subproject. May I please have some suggestions as to how to deal with these kind of issues. do I need to replace com.github.jacobono.wsdl plugin?
According to this answer, Gradle prior to 5.1.0 supported replacing tasks. Gradle 5 deprecated this feature and Gradle 6 removed it. I'm afraid you cannot use the com.github.jacobono.wsdl plugin with Gradle 6.

Alternatives to the Gradle Gretty Plugin

I’m trying to upgrade some old code that used the Jetty plugin in Gradle. I would like to upgrade the Gradle version beyond Gradle v3.5, but Gradle v4.0 and above has the Jetty plugin removed. Unfortunately, we are now required to use Gretty.
I’m using IntelliJ. My problems with the newer Gretty plugin are:
JVM Args and System properties specified on the commandline have to be manually put into the Gretty configuration.
At least in IntelliJ, I could do out of the box debugging with the Jetty plugin, but need to run two executions including the app and the Remote, and use a different Gradle task for debugging (e.g. jettyRunDebug) with Gretty.
What are the alternatives to Gretty? Anything that can substitute for the old Jetty plugin.
How about just skipping the Gretty plugin entirely and just using Unit testing?
See: https://stackoverflow.com/a/29759263/775715

Adding org.apache.kafka to dependencies with Gradle

I started a Gradle project with gradle init --type java-application using Kotlin as the build script DSL, and I just wanted to add org.apache.kafka library
dependencies {
// This dependency is used by the application.
implementation("com.google.guava:guava:28.0-jre")
implementation("org.apache.kafka:kafka_2.10:0.8.0")
// Use JUnit test framework
testImplementation("junit:junit:4.12")
}
But gradle build returned this:
* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find jmxtools.jar (com.sun.jdmk:jmxtools:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.jar
> Could not find jmxri.jar (com.sun.jmx:jmxri:1.2.1).
Searched in the following locations:
https://jcenter.bintray.com/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.jar
What's this about? Conflicts with JCenter?
As already mentioned in the comments upgrading the kafka version will solve the problem (probs go to #cricket_007).
The root cause for that problem is actually not kafka itself but it's transitive dependency log4j in a version 1.2.15. This log4j version requires jmxtools and jmxri. Due to some licensing issues these artifacts are NOT available on maven central and jcenter. The good news is: You most likely don't need it at all. You simply override the log4j dependency to use 1.2.16 (or above) or exclude jmxtools and jmxri.
You can also find some more insights in this blog article: http://unitstep.net/blog/2009/05/18/resolving-log4j-1215-dependency-problems-in-maven-using-exclusions/
So 3 ways to solve this issue:
use a more recent kafka-version OR
use a log4j version > 1.2.15 OR
exclude jmxtools and jmxri
Hope that helps and make things more clear

"unable to resolve class" error after upgrading gradle 3 to gradle 4

Grails version: 3.2.9
Gradle initial version: 3.4.1 (everything works fine with this version)
Gradle upgraded version:4.10.3
Plugin: org.grails.grails-gsp
When I run gradlew war after upgrading gradle version to 4.10.3 I start to get the following error during execution of compileGroovyPages task:
dashboard_gsp.groovy: 2: unable to resolve class com.abnd.CarStatusEnum
# line 2, column 1.
import com.abnd.CarStatusEnum
^
Location of class com.abnd.CarStatusEnum is src/main/groovy/com/abnd/CarStatusEnum in the same project where the build is being run and gradlew war task completes successfully with gradle version 3.4.1. However when I upgrade gradle version to 4.10.3 then I start to get this error. Same happens with gradle version 4.1.
1) Any clue what can be the problem ?
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with grails version 3.x.x as with gradle 5.x.x I start to get even more issues as some grails plugins(like grails-gsp v3.3.2 which is latest stable version) use some features that have been deprecated in gradle 4.x.x and removed from gradle 5.x.x (see the error bellow)?
Failed to apply plugin [id 'org.grails.grails-gsp']
Could not get unknown property 'classesDir' for main classes of type org.gradle.api.internal.tasks.DefaultSourceSetOutput.
1) Any clue what can be the problem ?
Yes. The error message is a clue that the GSP compiler can't find the enum class. This is because our plugin isn't compatible with Gradle 4.10.3.
2) Is that a good idea to use gradle version 4.x.x or 5.x.x with
grails version 3.x.x
No. Those Gradle versions are not supported with the version of Grails you are using.
I hope that helps.

pom error - org.apache.maven.archiver.MavenArchiver.getManifes

I am getting error in pom file - org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.MavenProject, org.apache.maven.archiver.MavenArchiveConfiguration)
in my pom i am using maven-war-plugin 3.0.0 , IDE- STS , java 7
encountered the same issue after updating the maven-jar-plugin to its latest version (at the time of writing), 3.0.2.
Eclipse 4.5.2 started flagging the pom.xml file with the org.apache.maven.archiver.MavenArchiver.getManifest error and a Maven > Update Project.. would not fix it.
Easy solution: downgrade to 2.6 version
Indeed a possible solution is to get back to version 2.6, a further update of the project would then remove any error. However, that's not the ideal scenario and a better solution is possible: update the m2e extensions (Eclipse Maven integration).
Better solution: update Eclipse m2e extensions
From Help > Install New Software.., add a new repository (via the Add.. option), pointing to any of the following URLs:
https://otto.takari.io/content/sites/m2e.extras/m2eclipse-mavenarchiver/0.17.2/N/LATEST/ or
http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
Then follow the update wizard as usual. Eclipse would then require a restart. Afterwards, a further Update Project.. on the concerned Maven project would remove any error and your Maven build could then enjoy the benefit of the latest maven-jar-plugin version.
Additonal notes
The reason for this issue is that from version 3.0.0 on, the concerned component, the maven-archiver and the related plexus-archiver has been upgraded to newer versions, breaking internal usages (via reflections) of the m2e integration in Eclipse. The only solution is then to properly update Eclipse, as described above.
Also note: while Eclipse would initially report errors, the Maven build (e.g. from command line) would keep on working perfectly, this issue is only related to the Eclipse-Maven integration, that is, to the IDE.
Upgrade your m2e extensions instead downgrade.
(In Eclipse IDE) From Help > Install New Software.., add a new repository (via the Add.. option)
Specify name for your plugin and add path http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-mavenarchiver/0.17.2/N/LATEST/
once you are done with installation, please restart eclipse and update your project.

Resources