Skip to content
Draft
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target
/docs/javadoc/*
/clara-home
tmp
/common-tools/clas-io/src/main/java/org/jlab/io/banks

# deployment
/myLocalMvnRepo
Expand Down
16 changes: 16 additions & 0 deletions libexec/bank-schema-enums
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env python3
import os,glob,json
idir = 'etc/bankdefs/hipo4'
odir = 'common-tools/clas-io/src/main/java/org/jlab/io/banks'
os.makedirs(odir, exist_ok=True)
for x in glob.glob(f'{idir}/*.json'):
for bank in json.load(open(x,'r')):
class_name = bank['name'].replace(':','_');
with open(f'{odir}/{class_name}.java','w') as f:
f.write('package org.jlab.io.banks;\n')
f.write(f'public class {class_name} {{\n')
for i,entry in enumerate(bank['entries']):
var_name = entry['name']
f.write(f' public static final short {var_name} = {i};\n')
f.write('}\n')
f.close()
40 changes: 40 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,30 @@

<plugins> <!-- plugins inherited by all child POMs -->

<!-- generate bank shcema enums -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<id>bank-schema-enums</id>
<phase>validate</phase>
<goals>
<goal>run</goal>
</goals>
<inherited>false</inherited> <!-- make this one NOT inherited -->
<configuration>
<target>
<exec executable="python3">
<arg value="libexec/bank-schema-enums"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>

<!-- static analysis -->
<plugin>
<groupId>com.github.spotbugs</groupId>
Expand Down Expand Up @@ -428,6 +452,22 @@
<pluginManagement>
<plugins> <!-- plugin configurations (unused in child POMs unless declared) -->

<!-- delete auto-generated bank schema enums during clean phase -->
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<filesets>
<fileset>
<directory>common-tools/clas-io/src/main/java/org/jlab/io/banks</directory>
<includes>
<include>**/*.java</include>
</includes>
</fileset>
</filesets>
</configuration>
</plugin>

<!-- generate minimal POM files for deployment, containing GAV (groupID, artifactId, version) -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down
Loading