diff --git a/lib/modules/manager/gradle/parser.ts b/lib/modules/manager/gradle/parser.ts
index d9f0f4e6111792c705728bec785f768b863afaa7..b0459572b2d084fe759b7046e64d5076728998fc 100644
--- a/lib/modules/manager/gradle/parser.ts
+++ b/lib/modules/manager/gradle/parser.ts
@@ -18,7 +18,7 @@ import type {
   PackageVariables,
   ParseGradleResult,
 } from './types';
-import { isDependencyString, parseDependencyString } from './utils';
+import { parseDependencyString } from './utils';
 
 const groovy = lang.createLang('groovy');
 const ctx: Ctx = {
@@ -127,28 +127,27 @@ export function parseProps(
 ): { vars: PackageVariables; deps: PackageDependency<GradleManagerData>[] } {
   let offset = 0;
   const vars: PackageVariables = {};
-  const deps: PackageDependency[] = [];
+  const deps: PackageDependency<GradleManagerData>[] = [];
+
   for (const line of input.split(newlineRegex)) {
     const lineMatch = propRegex.exec(line);
     if (lineMatch?.groups) {
       const { key, value, leftPart } = lineMatch.groups;
-      if (isDependencyString(value)) {
-        const dep = parseDependencyString(value);
-        if (dep) {
-          deps.push({
-            ...dep,
-            managerData: {
-              fileReplacePosition:
-                offset + leftPart.length + dep.depName!.length + 1,
-              packageFile,
-            },
-          });
-        }
+      const replacePosition = offset + leftPart.length;
+      const dep = parseDependencyString(value);
+      if (dep) {
+        deps.push({
+          ...dep,
+          managerData: {
+            fileReplacePosition: replacePosition + dep.depName!.length + 1,
+            packageFile,
+          },
+        });
       } else {
         vars[key] = {
           key,
           value,
-          fileReplacePosition: offset + leftPart.length,
+          fileReplacePosition: replacePosition,
           packageFile,
         };
       }
diff --git a/lib/modules/manager/gradle/parser/common.ts b/lib/modules/manager/gradle/parser/common.ts
index a008c30249da4c0f3e0c44f750e2e763d5b1aec2..2c201804407bceed4949f1d2e842506adb042ec0 100644
--- a/lib/modules/manager/gradle/parser/common.ts
+++ b/lib/modules/manager/gradle/parser/common.ts
@@ -267,23 +267,13 @@ export const qTemplateString = q
       ctx.tmpTokenStore.templateTokens = [];
       return ctx;
     },
-    search: q.alt(
-      qStringValue.handler((ctx) => {
+    search: q
+      .alt(qStringValue, qPropertyAccessIdentifier, qVariableAccessIdentifier)
+      .handler((ctx) => {
         ctx.tmpTokenStore.templateTokens?.push(...ctx.varTokens);
         ctx.varTokens = [];
         return ctx;
       }),
-      qPropertyAccessIdentifier.handler((ctx) => {
-        ctx.tmpTokenStore.templateTokens?.push(...ctx.varTokens);
-        ctx.varTokens = [];
-        return ctx;
-      }),
-      qVariableAccessIdentifier.handler((ctx) => {
-        ctx.tmpTokenStore.templateTokens?.push(...ctx.varTokens);
-        ctx.varTokens = [];
-        return ctx;
-      }),
-    ),
   })
   .handler((ctx) => {
     ctx.varTokens = ctx.tmpTokenStore.templateTokens!;
diff --git a/lib/modules/manager/gradle/utils.ts b/lib/modules/manager/gradle/utils.ts
index 84de600b478a0fdf65c35e8366c698a59946a39f..8b238247ec5300c4f30082986cb14c7361e26c1f 100644
--- a/lib/modules/manager/gradle/utils.ts
+++ b/lib/modules/manager/gradle/utils.ts
@@ -13,8 +13,7 @@ const artifactRegex = regEx(
 
 const versionLikeRegex = regEx('^(?<version>[-_.\\[\\](),a-zA-Z0-9+]+)');
 
-// Extracts version-like and range-like strings
-// from the beginning of input
+// Extracts version-like and range-like strings from the beginning of input
 export function versionLikeSubstring(
   input: string | null | undefined,
 ): string | null {
@@ -32,40 +31,32 @@ export function versionLikeSubstring(
 }
 
 export function isDependencyString(input: string): boolean {
-  const split = input?.split(':');
-  if (split?.length !== 3 && split?.length !== 4) {
+  const parts = input.split(':');
+  if (parts.length !== 3 && parts.length !== 4) {
     return false;
   }
-  // eslint-disable-next-line prefer-const
-  let [tempGroupId, tempArtifactId, tempVersionPart, optionalClassifier] =
-    split;
+  const [groupId, artifactId, versionPart, optionalClassifier] = parts;
 
   if (optionalClassifier && !artifactRegex.test(optionalClassifier)) {
     return false;
   }
 
-  if (
-    tempVersionPart !== versionLikeSubstring(tempVersionPart) &&
-    tempVersionPart.includes('@')
-  ) {
-    const versionSplit = tempVersionPart?.split('@');
-    if (versionSplit?.length !== 2) {
+  let version = versionPart;
+  if (versionPart.includes('@')) {
+    const [actualVersion, ...rest] = versionPart.split('@');
+    if (rest.length !== 1) {
       return false;
     }
-    [tempVersionPart] = versionSplit;
+    version = actualVersion;
   }
-  const [groupId, artifactId, versionPart] = [
-    tempGroupId,
-    tempArtifactId,
-    tempVersionPart,
-  ];
+
   return !!(
     groupId &&
     artifactId &&
-    versionPart &&
+    version &&
     artifactRegex.test(groupId) &&
     artifactRegex.test(artifactId) &&
-    versionPart === versionLikeSubstring(versionPart)
+    version === versionLikeSubstring(version)
   );
 }
 
@@ -75,18 +66,14 @@ export function parseDependencyString(
   if (!isDependencyString(input)) {
     return null;
   }
-  const [groupId, artifactId, FullValue] = input.split(':');
-  if (FullValue === versionLikeSubstring(FullValue)) {
-    return {
-      depName: `${groupId}:${artifactId}`,
-      currentValue: FullValue,
-    };
-  }
-  const [currentValue, dataType] = FullValue.split('@');
+
+  const [groupId, artifactId, fullValue] = input.split(':');
+  const [currentValue, dataType] = fullValue.split('@');
+
   return {
     depName: `${groupId}:${artifactId}`,
     currentValue,
-    dataType,
+    ...(dataType && { dataType }),
   };
 }