-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathgenerate-mega-melt.py
More file actions
147 lines (136 loc) · 4.91 KB
/
generate-mega-melt.py
File metadata and controls
147 lines (136 loc) · 4.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# generate-mega-melt.py - Make a POM depending on everything in pom-scijava.
#
import os, re, sys
from xml.dom import minidom
def child(node, tag):
nodes = node.getElementsByTagName(tag)
return None if len(nodes) == 0 else nodes[0]
script_dir = os.path.dirname(os.path.realpath(__file__)) if __file__ else '.'
out = minidom.parse(os.path.join(script_dir, 'mega-melt-template.xml'))
out.getElementsByTagName('project')[0].appendChild(out.createElement('dependencies'))
outDeps = out.getElementsByTagName('dependencies')[0]
psj = minidom.parse(os.path.join(script_dir, '..', 'pom.xml'))
depMgmt = psj.getElementsByTagName('dependencyManagement')[0]
deps = depMgmt.getElementsByTagName('dependencies')[0]
depList = deps.getElementsByTagName('dependency')
# Artifacts to exclude from the mega melt.
ignoredArtifacts = [
# TEMP: Exclude org.bytedeco:hdf5 until cisd:jhdf5 is gone.
'hdf5',
# TEMP: The original ImageJ requires Java 9+ to compile,
# because it has a module-info.java, so skip it until the
# component collection is updated from Java 8 to Java 11.
'ij',
# TEMP: Skip components within multi-module reactors.
# Neither melting-pot.sh nor release-version.sh understand
# multi-module repositories; release-version.sh needs to learn
# how to tag and release individual components from multi-module
# repos, so that when melting-pot.sh shallow clones the repo at
# that tag and invokes a build, it will be building only the
# released component as it does with single-component repos.
'scijava-collections',
'scijava-common3',
'scijava-concurrent',
'scijava-discovery-test',
'scijava-discovery',
'scijava-function',
'scijava-legacy',
'scijava-meta',
'scijava-ops-api',
'scijava-ops-benchmarks',
'scijava-ops-engine',
'scijava-ops-ext-parser',
'scijava-ops-flim',
'scijava-ops-image',
'scijava-ops-indexer',
'scijava-ops-opencv',
'scijava-ops-spi',
'scijava-ops-tutorial',
'scijava-priority',
'scijava-progress',
'scijava-struct',
'scijava-taglets',
'scijava-testutil',
'scijava-types',
'mpicbg', 'mpicbg_',
# NB: Skip artifacts requiring minimum Java version >8.
'algart-tiff',
'javafx-base',
'javafx-controls',
'javafx-fxml',
'javafx-graphics',
'javafx-media',
'javafx-swing',
'javafx-web',
'SNT',
# NB: Skip closed-source artifacts.
'bonej-plus',
# NB: The following artifacts have messy dependency trees.
# Too many problems to test as part of the mega-melt.
# See WARNING block in pom-scijava's pom.xml for details.
'imagej-server',
'spark-core_2.11',
# NB: Skip scijava forks of third-party projects.
# These are very stable, with few/no dependencies, and
# don't need to be retested as pom-scijava evolves.
'j3dcore',
'j3dutils',
'jep',
'junit-benchmarks',
'vecmath',
# NB: Skip alternate flavors of other managed components.
'gluegen', # uberjar flavor of gluegen-rt
'jogl-all-noawt', # slimmed down flavor of jogl-all
# NB: All the SWT platform JARs have the same classes.
# The current platform will be brought in transitively.
'org.eclipse.swt.cocoa.macosx',
'org.eclipse.swt.cocoa.macosx.x86_64',
'org.eclipse.swt.gtk.aix.ppc',
'org.eclipse.swt.gtk.aix.ppc64',
'org.eclipse.swt.gtk.hpux.ia64',
'org.eclipse.swt.gtk.linux.ppc',
'org.eclipse.swt.gtk.linux.ppc64',
'org.eclipse.swt.gtk.linux.s390',
'org.eclipse.swt.gtk.linux.s390x',
'org.eclipse.swt.gtk.linux.x86',
'org.eclipse.swt.gtk.linux.x86_64',
'org.eclipse.swt.gtk.solaris.sparc',
'org.eclipse.swt.gtk.solaris.x86',
'org.eclipse.swt.win32.win32.x86',
'org.eclipse.swt.win32.win32.x86_64',
# NB: All SLF4J bindings have the same classes.
# We'll rely on logback-classic being present here.
'slf4j-jcl',
'slf4j-jdk14',
'slf4j-nop',
'slf4j-simple',
# NB: Cannot include both commons-logging and jcl-over-slf4j;
# see: http://www.slf4j.org/codes.html#jclDelegationLoop
'jcl-over-slf4j'
]
for dep in depList:
# Harvest relevant information (ignore exclusions and version).
groupId = child(dep, 'groupId')
artifactId = child(dep, 'artifactId')
classifier = child(dep, 'classifier')
scope = child(dep, 'scope')
if artifactId.firstChild.data in ignoredArtifacts:
continue
outDep = out.createElement('dependency')
outDep.appendChild(groupId)
outDep.appendChild(artifactId)
if classifier:
outDep.appendChild(classifier)
if scope:
outDep.appendChild(scope)
outDeps.appendChild(outDep)
# Filter XML through a hacky substitution to avoid unwanted whitespace.
xml = re.sub('\n[\n\r\t]*\n', '\n', out.toprettyxml())
outDir = sys.argv[1] if len(sys.argv) > 1 else 'mega-melt'
try:
os.mkdir(outDir)
except:
pass
with open(os.path.join(outDir, 'pom.xml'), 'w') as outPOM:
outPOM.write(xml)