I develop a Gradle plugin that has a task extending AbstractArchiveTask. The target archive (Ruby’s gem) has a little bit different version scheme, then I wanted to rewrite archiveVersion, then archiveFileName and archiveFile accordingly.
What is the best way to do that?
I tried to set convention in the task’s constructor, but it didn’t work at all. (The convention Provider was never called.)
class Gem extends AbstractArchiveTask {
@Inject
public Gem() {
super();
this.getArchiveVersion().convention(this.getProject().provider(() -> {
return buildRubyStyleVersionFromJavaStyleVersion(this.getProject().getVersion().toString());
}));
I then tried to directly set in createCopyAction. It worked for archiveVersion, but archiveFile did not follow the updated archiveVersion.
@Override
protected CopyAction createCopyAction() {
this.getArchiveVersion().set(...)
I’ll finally want to update archiveFile in the plugin. How can I do that?