gradle/gradle · error · UnsupportedOperationException

Cannot convert relative path %s to an absolute file.

Error message

Cannot convert relative path %s to an absolute file.

What it means

Gradle throws this error when the following condition is violated: Cannot convert relative path <value> to an absolute file.

Source

Thrown at platforms/core-configuration/file-collections/src/main/java/org/gradle/api/internal/file/IdentityFileResolver.java:30

 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gradle.api.internal.file;

import java.io.File;

/**
 * FileResolver that uses the file provided to it or constructs one from the toString of the provided object. Used in cases where a FileResolver is needed by the infrastructure, but no base directory
 * can be known.
 *
 * NOTE: Do not create instances of this type. Instead, use the {@link FileLookup} service.
 */
public class IdentityFileResolver extends AbstractFileResolver {
    @Override
    protected File doResolve(File path) {
        if (!path.isAbsolute()) {
            throw new UnsupportedOperationException(String.format("Cannot convert relative path %s to an absolute file.", path));
        }
        return path;
    }

    @Override
    public String resolveAsRelativePath(Object path) {
        throw new UnsupportedOperationException(String.format("Cannot convert path %s to a relative path.", path));
    }

    @Override
    public boolean canResolveRelativePath() {
        return false;
    }
}

View on GitHub (pinned to 534f27719b)

Solutions

  1. Use a value whose type matches the property type.
  2. Convert the value explicitly (e.g. via map()) before assigning it to the property.

When it happens

Trigger: Thrown at platforms/core-configuration/file-collections/src/main/java/org/gradle/api/internal/file/IdentityFileResolver.java:30 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of gradle/gradle@534f27719b (2026-08-22). Data as JSON: /api/errors/72a131046a8ee6ad. Report an issue: GitHub.