From fdee4757ba941cb469428722878ae19305996796 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sat, 12 Oct 2024 12:11:20 +0200 Subject: [PATCH 1/5] Work around problems with flattened pom --- maven-settings.xml | 33 +++++++++++++++---- .../extension_indexer/SourceAndLibs.java | 2 ++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/maven-settings.xml b/maven-settings.xml index bc58a94..df6f1cd 100644 --- a/maven-settings.xml +++ b/maven-settings.xml @@ -1,9 +1,28 @@ - - - repo.jenkins-ci.org - https://repo.jenkins-ci.org/public/ - * - - + + jenkins + + + + jenkins + + + jenkins-releases + https://repo.jenkins-ci.org/releases/ + + true + + + + + + jenkins-releases + https://repo.jenkins-ci.org/releases/ + + true + + + + + diff --git a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java index 1aff611..0820c56 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java +++ b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java @@ -186,6 +186,8 @@ private static void downloadDependencies(File pomDir, File destDir) throws IOExc command.addAll(Arrays.asList("--update-snapshots", "--batch-mode", "dependency:copy-dependencies", + "dependency:copy", + "-Dartifact=org.jenkins-ci.main:jenkins-core:2.480", "-DincludeScope=compile", "-DoutputDirectory=" + destDir.getAbsolutePath())); From 3139ca302df48aa39f8e7aa5aa4a8fb43cf12119 Mon Sep 17 00:00:00 2001 From: Daniel Beck Date: Sat, 12 Oct 2024 15:26:18 +0200 Subject: [PATCH 2/5] Force version of dependency plugin that works, attempt to override poor repo definitions --- maven-settings.xml | 20 +++++++++++++++---- .../extension_indexer/SourceAndLibs.java | 4 ++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/maven-settings.xml b/maven-settings.xml index df6f1cd..0bda067 100644 --- a/maven-settings.xml +++ b/maven-settings.xml @@ -7,8 +7,8 @@ jenkins - jenkins-releases - https://repo.jenkins-ci.org/releases/ + jenkins-public + https://repo.jenkins-ci.org/public/ true @@ -16,8 +16,8 @@ - jenkins-releases - https://repo.jenkins-ci.org/releases/ + jenkins-public + https://repo.jenkins-ci.org/public/ true @@ -25,4 +25,16 @@ + + + repo.j.o-mirror + repo.jenkins-ci.org + https://repo.jenkine-ci.org/public/ + + + m.g.o-public-repo1 + m.g.o-public + https://repo.maven.apache.org/maven2/ + + diff --git a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java index 0820c56..9327309 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java +++ b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java @@ -185,8 +185,8 @@ private static void downloadDependencies(File pomDir, File destDir) throws IOExc command.addAll(Arrays.asList("--settings", (System.getenv("MAVEN_SETTINGS") != null) ? System.getenv("MAVEN_SETTINGS") : new File("maven-settings.xml").getAbsolutePath())); command.addAll(Arrays.asList("--update-snapshots", "--batch-mode", - "dependency:copy-dependencies", - "dependency:copy", + "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy-dependencies", + "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy", "-Dartifact=org.jenkins-ci.main:jenkins-core:2.480", "-DincludeScope=compile", "-DoutputDirectory=" + destDir.getAbsolutePath())); From 4de488a395f57646c7a5727042e00c33ad22bc10 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sat, 12 Oct 2024 16:24:40 +0100 Subject: [PATCH 3/5] Add renovate --- .github/dependabot.yml | 6 ----- .github/renovate.json | 22 +++++++++++++++++++ .../extension_indexer/SourceAndLibs.java | 2 +- 3 files changed, 23 insertions(+), 7 deletions(-) delete mode 100644 .github/dependabot.yml create mode 100644 .github/renovate.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 933435d..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,6 +0,0 @@ -version: 2 -updates: - - package-ecosystem: maven - directory: "/" - schedule: - interval: weekly diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000..e8d9001 --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base", + ":semanticCommitsDisabled", + "schedule:earlyMondays" + ], + "automerge": true, + "labels": [ + "dependencies" + ], + "customManagers": [ + { + "customType": "regex", + "fileMatch": ["^src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java"], + "matchStrings": ["org.jenkins-ci.main:jenkins-core:(?.*?)\""], + "depNameTemplate": "org.jenkins-ci.main:jenkins-core", + "datasourceTemplate": "maven" + } + ], + "rebaseWhen": "conflicted" +} diff --git a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java index 9327309..58ed4d9 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java +++ b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java @@ -187,7 +187,7 @@ private static void downloadDependencies(File pomDir, File destDir) throws IOExc "--batch-mode", "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy-dependencies", "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy", - "-Dartifact=org.jenkins-ci.main:jenkins-core:2.480", + "-Dartifact=org.jenkins-ci.main:jenkins-core:2.479", "-DincludeScope=compile", "-DoutputDirectory=" + destDir.getAbsolutePath())); From ba418d4171cc56c8d80ae26778216aca27dadc15 Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sat, 12 Oct 2024 16:55:10 +0100 Subject: [PATCH 4/5] Add registry url --- .github/renovate.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/renovate.json b/.github/renovate.json index e8d9001..1d04fa6 100644 --- a/.github/renovate.json +++ b/.github/renovate.json @@ -9,6 +9,13 @@ "labels": [ "dependencies" ], + "packageRules": [ + { + "matchPackageNames": ["org.jenkins-ci.main:jenkins-core"], + "description": ["Needed for regex manager which doesn't extract the registry url like other dependencies"], + "registryUrls": ["https://repo.jenkins-ci.org/releases/"] + } + ], "customManagers": [ { "customType": "regex", From 67785f7cb48d2765adca4032acffca4367ba489f Mon Sep 17 00:00:00 2001 From: Tim Jacomb Date: Sat, 12 Oct 2024 17:51:55 +0100 Subject: [PATCH 5/5] Code re-org to pass down core version --- .github/dependabot.yml | 6 ++++ .github/renovate.json | 29 ------------------- .../ExtensionPointListGenerator.java | 16 +++++----- .../ExtensionPointsExtractor.java | 4 +-- .../extension_indexer/SourceAndLibs.java | 9 +++--- 5 files changed, 22 insertions(+), 42 deletions(-) create mode 100644 .github/dependabot.yml delete mode 100644 .github/renovate.json diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..933435d --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: maven + directory: "/" + schedule: + interval: weekly diff --git a/.github/renovate.json b/.github/renovate.json deleted file mode 100644 index 1d04fa6..0000000 --- a/.github/renovate.json +++ /dev/null @@ -1,29 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:base", - ":semanticCommitsDisabled", - "schedule:earlyMondays" - ], - "automerge": true, - "labels": [ - "dependencies" - ], - "packageRules": [ - { - "matchPackageNames": ["org.jenkins-ci.main:jenkins-core"], - "description": ["Needed for regex manager which doesn't extract the registry url like other dependencies"], - "registryUrls": ["https://repo.jenkins-ci.org/releases/"] - } - ], - "customManagers": [ - { - "customType": "regex", - "fileMatch": ["^src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java"], - "matchStrings": ["org.jenkins-ci.main:jenkins-core:(?.*?)\""], - "depNameTemplate": "org.jenkins-ci.main:jenkins-core", - "datasourceTemplate": "maven" - } - ], - "rebaseWhen": "conflicted" -} diff --git a/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointListGenerator.java b/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointListGenerator.java index 5115491..4f34701 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointListGenerator.java +++ b/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointListGenerator.java @@ -210,9 +210,10 @@ public void run() throws Exception { if (asciidocOutputDir ==null && jsonFile==null && pluginsDir ==null) throw new IllegalStateException("Nothing to do. Either -adoc, -json, or -pipeline is needed"); - discover(addModule(new Module.CoreModule(updateCenterJson.getJSONObject("core").getString("version")))); + Module.CoreModule coreModule = new Module.CoreModule(updateCenterJson.getJSONObject("core").getString("version")); + discover(addModule(coreModule), coreModule); - processPlugins(updateCenterJson.getJSONObject("plugins").values()); + processPlugins(updateCenterJson.getJSONObject("plugins").values(), coreModule); if (jsonFile!=null) { JSONObject all = new JSONObject(); @@ -247,10 +248,10 @@ public void run() throws Exception { } /** - * Walks over the plugins, record {@link #modules} and call {@link #discover(Module)}. + * Walks over the plugins, record {@link #modules} and call {@link #discover(Module, Module.CoreModule)}. * @param plugins */ - private void processPlugins(Collection plugins) throws Exception { + private void processPlugins(Collection plugins, Module.CoreModule core) throws Exception { int availableProcessors = Runtime.getRuntime().availableProcessors(); int nThreads = availableProcessors * 3; System.out.printf("Running with %d threads%n", nThreads); @@ -269,7 +270,8 @@ public void run() { try { System.out.println(artifactId); if (asciidocOutputDir !=null || jsonFile!=null) { - discover(addModule(new Module.PluginModule(plugin.getString("gav"), plugin.getString("url"), plugin.getString("title"), plugin.optString("scm")))); + Module pluginModule = addModule(new Module.PluginModule(plugin.getString("gav"), plugin.getString("url"), plugin.getString("title"), plugin.optString("scm"))); + discover(pluginModule, core); } if (pluginsDir!=null) { FileUtils.copyURLToFile( @@ -331,9 +333,9 @@ private void generateAsciidocReport() throws IOException { } } - private void discover(Module m) throws IOException, InterruptedException { + private void discover(Module m, Module.CoreModule core) throws IOException, InterruptedException { if (asciidocOutputDir !=null || jsonFile!=null) { - for (ClassOfInterest e : extractor.extract(m)) { + for (ClassOfInterest e : extractor.extract(m, core)) { synchronized (families) { System.out.println("Found "+e); diff --git a/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointsExtractor.java b/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointsExtractor.java index 131518e..8242a86 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointsExtractor.java +++ b/src/main/java/org/jenkinsci/extension_indexer/ExtensionPointsExtractor.java @@ -36,8 +36,8 @@ * @author Kohsuke Kawaguchi */ public class ExtensionPointsExtractor { - public List extract(Module module) throws IOException, InterruptedException { - return extract(module,SourceAndLibs.create(module)); + public List extract(Module module, Module.CoreModule core) throws IOException, InterruptedException { + return extract(module,SourceAndLibs.create(module, core)); } public List extract(final Module module, final SourceAndLibs sal) throws IOException { diff --git a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java index 58ed4d9..c9870e4 100644 --- a/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java +++ b/src/main/java/org/jenkinsci/extension_indexer/SourceAndLibs.java @@ -144,7 +144,7 @@ private static URLConnection getURLConnection(URL url) throws MalformedURLExcept return conn; } - public static SourceAndLibs create(Module module) throws IOException, InterruptedException { + public static SourceAndLibs create(Module module, Module.CoreModule core) throws IOException, InterruptedException { final File tempDir = Files.createTempDirectory("jenkins-extPoint").toFile(); File srcdir = new File(tempDir,"src"); File libdir = new File(tempDir,"lib"); @@ -163,7 +163,7 @@ public static SourceAndLibs create(Module module) throws IOException, Interrupte } System.out.println("Downloading Dependencies"); - downloadDependencies(srcdir, libdir); + downloadDependencies(srcdir, libdir, core); return new SourceAndLibs(srcdir, libdir) { @Override @@ -174,7 +174,7 @@ public void close() throws IOException { } @SuppressFBWarnings(value = "COMMAND_INJECTION", justification = "Command injection is not a viable risk here") - private static void downloadDependencies(File pomDir, File destDir) throws IOException, InterruptedException { + private static void downloadDependencies(File pomDir, File destDir, Module.CoreModule core) throws IOException, InterruptedException { Files.createDirectories(destDir.toPath()); String process = "mvn"; if (System.getenv("M2_HOME") != null) { @@ -183,11 +183,12 @@ private static void downloadDependencies(File pomDir, File destDir) throws IOExc List command = new ArrayList<>(); command.add(process); command.addAll(Arrays.asList("--settings", (System.getenv("MAVEN_SETTINGS") != null) ? System.getenv("MAVEN_SETTINGS") : new File("maven-settings.xml").getAbsolutePath())); + command.addAll(Arrays.asList("--update-snapshots", "--batch-mode", "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy-dependencies", "org.apache.maven.plugins:maven-dependency-plugin:3.8.0:copy", - "-Dartifact=org.jenkins-ci.main:jenkins-core:2.479", + "-Dartifact=" + core.gav, "-DincludeScope=compile", "-DoutputDirectory=" + destDir.getAbsolutePath()));