This is an automated email from the ASF dual-hosted git repository.

ppkarwasz pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/commons-secure-xml.git


The following commit(s) were added to refs/heads/main by this push:
     new 6167dcf  Read the version of the library under test from the POM. (#87)
6167dcf is described below

commit 6167dcf4af00fe58e09da8925f53fe238eb52679
Author: Piotr P. Karwasz <[email protected]>
AuthorDate: Sun Sep 13 10:37:15 2026 +0200

    Read the version of the library under test from the POM. (#87)
    
    The Android build repeated the version as a literal, which had drifted from
    the Maven one, so connectedAndroidTest looked for a JAR that the release
    bump had renamed. It now reads ../pom.xml, with the last release of this
    library doing the parsing, and Dependabot gains the Gradle ecosystem so the
    dogfooded coordinate and the plugins the module pins stay current.
    
    Assisted-By: Claude Opus 5 (1M context) <[email protected]>
    Claude-Session: https://claude.ai/code/session_01AaDyR9HjZLWkFn42x7kje3
---
 .github/dependabot.yml         |  5 +++++
 android-tests/build.gradle.kts | 28 +++++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index cc8ef12..623a02a 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -20,6 +20,11 @@ updates:
     schedule:
       interval: "quarterly"
 
+  - package-ecosystem: "gradle"
+    directory: "/android-tests"
+    schedule:
+      interval: "quarterly"
+
   - package-ecosystem: "github-actions"
     directory: "/"
     schedule:
diff --git a/android-tests/build.gradle.kts b/android-tests/build.gradle.kts
index 845b1e1..a162444 100644
--- a/android-tests/build.gradle.kts
+++ b/android-tests/build.gradle.kts
@@ -16,14 +16,40 @@
  */
 
 import com.android.build.api.dsl.ManagedVirtualDevice
+import org.apache.commons.xml.secure.SecureDocumentBuilderFactory
+import org.apache.commons.xml.secure.SecureXPathFactory
 import org.gradle.api.tasks.compile.JavaCompile
 
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        // Dogfooding, not the artifact under test: this parses the POM below, 
while the tests run against the JAR in ../target.
+        classpath("org.apache.commons:commons-secure-xml:1.0.0")
+    }
+}
+
 plugins {
     id("com.android.library") version "8.6.1"
     id("de.mannodermaus.android-junit5") version "1.14.0.0"
 }
 
-val libraryVersion = "1.0.0-SNAPSHOT"
+/** Returns the `version` of the Maven project itself: the direct child of the 
root element, never the `parent` block's. */
+fun projectVersionOf(pom: File): String {
+    // newInstance, not newNSInstance: the path below is spelled plainly, and 
would select nothing if the POM namespace were honoured.
+    val documents = SecureDocumentBuilderFactory.newInstance()
+    val version = SecureXPathFactory.newInstance().newXPath()
+        .evaluate("/project/version", 
documents.newDocumentBuilder().parse(pom))
+        .trim()
+    if (version.isEmpty()) {
+        throw GradleException("No <version> element in ${pom}")
+    }
+    return version
+}
+
+// Taken from the Maven build instead of repeated here, so the JAR this module 
looks for follows a version bump.
+val libraryVersion = projectVersionOf(rootProject.file("../pom.xml"))
 val libraryJar = 
rootProject.file("../target/commons-secure-xml-${libraryVersion}.jar")
 
 android {

Reply via email to