Deprecation warning gradle 8.4 with filter and shadowJar

The following build.gradle snippet has been working fine with gradle 7.x:

import org.apache.tools.ant.filters.*;

task installScript(type: Copy) {
	from "../templates/java-program-wrapper.sh"
	into "$installDir/bin/"
	rename ('java-program-wrapper.sh', "$programName")
	fileMode 0755

	filter(FixCrLfFilter.class,
		eol:FixCrLfFilter.CrLf.newInstance("lf"))

	// Replace each token of form "@token" with the given value
	filter(ReplaceTokens, tokens:
  	       [
		jarName: shadowJar.archiveFileName.get(),
	    javaMajorVersion: javaRunVersion,
	    //javaMajorVersion: sourceCompatibility.toString(),
		installDir: installDir
		])
}

Now with gradle 8.4 I get:

The Project.getConvention() method has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#deprecated_access_to_conventions        
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#deprecated_access_to_conventions
The org.gradle.util.ConfigureUtil type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#org_gradle_util_reports_deprecations
        at build_8guu4is3ogchpeu8ynwwr05lr$_run_closure5.doCall$original(C:\Users\mcooper\ws\cmb\7.2\CmbProduct\ChangeLogBuilder\build.gradle:76)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#java_convention_deprecation
        at build_8guu4is3ogchpeu8ynwwr05lr$_run_closure5.doCall$original(C:\Users\mcooper\ws\cmb\7.2\CmbProduct\ChangeLogBuilder\build.gradle:76)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

The line 76 corresponds to:
jarName: shadowJar.archiveFileName.get(),

I can’t seem to figure out what exactly is the problem here. I’ve read over the URL’s it outputs but still can’t seem to nail it down.

Would appreciate some help on this.

mike

If you use --stacktrace you get a full stacktrace for each warning.

I’ve looked at the --stacktrace and it doesn’t really help me much. I’ve attached it in case you have a moment to have a look.

These warnings are about #deprecated_access_to_conventions and as such are a bit generic to those of us not deeply intimate with gradle.

stacktrace.zip (24.4 KB)

What the warning is about is not so relevant at first.
The first thing to look for is who the culprit is and for that the stacktrace is helpful.
You see in the stacktrace that the first non-Gradle class is a class from the shadow plugin, so this is an incompatibility of that plugin with newer Gradle versions which you cannot do something about yourself except for reporting to that plugin’s maintainer and updating if there is a new version that is compatible. Until then you have to live with the warnings or downgrade Gradle.

But it also is not only the shadow plugin, but also the vaadin plugin for example.

Just look through your stacktraces and report to the according plugins if not reported yet.

Ahh. That makes sense! Thanks for that!

1 Like