Skip to content

Commit 27897ef

Browse files
committed
Read maven-dependency-plugin version dynamically+ enable dependabot for maven helpers
1 parent 40978c0 commit 27897ef

File tree

4 files changed

+49
-4
lines changed

4 files changed

+49
-4
lines changed

.github/dependabot.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,15 @@ updates:
166166
interval: "weekly"
167167
day: "sunday"
168168
time: "16:00"
169+
- package-ecosystem: "maven"
170+
directory: "/maven/lib/dependabot/maven/"
171+
schedule:
172+
interval: "weekly"
173+
day: "sunday"
174+
time: "16:00"
175+
- package-ecosystem: "docker"
176+
directory: "/maven"
177+
schedule:
178+
interval: "weekly"
179+
day: "sunday"
180+
time: "16:00"

maven/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1+
# This cannot be inlined below (e.g., COPY --from=maven:...) because Dependabot does not support that syntax yet
2+
FROM maven:3.9.9 as maven
3+
14
FROM ghcr.io/dependabot/dependabot-updater-core
25

36
RUN apt-get update && apt-get install -y --no-install-recommends \
47
openjdk-21-jdk \
58
ca-certificates-java \
69
&& rm -rf /var/lib/apt/lists/*
710

8-
COPY --from=maven:3.9.9 /usr/share/maven /usr/share/maven
11+
COPY --from=maven /usr/share/maven /usr/share/maven
912

1013
ENV MAVEN_HOME=/usr/share/maven
1114

maven/lib/dependabot/maven/native_helpers.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
1-
# typed: strong
1+
# typed: strict
22
# frozen_string_literal: true
33

44
require "shellwords"
55
require "sorbet-runtime"
6+
require "nokogiri"
67

78
module Dependabot
89
module Maven
910
module NativeHelpers
1011
extend T::Sig
11-
# Latest version of the plugin can be found here - https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin
12-
DEPENDENCY_PLUGIN_VERSION = "3.8.1"
12+
pom_path = File.join(__dir__, "pom.xml")
13+
14+
version = File.open(pom_path) do |f|
15+
doc = Nokogiri::XML(f)
16+
doc.at_xpath("//project/properties/maven-dependency-plugin.version")&.text
17+
end
18+
19+
DEPENDENCY_PLUGIN_VERSION = T.let(version, T.nilable(String))
1320

1421
sig do
1522
params(file_name: String).void

maven/lib/dependabot/maven/pom.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
4+
<!--
5+
This build is not used directly within the native helper.
6+
The goal is to help automate the maintenance overhead of keeping the version of maven-dependency-plugin up to date.
7+
8+
1. We read the maven-dependency-plugin.version version dynamically from the native_helper
9+
2. We use Dependabot keep the version up to date
10+
-->
11+
12+
<properties>
13+
<maven-dependency-plugin.version>3.8.1</maven-dependency-plugin.version>
14+
</properties>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-dependency-plugin</artifactId>
20+
<version>${maven-dependency-plugin.version}</version>
21+
</dependency>
22+
</dependencies>
23+
</project>

0 commit comments

Comments
 (0)