From c6be1e3d49aeabf96a36aed9228eb8cabf79913c Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 6 Oct 2026 15:29:18 -0400 Subject: [PATCH 1/5] feat: print source Maven repo for each dependency --- .github/workflows/ci.yml | 25 +++++++++++ libexec/dependency-info.rb | 91 ++++++++++++++++++++++++++++++++++++++ pom.xml | 8 ++-- 3 files changed, 120 insertions(+), 4 deletions(-) create mode 100755 libexec/dependency-info.rb diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c32b30722..4e76d8510a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,31 @@ jobs: path: | coatjava.tar.gz clara.tar.gz + - uses: actions/upload-artifact@v7 + with: + name: target_ubuntu-latest + retention-days: 1 + path: '**/target' + + dependency_info: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + - name: Set up JDK + uses: actions/setup-java@v6.0.1 + with: + java-version: ${{ env.JAVA_VERSION }} + distribution: ${{ env.java_distribution }} + # NOTE: do not use `cache: maven` here, so stale `_remote.repositories` aren't read + - uses: actions/download-artifact@v8 + with: + name: target_ubuntu-latest + - run: libexec/dependency-info.rb + - name: dependency tree + run: cat target/info/trees.txt + - name: dependency repository sources + run: cat target/info/repos.yaml # tests ############################################################################# diff --git a/libexec/dependency-info.rb b/libexec/dependency-info.rb new file mode 100755 index 0000000000..379800e7b0 --- /dev/null +++ b/libexec/dependency-info.rb @@ -0,0 +1,91 @@ +#!/usr/bin/env ruby +# +# map dependency to the repository from which it was obtained +# + +require 'yaml' +require 'fileutils' + +TOP_DIR = File.realpath "#{__dir__}/.." +OUT_DIR = "#{TOP_DIR}/target/info" +CLASSPATH_FILE_NAME = 'dependency-classpath.txt' +TREE_FILE_NAME = 'dependency-tree.txt' +REPO_LOCAL = 'local' +REPO_CENTRAL = 'maven-central' + +# get classpath for each module +system [ + 'mvn', + 'dependency:build-classpath', + "-Dmdep.outputFile='${project.build.directory}/#{CLASSPATH_FILE_NAME}'", + '--quiet', + "--file #{TOP_DIR}", +].join ' ' +raise "dependency:build-classpath goal failed" unless $?.success? + +# get the list of unique dependency JARs +jars = [] +Dir.glob("#{TOP_DIR}/**/target/#{CLASSPATH_FILE_NAME}").each do |classpath_file| + File.readlines(classpath_file, chomp: true).each do |line| + jars << line.split(':') + end +end +jars.flatten!.uniq!.sort! + +# get the remote repos +repos = {} +jars.each do |jar_path| + # SNAPSHOT normalizer: replace timestamp with 'SNAPSHOT' + def normalize(name) + name.sub(/\d{8}\.\d{6}-\d+/, 'SNAPSHOT') + end + # names + jar_dir = File.dirname jar_path + jar_name = normalize(File.basename jar_path) + repo_file = "#{jar_dir}/_remote.repositories" + # check if remote repo description exists + unless File.exist? repo_file + warn "WARNING: #{repo_file} does not exist" + next + end + # get info for this JAR + repo_lines = File.readlines(repo_file, chomp: true) + .reject { |l| l.start_with?('#') } + .select { |l| normalize(l.split('>', 2)[0]) == jar_name } + if repo_lines.empty? + warn "WARNING: could not find #{jar_name} in #{repo_file}" + next + end + # fill output hash + repo_lines.each do |repo_line| + repo_id = repo_line.split('>')[1].split('=')[0] + repo = case repo_id + when /code.jlab.org-.*/ then 'code.jlab.org' + when nil then REPO_LOCAL + when 'central' then REPO_CENTRAL + else repo_id + end + (repos[repo] ||= []) << jar_path.sub(/^.*.m2\/repository\//,'') + end +end + +# dump output as YAML +FileUtils.mkdir_p OUT_DIR +OUT_REPOS = "#{OUT_DIR}/repos.yaml" +File.open(OUT_REPOS, 'w') do |o| + o.puts repos + .sort_by{ |k,_| [ [REPO_LOCAL, REPO_CENTRAL].index(k) || 2, k] } + .to_h + .to_yaml +end +puts "Wrote #{OUT_REPOS}" + +# collect all dependency trees +OUT_TREES = "#{OUT_DIR}/trees.txt" +File.open(OUT_TREES, 'w') do |o| + Dir.glob("#{TOP_DIR}/**/target/#{TREE_FILE_NAME}").sort.each do |tree_file| + o.puts `cat #{tree_file}` + o.puts '' + end +end +puts "Wrote #{OUT_TREES}" diff --git a/pom.xml b/pom.xml index 93a1bb8e70..e1fee795a0 100644 --- a/pom.xml +++ b/pom.xml @@ -20,19 +20,19 @@ - clas12-hipo-java + code.jlab.org-hipo-java https://code.jlab.org/api/v4/projects/919/packages/maven - clas12-clara-java + code.jlab.org-clara-java https://code.jlab.org/api/v4/projects/243/packages/maven - clas12maven + clasweb-clas12maven https://clasweb.jlab.org/.clas12maven - jnp-maven + clasweb-jhep https://clasweb.jlab.org/.jhep/maven From 2fb378be1c2982a139ac1d9ee329a6c3a8c5542a Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 6 Oct 2026 17:39:56 -0400 Subject: [PATCH 2/5] fix: need to build --- .github/workflows/ci.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4e76d8510a..c72c5b07a1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,14 +114,8 @@ jobs: path: | coatjava.tar.gz clara.tar.gz - - uses: actions/upload-artifact@v7 - with: - name: target_ubuntu-latest - retention-days: 1 - path: '**/target' dependency_info: - needs: build runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 @@ -130,14 +124,15 @@ jobs: with: java-version: ${{ env.JAVA_VERSION }} distribution: ${{ env.java_distribution }} - # NOTE: do not use `cache: maven` here, so stale `_remote.repositories` aren't read - - uses: actions/download-artifact@v8 - with: - name: target_ubuntu-latest - - run: libexec/dependency-info.rb - - name: dependency tree + # NOTE: do not use `cache: maven` here, so stale `_remote.repositories` data aren't read + - name: build + run: | + ./build-coatjava.sh --no-aux --no-progress --quiet -T${{ env.nthreads }} + - name: collect info + run: libexec/dependency-info.rb + - name: print dependency trees run: cat target/info/trees.txt - - name: dependency repository sources + - name: print dependency repository sources run: cat target/info/repos.yaml # tests From 91d0304e28c835fa7324afdcff336411da121d28 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 6 Oct 2026 17:58:12 -0400 Subject: [PATCH 3/5] fix: strip digest --- libexec/dependency-info.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/dependency-info.rb b/libexec/dependency-info.rb index 379800e7b0..3ce4963d81 100755 --- a/libexec/dependency-info.rb +++ b/libexec/dependency-info.rb @@ -59,6 +59,7 @@ def normalize(name) # fill output hash repo_lines.each do |repo_line| repo_id = repo_line.split('>')[1].split('=')[0] + repo_id = repo_id.sub /-\h{32,}\z/, '' # drop the trailing digest (from GitHub `setup-java`'s `settings.xml`) repo = case repo_id when /code.jlab.org-.*/ then 'code.jlab.org' when nil then REPO_LOCAL From c38fd672c55f7568c676f6a8eec14456deff6367 Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 6 Oct 2026 18:04:26 -0400 Subject: [PATCH 4/5] fix: nil? --- libexec/dependency-info.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/dependency-info.rb b/libexec/dependency-info.rb index 3ce4963d81..8cce06eb58 100755 --- a/libexec/dependency-info.rb +++ b/libexec/dependency-info.rb @@ -59,7 +59,7 @@ def normalize(name) # fill output hash repo_lines.each do |repo_line| repo_id = repo_line.split('>')[1].split('=')[0] - repo_id = repo_id.sub /-\h{32,}\z/, '' # drop the trailing digest (from GitHub `setup-java`'s `settings.xml`) + repo_id = repo_id.sub /-\h{32,}\z/, '' unless repo_id.nil? # drop the trailing digest (from GitHub `setup-java`'s `settings.xml`) repo = case repo_id when /code.jlab.org-.*/ then 'code.jlab.org' when nil then REPO_LOCAL From 7797035de8bb17df990d12707f8b0f97b605d30d Mon Sep 17 00:00:00 2001 From: Christopher Dilks Date: Tue, 6 Oct 2026 18:26:52 -0400 Subject: [PATCH 5/5] fix: heck --- common-tools/coat-libs/pom.xml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/common-tools/coat-libs/pom.xml b/common-tools/coat-libs/pom.xml index d8c6659cf2..e9a5384fed 100644 --- a/common-tools/coat-libs/pom.xml +++ b/common-tools/coat-libs/pom.xml @@ -13,14 +13,6 @@ 14.2.1-SNAPSHOT - - - freehep-repo-public - https://clasweb.jlab.org/.clas12maven/ - - - -