Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle 7.2 Tar task baseName deprecated but replacement archiveBaseName is rejected

Tags:

gradle

I have started using Gradle 7.2 to build a project that produces a compressed Tar archive. Gradle is issuing a deprecation warning that baseName is deprecated and should be replaced with archiveBaseName. But it rejects archiveBaseName.

A very much simplified example using a trivial Gradle build script, with their associated execution outputs are given below. I did run 'gradle --stop' to ensure a prior version's daemon wasn't actually executing; a GRADLE_HOME environment variable is pointing to the correct Gradle folder (not sure it's needed, but it is set.)

I tried using "archiveBaseName" both without and with "=" ("archiveBaseName 'Test'" and "archiveBaseName='Test'").

The docs seem to suggest archiveBaseName should already be available, so I don't think it's just a heads up of things to come.

Thank you!

Gradle file:

task dist(type: Tar) {
  baseName 'Test'
  into ('.') { from('.') }
}

Execution:

gradle build --warning-mode=all
c:\jdev\newpaas\xxx>gradle build --warning-mode all

> Configure project :
The AbstractArchiveTask.baseName property has been deprecated. This is scheduled to be removed in Gradle 8.0. Please use the archiveBaseName property instead. See https://docs.gradle.org/7.2/dsl/org.gradle.api.tasks.bundling.AbstractArchiveTask.html#org.gradle.api.tasks.bundling.AbstractArchiveTask:baseName for more details.
        at build_2qa2gx0itzunotwyc4ndf9v86$_run_closure1.doCall(C:\jdev\newpaas\xxx\build.gradle:2)
        (Run with --stacktrace to get the full stack trace of this deprecation warning.)

> Task :buildEnvironment

------------------------------------------------------------
Root project 'TestProject'
------------------------------------------------------------

classpath
No dependencies

A web-based, searchable dependency report is available by adding the --scan option.

BUILD SUCCESSFUL in 983ms
1 actionable task: 1 executed

Gradle file:

task dist(type: Tar) {
  archiveBaseName 'Test'
  into ('.') { from('.') }
}

Execution:

c:\jdev\newpaas\xxx>gradle build --warning-mode all

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\jdev\newpaas\xxx\build.gradle' line: 2

* What went wrong:
A problem occurred evaluating root project 'TestProject'.
> Could not find method archiveBaseName() for arguments [Test] on task ':dist' of type org.gradle.api.tasks.bundling.Tar.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s

Gradle file:

task dist(type: Tar) {
  archiveBaseName='Test'
  into ('.') { from('.') }
}

Execution:

c:\jdev\newpaas\xxx>gradle dist
> Task :dist FAILED

FAILURE: Build failed with an exception.

* What went wrong:
A problem was found with the configuration of task ':dist' (type 'Tar').
  - Type 'org.gradle.api.tasks.bundling.Tar' property 'archiveFile' doesn't have a configured value.

    Reason: This property isn't marked as optional and no value has been configured.

    Possible solutions:
      1. Assign a value to 'archiveFile'.
      2. Mark property 'archiveFile' as optional.

    Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#value_not_set for more details about this problem.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
1 actionable task: 1 executed
like image 734
John Elion Avatar asked Nov 19 '25 12:11

John Elion


1 Answers

The following syntax worked for me:

task dist(type: Tar) {
  archiveBaseName="Test"
  destinationDirectory=buildDir
  into ('.') { from('.') { include 'build.gradle' } }
}

It didn't like the into/from without the include (in my empty test project folder).

DestinationDir seems to be required with archiveBaseName. I find this surprising because DestinationDirectory claims to have a default, but this example works and without DestinationDirectory, the example still does not work, re-tried in Gradle 7.2, 7.6, and 8.0.2.

This may be related: https://github.com/marklogic/ml-gradle/issues/545 .

like image 137
John Elion Avatar answered Nov 21 '25 03:11

John Elion



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!