Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ jobs:
coatjava.tar.gz
clara.tar.gz

dependency_info:
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` 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: print dependency repository sources
run: cat target/info/repos.yaml

# tests
#############################################################################

Expand Down
8 changes: 0 additions & 8 deletions common-tools/coat-libs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
<version>14.2.1-SNAPSHOT</version>
</parent>

<repositories>
<repository>
<id>freehep-repo-public</id>
<url>https://clasweb.jlab.org/.clas12maven/</url>
<!--<url>https://srs.slac.stanford.edu/nexus/content/groups/freehep-maven2-public/</url>-->
</repository>
</repositories>

<dependencies>

<dependency>
Expand Down
92 changes: 92 additions & 0 deletions libexec/dependency-info.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#!/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_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
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}"
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@

<repositories>
<repository>
<id>clas12-hipo-java</id> <!-- `jnp-hipo4` is now built and published from its own repository, https://code.jlab.org/hallb/clas12/hipo-java. Project 919's package registry is public -->
<id>code.jlab.org-hipo-java</id> <!-- `jnp-hipo4` is now built and published from its own repository, https://code.jlab.org/hallb/clas12/hipo-java. Project 919's package registry is public -->
<url>https://code.jlab.org/api/v4/projects/919/packages/maven</url>
</repository>
<repository>
<id>clas12-clara-java</id>
<id>code.jlab.org-clara-java</id>
<url>https://code.jlab.org/api/v4/projects/243/packages/maven</url>
</repository>
<repository>
<id>clas12maven</id>
<id>clasweb-clas12maven</id>
<url>https://clasweb.jlab.org/.clas12maven</url>
</repository>
<repository>
<id>jnp-maven</id>
<id>clasweb-jhep</id>
<url>https://clasweb.jlab.org/.jhep/maven</url>
</repository>
</repositories>
Expand Down
Loading