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

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.

Related

Gradle 6.8 to 7 version update in a spring-boot application

d:\myProject>gradlew build --warning-mode all
> Task :compileJava UP-TO-DATE
Property 'options.compilerArgumentProviders.apt$0.name' is not annotated with an input or
output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.
See https://docs.gradle.org/6.8/userguide/more_about_tasks.html#sec:up_to_date_checks
for more details.
Property 'options.compilerArgumentProviders.apt$0.publicType' is not annotated with an
input or output annotation. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0.
See https://docs.gradle.org/6.8/userguide/more_about_tasks.html#sec:up_to_date_checks
for more details.
I have tried removing the generic plugin (id "net.ltgt.apt") and the IntelliJ (id "net.ltgt.apt-idea") plugin as suggested by #Bjørn Vester(https://www.linkedin.com/in/bjornvester/), but the code is giving same error.
I am trying to update gradle from 6.8 to 7.5 version.
Can anyone help?
First things first,
As #Bjørn Vester said you need to remove the the below lines from build.gradle
id "net.ltgt.apt-eclipse" version "0.21"
id "net.ltgt.apt-idea" version "0.21"
id "net.ltgt.apt" version "0.21"
and add eclipse support by adding below line,
id "com.diffplug.eclipse.apt" version "3.36.2"
and also update the version of
id "com.diffplug.eclipse.apt" to latest.
As on the date of writing this answer the version was 3.36.2

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

Error: DefaultOperationDescriptor#2b878eea already available in Android Studio

Failed to complete Gradle Execution
When I try to Sync Gradle with Project Files, the error mentioned below appears
Android Studio version that I am using is 3.0.1, Gradle Build 4.1-all.zip
FYI, I have already tried ->Build->Clean Project and Invalidate Cache & Restart and one more thing is that there is no error in my code.
Message Error:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
Error:Failed to complete Gradle execution.
Cause:
Operation org.gradle.tooling.internal.provider.events.DefaultOperationDescriptor#86028ba already available.
BUILD SUCCESSFUL in 8s
Information:1 error
Information:0 warnings
But When I try to Run on my Emulator
The error below appears
Message Error At Run Time
Information:Gradle tasks [:app:assembleDebug]
E:\Android Game App\app\build.gradle
Error:(1, 1) A problem occurred evaluating project ':Android Game App:app'.
Failed to apply plugin [id 'com.android.application']
Due to a limitation of Gradle new variant-aware dependency management, loading the Android Gradle plugin in different class loaders leads to a build error.
This can occur when the buildscript classpaths that contain the Android Gradle plugin in sub-projects, or included projects in the case of composite builds, are set differently.
To resolve this issue, add the Android Gradle plugin to only the buildscript classpath of the top-level build.gradle file.
In the case of composite builds, also make sure the build script classpaths that contain the Android Gradle plugin are identical across the main and included projects.
If you are using a version of Gradle that has fixed the issue, you can disable this check by setting android.enableBuildScriptClasspathCheck=false in the gradle.properties file.
To learn more about this issue, go to https://d.android.com/r/tools/buildscript-classpath-check.html.
Information:BUILD FAILED in 16s
Information:1 error
Information:0 warnings
Information:See complete output in console
Nothing found on Google! Any help would be highly encouraged???
The key to the problem is this line. Maybe due to a project.all in root build.gradle or you are using composite builds.
This can occur when the build script classpaths that contain the Android Gradle plugin in sub-projects,
or included projects in the case of composite builds, are set differently.
that mean in all yours build.gradle you have more than one this line
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:x.y.z"
}
}
what this means is that with the introduction of Android Gradle Plugin 3.Y.Z and the new way of handling dependencies,
if you mix in the same project 2 projects with different plugin version (one with a 2.3 and other with 3.0.1) you will get dragons while compiling.
And this error it's a way to force developer to check it and opt-out once detected and solved.
how to solve it, first ensure you don't use a android gradle plugin below 3.0.1 and use the new dependencies configurations, and add this property on every gradle.properties you have.
android.enableBuildScriptClasspathCheck=false
with that you can now compile
one example could be found at realm sample repo they use a allprojects block that include android gradle plugin on every module. and solve it adding previus gradle property at root gradle.properties

Difference between gradle upload and gradle publish

I am testing pushing my artifacts to a Nexus maven repository. I am using gradle to do so.
What is the difference between gradle upload and gradle publish?
Currently gradle provides two publishing mechanisms. Original - shipped with java plugin - is described here and is based on a task of type Upload. This mechanism is going to be replaced by the - currently incubating - second mechanism that is separated from java plugin and also splitted into maven and ivy. This new mechanism is described here.
Also have a look at "Upgrading your build from Gradle 6.x to the latest": "Removal of the uploadArchives task: The uploadArchives task was used in combination with the legacy Ivy or Maven publishing mechanisms. It has been removed in Gradle 7. You should migrate to the maven-publish or ivy-publish plugin instead."

Gradle plugin compatibility - how to find out?

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.

Resources