source: trunk/scan-deps.pl @ 6224

Revision 6224, 31.1 KB checked in by curtis, 10 years ago (diff)

Better error output for scan-deps.

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl
2use strict;
3
4# scan-deps.pl - Scans source code to determine project interdependencies,
5#                as well as dependencies on external libraries.
6
7# This script was used to autogenerate the project dependency documentation in
8# the build.xml file's top-level comment, as well as verify the correctness of
9# the component.classpath field in each component's build.properties file.
10
11# TODO - Use this script to autogenerate the LOCI plugins configuration file:
12#   components/loci-plugins/src/loci/plugins/config/libraries.txt
13
14# TODO - Use this script to check build.xml's depends clauses.
15
16use constant {
17  NAME      => 0,  # short name, for ease of reference
18  TITLE     => 1,  # human-friendly title for each component and library
19  PATH      => 2,  # source code path for each component
20  JAR       => 3,  # JAR file name for each component and library
21  PACKAGE   => 4,  # base package for each component and library
22  DESC      => 5,  # description for each component
23  LICENSE   => 6,  # license governing each component and library
24  URL       => 7,  # URL for each external project (forks, stubs & libs)
25  NOTES     => 8,  # notes for each external project (forks, stubs & libs)
26  PROJ_DEPS => 9,  # compile-time project dependencies for each component
27  PROJ_OPT  => 10, # runtime project dependencies for each component
28  LIB_DEPS  => 11, # compile-time library dependencies for each component
29  LIB_OPT   => 12, # runtime library dependencies for each component
30  COMPILE   => 13, # compile-time classpath for each component
31  RUNTIME   => 14, # runtime classpath for each component
32  ECLIPSE   => 15, # Eclipse classpath for each component
33  VERSION   => 16, # version number for each library
34};
35
36# -- COMPONENT DEFINITIONS - ACTIVE --
37
38my %autogen = (
39  NAME    => "autogen",
40  TITLE   => "LOCI code generator",
41  PATH    => "components/autogen",
42  JAR     => "loci-autogen.jar",
43  PACKAGE => "(none)",
44  DESC    => <<ZZ,
45Package for generating other code, including the Bio-Formats metadata API,
46related documentation, Ice bindings, and Bio-Formats C++ bindings headers
47ZZ
48  LICENSE => "GPL",
49);
50
51my %bfIce = (
52  NAME    => "bf-ice",
53  TITLE   => "Bio-Formats Ice framework",
54  PATH    => "components/bf-ice",
55  JAR     => "bf-ice.jar",
56  PACKAGE => "loci.ice.formats",
57  DESC    => <<ZZ,
58Bindings for Bio-Formats client/server communication enabling cross-language
59interoperability
60ZZ
61  LICENSE => "GPL",
62);
63
64my %bioFormats = (
65  NAME    => "bio-formats",
66  TITLE   => "Bio-Formats",
67  PATH    => "components/bio-formats",
68  JAR     => "bio-formats.jar",
69  PACKAGE => "loci.formats",
70  DESC    => <<ZZ,
71A library for reading and writing popular microscopy file formats
72ZZ
73  LICENSE => "GPL",
74);
75
76my %flowCytometry = (
77  NAME    => "flow-cytometry",
78  TITLE   => "WiscScan Flow Cytometry",
79  PATH    => "components/flow-cytometry",
80  JAR     => "flow-cytometry.jar",
81  PACKAGE => "loci.apps.flow",
82  DESC    => <<ZZ,
83Server application for flow cytometry with WiscScan using JVMLink
84ZZ
85  LICENSE => "BSD",
86);
87
88my %lociChecks = (
89  NAME    => "loci-checks",
90  TITLE   => "LOCI Checkstyle checks",
91  PATH    => "components/checkstyle",
92  JAR     => "loci-checks.jar",
93  PACKAGE => "loci.checks",
94  DESC    => <<ZZ,
95LOCI's Checkstyle extensions, for checking source code style
96ZZ
97  LICENSE => "Public domain",
98);
99
100my %lociCommon = (
101  NAME    => "common",
102  TITLE   => "LOCI Common",
103  PATH    => "components/common",
104  JAR     => "loci-common.jar",
105  PACKAGE => "loci.common",
106  DESC    => <<ZZ,
107A library containing common I/O and reflection classes
108ZZ
109  LICENSE => "GPL",
110);
111
112my %lociPlugins = (
113  NAME    => "loci-plugins",
114  TITLE   => "LOCI Plugins for ImageJ",
115  PATH    => "components/loci-plugins",
116  JAR     => "loci_plugins.jar",
117  PACKAGE => "loci.plugins",
118  DESC    => <<ZZ,
119A collection of plugins for ImageJ, including the Bio-Formats Importer,
120Bio-Formats Exporter, Bio-Formats Macro Extensions, Data Browser, Stack
121Colorizer and Stack Slicer
122ZZ
123  LICENSE => "GPL",
124);
125
126my %omeIO = (
127  NAME    => "ome-io",
128  TITLE   => "OME I/O",
129  PATH    => "components/ome-io",
130  JAR     => "ome-io.jar",
131  PACKAGE => "loci.ome.io",
132  DESC    => <<ZZ,
133A library for OME database import, upload and download
134ZZ
135  LICENSE => "GPL",
136);
137
138my %omePlugins = (
139  NAME    => "ome-plugins",
140  TITLE   => "OME Plugins for ImageJ",
141  PATH    => "components/ome-plugins",
142  JAR     => "ome_plugins.jar",
143  PACKAGE => "loci.plugins.ome",
144  DESC    => <<ZZ,
145A collection of plugins for ImageJ, including the Download from OME and Upload
146to OME plugins
147ZZ
148  LICENSE => "GPL",
149);
150
151my %omeXML = (
152  NAME    => "ome-xml",
153  TITLE   => "OME-XML Java library",
154  PATH    => "components/ome-xml",
155  JAR     => "ome-xml.jar",
156  PACKAGE => "ome.xml",
157  DESC    => <<ZZ,
158A library for working with OME-XML metadata structures
159ZZ
160  LICENSE => "GPL",
161);
162
163my %slimPlotter = (
164  NAME    => "slim-plotter",
165  TITLE   => "SLIM Plotter",
166  PATH    => "components/slim-plotter",
167  JAR     => "SlimPlotter.jar",
168  PACKAGE => "loci.slim",
169  DESC    => <<ZZ,
170An application and curve fitting library for visualization and analysis of
171combined spectral lifetime data
172ZZ
173  LICENSE => "GPL",
174);
175
176my %testSuite = (
177  NAME    => "test-suite",
178  TITLE   => "LOCI testing framework",
179  PATH    => "components/test-suite",
180  JAR     => "loci-testing-framework.jar",
181  PACKAGE => "loci.tests",
182  DESC    => <<ZZ,
183Framework for automated and manual testing of the LOCI software packages
184ZZ
185  LICENSE => "BSD",
186);
187
188my %visbio = (
189  NAME    => "visbio",
190  TITLE   => "VisBio",
191  PATH    => "components/visbio",
192  JAR     => "visbio.jar",
193  PACKAGE => "loci.visbio",
194  DESC    => <<ZZ,
195A multi-purpose biological analysis tool
196ZZ
197  LICENSE => "GPL",
198);
199
200# -- COMPONENT DEFINITIONS - LEGACY --
201
202my %jvmlink = (
203  NAME    => "jvmlink",
204  TITLE   => "JVMLink",
205  PATH    => "components/legacy/jvmlink",
206  JAR     => "jvmlink.jar",
207  PACKAGE => "loci.jvmlink",
208  DESC    => <<ZZ,
209A library for communicating between a Java Virtual Machine and other programs
210(e.g., C++ applications) via IP over localhost (or remotely)
211ZZ
212  LICENSE => "BSD",
213);
214
215my %multiLUT = (
216  NAME    => "multi-lut",
217  TITLE   => "Multi-LUT",
218  PATH    => "components/legacy/multi-lut",
219  JAR     => "MultiLUT.jar",
220  PACKAGE => "loci.apps",
221  DESC    => <<ZZ,
222A demo application for visually exploring  multi-spectral image data
223ZZ
224  LICENSE => "Public domain",
225);
226
227my %omeEditor = (
228  NAME    => "ome-editor",
229  TITLE   => "OME Metadata Editor",
230  PATH    => "components/legacy/ome-editor",
231  JAR     => "ome-editor.jar",
232  PACKAGE => "loci.ome.editor",
233  DESC    => <<ZZ,
234An application for exploration and editing of OME-XML and OME-TIFF metadata
235ZZ
236  LICENSE => "LGPL",
237);
238
239my %omeNotes = (
240  NAME    => "ome-notes",
241  TITLE   => "OME Notes",
242  PATH    => "components/legacy/ome-notes",
243  JAR     => "ome-notes.jar",
244  PACKAGE => "loci.ome.notes",
245  DESC    => <<ZZ,
246A library for flexible organization and presentation of OME-XML metadata within
247a graphical browser and editor interface
248ZZ
249  LICENSE => "LGPL",
250);
251
252# -- COMPONENT DEFINITIONS - FORKS --
253
254my %jai = (
255  NAME    => "jai",
256  TITLE   => "JAI Image I/O Tools",
257  PATH    => "components/forks/jai",
258  JAR     => "jai_imageio.jar",
259  PACKAGE => "com.sun.media.imageioimpl",
260  DESC    => <<ZZ,
261Java API to handle JPEG and JPEG2000 files
262ZZ
263  LICENSE => "BSD",
264  URL     => "http://jai-imageio.dev.java.net/",
265  NOTES   => <<ZZ,
266Used by Bio-Formats to read images compressed with JPEG2000 and lossless JPEG.
267Modified from the 2008-10-14 source to include support for the YCbCr color
268space. Several files in the com.sun.media.jai packages were removed, as they
269are not needed by Bio-Formats, and created an additional dependency. This
270component will be removed once our changes have been added to the official JAI
271CVS repository.
272ZZ
273);
274
275my %mdbtools = (
276  NAME    => "mdbtools",
277  TITLE   => "MDB Tools (Java port)",
278  PATH    => "components/forks/mdbtools",
279  JAR     => "mdbtools-java.jar",
280  PACKAGE => "mdbtools",
281  DESC    => <<ZZ,
282Java API to handle Microsoft MDB format (Access)
283ZZ
284  LICENSE => "LGPL",
285  URL     => "http://sourceforge.net/forum/message.php?msg_id=2550619",
286  NOTES   => <<ZZ,
287Used by Bio-Formats for Zeiss LSM metadata in MDB files.
288ZZ
289);
290
291my %poi = (
292  NAME    => "poi",
293  TITLE   => "Apache Jakarta POI",
294  PATH    => "components/forks/poi",
295  JAR     => "poi-loci.jar",
296  PACKAGE => "loci.poi",
297  DESC    => <<ZZ,
298Java API to handle Microsoft OLE 2 Compound Document format (Word, Excel)
299ZZ
300  LICENSE => "Apache",
301  URL     => "http://jakarta.apache.org/poi/",
302  NOTES   => <<ZZ,
303Based on poi-2.5.1-final-20040804.jar, with bugfixes for OLE v2 and memory
304efficiency improvements. Used by Bio-Formats for OLE support (cxd, ipw, oib,
305zvi). Used by VisBio overlays logic for XLS export feature.
306ZZ
307);
308
309# -- COMPONENT DEFINITIONS - STUBS --
310
311my %lwfStubs = (
312  NAME    => "lwf-stubs",
313  TITLE   => "Luratech LuraWave stubs",
314  PATH    => "components/stubs/lwf-stubs",
315  JAR     => "lwf-stubs.jar",
316  PACKAGE => "com.luratech.lwf",
317  DESC    => <<ZZ,
318Stub of proprietary Java API to handle Luratech LWF compression
319ZZ
320  LICENSE => "BSD",
321  URL     => "http://www.luratech.com/",
322  NOTES   => <<ZZ,
323required to compile Bio-Formats's support for Luratech LWF compression for
324the Opera Flex format
325ZZ
326);
327
328# -- LIBRARY DEFINITIONS --
329
330my %appleJavaExtensions = (
331  NAME    => "AppleJavaExtensions",
332  TITLE   => "Apple eAWT stubs",
333  JAR     => "AppleJavaExtensions.jar",
334  PACKAGE => "com.apple",
335  LICENSE => "BSD",
336  URL     => "http://developer.apple.com/samplecode/AppleJavaExtensions/",
337  NOTES   => <<ZZ,
338required to compile Mac-specific functionality on non-Mac OS X machines
339ZZ
340);
341
342my %antContrib = (
343  NAME    => "ant-contrib",
344  TITLE   => "Ant-Contrib",
345  JAR     => "ant-contrib-1.0b3.jar",
346  PACKAGE => "net.sf.antcontrib",
347  LICENSE => "Apache",
348  URL     => "http://ant-contrib.sourceforge.net/",
349  NOTES   => <<ZZ,
350used by tools target to iterate over JAR files ("for" task)
351ZZ
352  VERSION => "1.0b3"
353);
354
355my %checkstyle = (
356  NAME    => "checkstyle",
357  TITLE   => "Checkstyle",
358  JAR     => "checkstyle-all-5.0.jar",
359  PACKAGE => "com.puppycrawl.tools.checkstyle",
360  LICENSE => "LGPL",
361  URL     => "http://checkstyle.sourceforge.net/",
362  NOTES   => <<ZZ,
363used by style Ant target to check source code style conventions
364ZZ
365  VERSION => "5.0"
366);
367
368my %commonsHTTPClient = (
369  NAME    => "commons-httpclient",
370  TITLE   => "Apache Jakarta Commons HttpClient",
371  JAR     => "commons-httpclient-2.0-rc2.jar",
372  PACKAGE => "org.apache.commons.httpclient",
373  LICENSE => "Apache",
374  URL     => "http://jakarta.apache.org/commons/httpclient/",
375  NOTES   => <<ZZ,
376required for OME-Java to communicate with OME servers
377ZZ
378  VERSION => "2.0-rc2"
379);
380
381my %commonsLogging = (
382  NAME    => "commons-logging",
383  TITLE   => "Apache Jakarta Commons Logging",
384  JAR     => "commons-logging.jar",
385  PACKAGE => "org.apache.commons.logging",
386  LICENSE => "Apache",
387  URL     => "http://jakarta.apache.org/commons/logging/",
388  NOTES   => <<ZZ,
389used by OME-Java
390ZZ
391  VERSION => "1.0.3"
392);
393
394my %findbugs = (
395  NAME    => "findbugs",
396  TITLE   => "FindBugs Ant task",
397  JAR     => "findbugs-ant.jar",
398  PACKAGE => "edu.umd.cs.findbugs.anttask",
399  LICENSE => "LGPL",
400  URL     => "http://findbugs.sourceforge.net/",
401  NOTES   => <<ZZ,
402used by findbugs Ant target to check for program bugs
403ZZ
404  VERSION => "1.3.9"
405);
406
407my %forms = (
408  NAME    => "forms",
409  TITLE   => "JGoodies Forms",
410  JAR     => "forms-1.3.0.jar",
411  PACKAGE => "com.jgoodies.forms",
412  LICENSE => "BSD",
413  URL     => "http://www.jgoodies.com/freeware/forms/index.html",
414  NOTES   => <<ZZ,
415used for layout by VisBio, Data Browser and OME Notes
416ZZ
417  VERSION => "1.3.0"
418);
419
420my %ice = (
421  NAME    => "ice",
422  TITLE   => "Ice",
423  JAR     => "Ice-3.3.1.jar",
424  PACKAGE => "Ice",
425  LICENSE => "GPL",
426  URL     => "http://www.zeroc.com/ice.html",
427  NOTES   => <<ZZ,
428used by Bio-Formats Ice framework
429ZZ
430  VERSIOn => "3.3.1"
431);
432
433my %ij = (
434  NAME    => "ij",
435  TITLE   => "ImageJ",
436  JAR     => "ij.jar",
437  PACKAGE => "ij",
438  LICENSE => "Public domain",
439  URL     => "http://rsb.info.nih.gov/ij/",
440  NOTES   => <<ZZ,
441used by LOCI plugins for ImageJ and OME plugins for ImageJ; bundled with VisBio
442to achieve ImageJ interconnectivity
443ZZ
444  VERSION => "1.43o"
445);
446
447my %jiio = (
448  NAME    => "jiio",
449  TITLE   => "JAI ImageIO wrapper",
450  JAR     => "clibwrapper_jiio.jar",
451  PACKAGE => "com.sun.medialib.codec",
452  LICENSE => "BSD",
453  URL     => "https://jai-imageio.dev.java.net/",
454  NOTES   => <<ZZ,
455used by Bio-Formats via reflection for JPEG2000 support (ND2, JP2) and lossless
456JPEG decompression (DICOM)
457ZZ
458  VERSION => "1.1"
459);
460
461my %junit = (
462  NAME    => "junit",
463  TITLE   => "JUnit",
464  JAR     => "junit.jar",
465  PACKAGE => "junit",
466  LICENSE => "Common Public License",
467  URL     => "http://www.junit.org/",
468  NOTES   => <<ZZ,
469unit testing framework used for a few VisBio unit tests
470ZZ
471  VERSION => "3.8.2"
472);
473
474my %lma = (
475  NAME    => "lma",
476  TITLE   => "L-M Fit",
477  JAR     => "lma.jar",
478  PACKAGE => "jaolho.data.lma",
479  LICENSE => "LGPL",
480  URL     => "http://users.utu.fi/jaolho/",
481  NOTES   => <<ZZ,
482Levenberg-Marquardt algorithm for exponential curve fitting, used by SLIM
483Plotter
484ZZ
485);
486
487my %log4j = (
488  NAME    => "log4j",
489  TITLE   => "Apache log4j",
490  JAR     => "log4j-1.2.15.jar",
491  PACKAGE => "org.apache.log4j",
492  LICENSE => "Apache",
493  URL     => "http://logging.apache.org/log4j/",
494  NOTES   => <<ZZ,
495required by SLF4J implementation
496ZZ
497  VERSION => "1.2.15"
498);
499
500my %looks = (
501  NAME    => "looks",
502  TITLE   => "JGoodies Looks",
503  JAR     => "looks-2.3.1.jar",
504  PACKAGE => "com.jgoodies.looks",
505  LICENSE => "BSD",
506  URL     => "http://www.jgoodies.com/freeware/looks/index.html",
507  NOTES   => <<ZZ,
508used for a nicer Look & Feel by VisBio and OME Metadata Editor
509ZZ
510  VERSION => "2.3.1"
511);
512
513my %netcdf = (
514  NAME    => "netcdf",
515  TITLE   => "NetCDF",
516  JAR     => "netcdf-4.0.jar",
517  PACKAGE => "ucar.nc2",
518  LICENSE => "LGPL",
519  URL     => "http://www.unidata.ucar.edu/software/netcdf-java/",
520  NOTES   => <<ZZ,
521used by Bio-Formats via reflection for HDF support (Imaris 5.5)
522ZZ
523  VERSION => "4.0"
524);
525
526my %omeJava = (
527  NAME    => "ome-java",
528  TITLE   => "OME-Java",
529  JAR     => "ome-java.jar",
530  PACKAGE => "org.openmicroscopy.[di]s",
531  LICENSE => "LGPL",
532  URL     => "http://www.openmicroscopy.org/site/documents/data-management/".
533             "ome-server/developer/java-api",
534  NOTES   => <<ZZ,
535used by OME I/O to connect to OME servers
536ZZ
537);
538
539my %omeJavaDeprecated = (
540  NAME    => "ome-java-deprecated",
541  TITLE   => "OME-Java deprecated classes",
542  JAR     => "ome-java-deprecated.jar",
543  PACKAGE => "org.openmicroscopy.xml",
544  LICENSE => "LGPL",
545  URL     => "http://www.openmicroscopy.org/site/documents/data-management/".
546             "ome-server/developer/java-api",
547  NOTES   => <<ZZ,
548used by OME Notes and OME Metadata Editor to work with OME-XML
549ZZ
550);
551
552my %omeroClient = (
553  NAME    => "omero-client",
554  TITLE   => "OMERO Client",
555  JAR     => "omero-client-4.1.1.jar",
556  PACKAGE => "ome.system",
557  LICENSE => "GPL",
558  URL     => "http://trac.openmicroscopy.org.uk/omero/wiki/MilestoneDownloads",
559  NOTES   => <<ZZ,
560used by OME I/O to connect to OMERO servers
561ZZ
562  VERSION => "4.1.1"
563);
564
565my %omeroCommon = (
566  NAME    => "omero-common",
567  TITLE   => "OMERO Common",
568  JAR     => "omero-common-4.1.1.jar",
569  PACKAGE => "ome.api",
570  LICENSE => "GPL",
571  URL     => "http://trac.openmicroscopy.org.uk/omero/wiki/MilestoneDownloads",
572  NOTES   => <<ZZ,
573used by OME I/O to connect to OMERO servers
574ZZ
575  VERSION => "4.1.1"
576);
577
578my %skinlf = (
579  NAME    => "skinlf",
580  TITLE   => "Skin Look and Feel",
581  JAR     => "skinlf.jar",
582  PACKAGE => "com.l2fprod",
583  LICENSE => "Custom (BSD-like)",
584  URL     => "http://skinlf.l2fprod.com/",
585  NOTES   => <<ZZ,
586not used (may be used in the future for flexible skinning)
587ZZ
588  VERSION => "6.7"
589);
590
591my %slf4j_api = (
592  NAME    => "slf4j-api",
593  TITLE   => "Simple Logging Facade for Java API",
594  JAR     => "slf4j-api-1.5.10.jar",
595  PACKAGE => "org.slf4j",
596  LICENSE => "BSD",
597  URL     => "http://www.slf4j.org/",
598  NOTES   => <<ZZ,
599used for all logging in loci.*
600ZZ
601  VERSION => "1.5.10"
602);
603
604my %slf4j_impl = (
605  NAME    => "slf4j-log4j",
606  TITLE   => "Simple Logging Facade for Java log4j Binding",
607  JAR     => "slf4j-log4j12-1.5.10.jar",
608  PACKAGE => "org.slf4j.impl",
609  LICENSE => "BSD",
610  URL     => "http://www.slf4j.org/",
611  NOTES   => <<ZZ,
612used for all logging in loci.*
613ZZ
614  VERSION => "1.5.10"
615);
616
617my %testng = (
618  NAME    => "testng",
619  TITLE   => "TestNG",
620  JAR     => "testng-5.11-jdk15.jar",
621  PACKAGE => "org.testng",
622  LICENSE => "Apache",
623  URL     => "http://testng.org/",
624  NOTES   => <<ZZ,
625testing framework used for LOCI software automated test suite
626ZZ
627  VERSION => "5.7"
628);
629
630my %velocity = (
631  NAME    => "velocity",
632  TITLE   => "Apache Velocity",
633  JAR     => "velocity-1.6.3-dep.jar",
634  PACKAGE => "org.apache.velocity",
635  LICENSE => "Apache",
636  URL     => "http://velocity.apache.org/",
637  NOTES   => <<ZZ,
638used to autogenerate the loci.formats.meta and loci.formats.ome Bio-Formats
639packages
640ZZ
641  VERSION => "1.6.3"
642);
643
644my %visad = (
645  NAME    => "visad",
646  TITLE   => "VisAD",
647  JAR     => "visad-lite.jar",
648  PACKAGE => "visad",
649  LICENSE => "LGPL",
650  URL     => "http://www.ssec.wisc.edu/~billh/visad.html",
651  NOTES   => <<ZZ,
652stripped down VisAD library used by VisBio and SLIM Plotter for interactive
653visualization
654ZZ
655);
656
657my %xmlrpc = (
658  NAME    => "xmlrpc",
659  TITLE   => "Apache XML-RPC",
660  JAR     => "xmlrpc-1.2-b1.jar",
661  PACKAGE => "org.apache.xmlrpc",
662  LICENSE => "Apache",
663  URL     => "http://ws.apache.org/xmlrpc/",
664  NOTES   => <<ZZ,
665used by OME-Java library to communicate with OME servers
666ZZ
667  VERSION => "1.2-b1"
668);
669
670# -- DATA STRUCTURES --
671
672# List of active LOCI software components
673my @active = (
674  \%autogen,
675  \%bfIce,
676  \%bioFormats,
677  \%flowCytometry,
678  \%lociChecks,
679  \%lociCommon,
680  \%lociPlugins,
681  \%omeIO,
682  \%omePlugins,
683  \%omeXML,
684  \%slimPlotter,
685  \%testSuite,
686  \%visbio,
687);
688
689# List of legacy components (no longer supported)
690my @legacy = (
691  \%jvmlink,
692  \%multiLUT,
693  \%omeEditor,
694  \%omeNotes,
695);
696
697# List of external project forks
698my @forks = (
699  \%jai,
700  \%mdbtools,
701  \%poi,
702);
703
704# List of external project stubs
705my @stubs = (
706  \%lwfStubs,
707);
708
709# List of all LOCI software components
710my @components = (@active, @legacy, @forks, @stubs);
711
712# List of external libraries
713my @libs = (
714  \%appleJavaExtensions,
715  \%antContrib,
716  \%checkstyle,
717  \%commonsHTTPClient,
718  \%commonsLogging,
719  \%findbugs,
720  \%forms,
721  \%ice,
722  \%ij,
723  \%jiio,
724  \%junit,
725  \%lma,
726  \%log4j,
727  \%looks,
728  \%netcdf,
729  \%slf4j_api,
730  \%slf4j_impl,
731  \%omeJava,
732  \%omeJavaDeprecated,
733  \%omeroClient,
734  \%omeroCommon,
735  \%skinlf,
736  \%testng,
737  \%velocity,
738  \%visad,
739  \%xmlrpc,
740);
741
742my $programErrors = 0;
743
744# -- ARGUMENT PARSING --
745
746my $skipSummary = 0;
747foreach my $arg (@ARGV) {
748  if ($arg eq '-nosummary') {
749    $skipSummary = 1;
750  }
751}
752
753# -- DATA COLLECTION --
754
755# verify that all JAR files exist -- if not, this file is probably out of date
756print STDERR "--== VERIFYING JAR FILE EXISTENCE ==--\n\n";
757foreach my $c (@components) {
758  my $jar = $$c{JAR};
759  unless (-e "artifacts/$jar") {
760    die "Component $jar does not exist";
761  }
762}
763foreach my $l (@libs) {
764  my $jar = $$l{JAR};
765  unless (-e "jar/$jar") {
766    die "Library $jar does not exist";
767  }
768}
769
770# scan for project dependencies
771print STDERR "--== SCANNING PROJECT DEPENDENCIES ==--\n\n";
772foreach my $c (@components) {
773  my $path = $$c{PATH};
774  print STDERR "[$$c{TITLE}]\n";
775  my @deps = ();
776  my @opt = ();
777  foreach my $c2 (@components) {
778    if ($c eq $c2) { next; }
779    my $name = $$c2{TITLE};
780    my $package = $$c2{PACKAGE};
781    if (checkDirect($package, $path)) {
782      push (@deps, $c2);
783      print STDERR "$name\n";
784    }
785    elsif (checkReflect($package, $path)) {
786      push (@opt, $c2);
787      print STDERR "$name [reflected]\n";
788    }
789  }
790  $$c{PROJ_DEPS} = \@deps;
791  $$c{PROJ_OPT} = \@opt;
792  print STDERR "\n";
793}
794
795print STDERR "--== SCANNING LIBRARY DEPENDENCIES ==--\n\n";
796foreach my $c (@components) {
797  my @deps = ();
798  my @opt = ();
799  my $path = $$c{PATH};
800  print STDERR "[$$c{TITLE}]\n";
801  foreach my $l (@libs) {
802    my $name = $$l{TITLE};
803    my $package = $$l{PACKAGE};
804    if (checkDirect($package, $path)) {
805      push (@deps, $l);
806      print STDERR "$name\n";
807    }
808    elsif (checkReflect($package, $path)) {
809      push (@opt, $l);
810      print STDERR "$name [reflected]\n";
811    }
812  }
813  $$c{LIB_DEPS} = \@deps;
814  $$c{LIB_OPT} = \@opt;
815  print STDERR "\n";
816}
817
818print STDERR "--== GATHERING COMPONENT CLASSPATHS ==--\n\n";
819foreach my $c (@components) {
820  my $path = $$c{PATH};
821
822  # read compile-time and runtime classpaths from properties file
823  open FILE, "$path/build.properties"
824    or die "$path/build.properties: $!";
825  my @lines = <FILE>;
826  close(FILE);
827  my $inCompile = 0;
828  my $inManifest = 0;
829  my @compile = ();
830  my @runtime = ();
831  foreach my $line (@lines) {
832    $line = rtrim($line);
833    if ($line =~ /^component.classpath/) {
834      # found the compile-time classpath variable
835      $inCompile = 1;
836    }
837    elsif ($line =~ /^component.runtime-cp/) {
838      # found the runtime classpath variable
839      $inManifest = 1;
840    }
841    if ($inCompile || $inManifest) {
842      my $end = $line !~ /\\$/;
843      # append the entry to the classpath list
844      $line =~ s/[ :\\]*$//;
845      $line =~ s/.*[ =]+//;
846      if ($line ne '(none)' && $line ne '') {
847        if ($inCompile) {
848          push(@compile, $line);
849        }
850        elsif ($inManifest) {
851          if ($line =~ /\${component.classpath}/) {
852            push(@runtime, @compile);
853          }
854          else {
855            push(@runtime, $line);
856          }
857        }
858      }
859      if ($end) {
860        # line does not end with a backslash; end of variable
861        $inCompile = $inManifest = 0;
862      }
863    }
864  }
865  $$c{COMPILE} = \@compile;
866  $$c{RUNTIME} = \@runtime;
867}
868
869print STDERR "--== GATHERING ECLIPSE DEPENDENCIES ==--\n\n";
870foreach my $c (@components) {
871  my $path = $$c{PATH};
872
873  # read Eclipse classpath from classpath file
874  open FILE, "$path/.classpath"
875    or die "$path/.classpath: $!";
876  my @lines = <FILE>;
877  close(FILE);
878  my @eclipse = ();
879  foreach my $line (@lines) {
880    $line = rtrim($line);
881    if ($line =~ /<classpathentry /) {
882      # found a compile-time classpath entry
883      $line =~ s/.* path="//;
884      $line =~ s/"\/>$//;
885      push(@eclipse, $line);
886    }
887  }
888  @eclipse = sort @eclipse;
889  $$c{ECLIPSE} = \@eclipse;
890}
891
892# -- DATA VERIFICATION --
893
894print STDERR "--== VERIFYING CLASSPATH MATCHES ==--\n\n";
895foreach my $c (@components) {
896  my @projDeps = @{$$c{PROJ_DEPS}};
897  my @libDeps = @{$$c{LIB_DEPS}};
898  my @projOpt = @{$$c{PROJ_OPT}};
899  my @libOpt = @{$$c{LIB_OPT}};
900  my $name = $$c{TITLE};
901  my $path = $$c{PATH};
902  my @deps;
903
904  # verify compile-time classpath
905  my @compile = ();
906  foreach my $dep (@projDeps) {
907    push(@compile, "\${artifact.dir}/$$dep{JAR}");
908  }
909  foreach my $dep (@libDeps) {
910    push(@compile, "\${lib.dir}/$$dep{JAR}");
911  }
912  @compile = sort @compile;
913  my @cp = @{$$c{COMPILE}};
914  my $compileError = 0;
915  if (@compile != @cp) {
916    print STDERR "Dependency mismatch for $name compile time classpath:\n";
917    $compileError = 1;
918  }
919  else {
920    for (my $i = 0; $i < @cp; $i++) {
921      my $depJar = $compile[$i];
922      my $cpJar = $cp[$i];
923      if ($cpJar ne $depJar) {
924        print STDERR "Dependency mismatch for $name compile time classpath:\n";
925        print STDERR "  #$i: $depJar != $cpJar\n";
926        $compileError = 1;
927        last;
928      }
929    }
930  }
931  if ($compileError) {
932    print STDERR "  component.classpath:\n";
933    print STDERR "    Actual    = @cp\n";
934    print STDERR "    Synthetic = @deps\n";
935    print STDERR "\n";
936    print STDERR "  project deps =";
937    foreach my $q (@projDeps) {
938      print STDERR " $$q{NAME}";
939    }
940    print STDERR "\n";
941    print STDERR "  library deps =";
942    foreach my $q (@libDeps) {
943      print STDERR " $$q{NAME}";
944    }
945    print STDERR "\n";
946    $programErrors++;
947  }
948
949  # verify Eclipse classpath
950  @deps = ();
951  push(@deps, "src");
952  if (-e "$path/test") {
953    push(@deps, "test");
954  }
955  push(@deps, "org.eclipse.jdt.launching.JRE_CONTAINER");
956  foreach my $dep (@projDeps) {
957    push(@deps, "/$$dep{NAME}");
958  }
959  if (@libDeps > 0) {
960    push(@deps, "/External libraries");
961    foreach my $q (@libDeps) {
962      if ($$q{NAME} eq $testng{NAME}) {
963        push(@deps, "org.testng.TESTNG_CONTAINER");
964      }
965    }
966  }
967  push(@deps, "build-eclipse");
968  @deps = sort @deps;
969  @cp = @{$$c{ECLIPSE}};
970  my $eclipseError = 0;
971  if (@deps != @cp) {
972    print STDERR "Dependency mismatch for $name Eclipse classpath:\n";
973    $eclipseError = 1;
974  }
975  else {
976    for (my $i = 0; $i < @cp; $i++) {
977      my $depEntry = $deps[$i];
978      my $cpEntry = $cp[$i];
979      if ($cpEntry ne $depEntry) {
980        print STDERR "Dependency mismatch for $name Eclipse classpath:\n";
981        print STDERR "  #$i: $depEntry != $cpEntry\n";
982        $eclipseError = 1;
983        last;
984      }
985    }
986  }
987  if ($eclipseError) {
988    print STDERR "  Eclipse classpath:\n";
989    print STDERR "    Actual    = @cp\n";
990    print STDERR "    Synthetic = @deps\n";
991    print STDERR "\n";
992    print STDERR "  project deps =";
993    foreach my $q (@projDeps) {
994      print STDERR " $$q{NAME}";
995    }
996    print STDERR "\n";
997    print STDERR "  library deps =";
998    foreach my $q (@libDeps) {
999      print STDERR " $$q{NAME}";
1000    }
1001    print STDERR "\n";
1002    $programErrors++;
1003  }
1004
1005  # verify runtime classpath
1006  my @runtime = ();
1007  foreach my $dep (@projOpt) {
1008    push(@runtime, "\${artifact.dir}/$$dep{JAR}");
1009  }
1010  foreach my $dep (@libOpt) {
1011    push(@runtime, "\${lib.dir}/$$dep{JAR}");
1012  }
1013  @runtime = sort @runtime;
1014  @deps = (@compile, @runtime);
1015  @cp = @{$$c{RUNTIME}};
1016  my $runtimeError = 0;
1017  if (@deps != @cp) {
1018    print STDERR "Dependency mismatch for $name runtime classpath:\n";
1019    $runtimeError = 1;
1020  }
1021  else {
1022    for (my $i = 0; $i < @cp; $i++) {
1023      my $depJar = $deps[$i];
1024      my $cpJar = $cp[$i];
1025      if ($cpJar ne $depJar) {
1026        print STDERR "Dependency mismatch for $name runtime classpath:\n";
1027        print STDERR "  #$i: $depJar != $cpJar\n";
1028        $runtimeError = 1;
1029        last;
1030      }
1031    }
1032  }
1033  if ($runtimeError) {
1034    print STDERR "  component.runtime-cp:\n";
1035    print STDERR "    Actual    = @cp\n";
1036    print STDERR "    Synthetic = @deps\n";
1037    print STDERR "\n";
1038    print STDERR "  project deps        =";
1039    foreach my $q (@projDeps) {
1040      print STDERR " $$q{NAME}";
1041    }
1042    print STDERR "\n";
1043    print STDERR "  reflected projects  =";
1044    foreach my $q (@projOpt) {
1045      print STDERR " $$q{NAME}";
1046    }
1047    print STDERR "\n";
1048    print STDERR "  library deps        =";
1049    foreach my $q (@libDeps) {
1050      print STDERR " $$q{NAME}";
1051    }
1052    print STDERR "\n";
1053    print STDERR "  reflected libraries =";
1054    foreach my $q (@libOpt) {
1055      print STDERR " $$q{NAME}";
1056    }
1057    $programErrors++;
1058  }
1059}
1060
1061if ($skipSummary) {
1062  exit $programErrors;
1063}
1064
1065# -- FORMATTED DATA OUTPUT --
1066
1067print STDERR "--== DUMPING RESULTS TO STDOUT ==--\n\n";
1068
1069my $div = <<ZZ;
1070===============================================================================
1071ZZ
1072
1073# components - active
1074print "$div";
1075print "This build file handles the following components.\n";
1076print "For more information on a component, see the\n";
1077print "build.properties file in that component's subtree.\n";
1078print "Run ./scan-deps.pl to programmatically generate this list.\n\n";
1079foreach my $c (@active) {
1080  print "$$c{TITLE}\n";
1081  smartSplit("    ", " ", split(/[ \n]/, $$c{DESC}));
1082  print "    -=-\n";
1083  print "    JAR file:      $$c{JAR}\n";
1084  print "    Path:          $$c{PATH}\n";
1085
1086  my $lead = "                   ";
1087
1088  my @projDeps = @{$$c{PROJ_DEPS}};
1089  my @prettyDeps = ();
1090  foreach my $q (@projDeps) {
1091    push(@prettyDeps, $$q{TITLE});
1092  }
1093  smartSplit("    Project deps:  ", ", ", @prettyDeps);
1094
1095  my @libDeps = @{$$c{LIB_DEPS}};
1096  @prettyDeps = ();
1097  foreach my $q (@libDeps) {
1098    push(@prettyDeps, $$q{TITLE});
1099  }
1100  smartSplit("    Library deps:  ", ", ", @prettyDeps);
1101
1102  my @projOpt = @{$$c{PROJ_OPT}};
1103  my @prettyOpt = ();
1104  foreach my $q (@projOpt) {
1105    push(@prettyOpt, $$q{TITLE});
1106  }
1107  my @libOpt = @{$$c{LIB_OPT}};
1108  foreach my $q (@libOpt) {
1109    push(@prettyOpt, $$q{TITLE});
1110  }
1111  smartSplit("    Optional:      ", ", ", @prettyOpt);
1112
1113  print "    License:       $$c{LICENSE}\n";
1114  print "\n";
1115}
1116
1117# components - legacy
1118print "$div";
1119print "The following components are considered \"legacy\" but still " .
1120      "available:\n\n";
1121foreach my $c (@legacy) {
1122  print "$$c{TITLE}\n";
1123  smartSplit("    ", " ", split(/[ \n]/, $$c{DESC}));
1124  print "    -=-\n";
1125  print "    JAR file:      $$c{JAR}\n";
1126  print "    Path:          $$c{PATH}\n";
1127
1128  my $lead = "                   ";
1129
1130  my @deps = @{$$c{PROJ_DEPS}};
1131  my @prettyDeps = ();
1132  foreach my $q (@deps) {
1133    push(@prettyDeps, $$q{TITLE});
1134  }
1135  smartSplit("    Project deps:  ", ", ", @prettyDeps);
1136
1137  my @opt = @{$$c{PROJ_OPT}};
1138  my @prettyOpt = ();
1139  foreach my $q (@opt) {
1140    push(@prettyOpt, $$q{TITLE});
1141  }
1142  smartSplit("    Optional:      ", ", ", @prettyOpt);
1143
1144  print "    License:       $$c{LICENSE}\n";
1145  print "\n";
1146}
1147
1148# components - forks
1149for (my $i = 0; $i < 2; $i++) {
1150  print "$div";
1151  my @list;
1152  if ($i == 0) {
1153    @list = @forks;
1154    print "The following components are forks of third party projects:\n\n";
1155  }
1156  else {
1157    @list = @stubs;
1158    print "The following components are stubs of third party projects:\n\n";
1159  }
1160  foreach my $c (@list) {
1161    print "$$c{TITLE}\n";
1162    smartSplit("    ", " ", split(/[ \n]/, $$c{DESC}));
1163    print "    -=-\n";
1164    print "    JAR file:      $$c{JAR}\n";
1165    print "    Path:          $$c{PATH}\n";
1166
1167    my @deps = @{$$c{PROJ_DEPS}};
1168    my @prettyDeps = ();
1169    foreach my $q (@deps) {
1170      push(@prettyDeps, $$q{TITLE});
1171    }
1172    smartSplit("    Project deps:  ", ", ", @prettyDeps);
1173
1174    my @opt = @{$$c{PROJ_OPT}};
1175    my @prettyOpt = ();
1176    foreach my $q (@opt) {
1177      push(@prettyOpt, $$q{TITLE});
1178    }
1179    smartSplit("    Optional:      ", ", ", @prettyOpt);
1180
1181    print "    License:       $$c{LICENSE}\n";
1182    print "    Project URL:   $$c{URL}\n";
1183    smartSplit("    Notes:         ", " ", split(/[ \n]/, $$c{NOTES}));
1184    print "\n";
1185  }
1186}
1187
1188# libraries
1189print "$div";
1190print "The following external dependencies (in the jar folder) may be " .
1191      "required:\n";
1192foreach my $l (@libs) {
1193  print "$$l{TITLE}\n";
1194  print "    JAR file:  $$l{JAR}\n";
1195  print "    URL:       $$l{URL}\n";
1196  smartSplit("    Notes:     ", " ", split(/[ \n]/, $$l{NOTES}));
1197  print "    License:   $$l{LICENSE}\n";
1198  print "\n";
1199}
1200
1201exit $programErrors;
1202
1203# -- SUBROUTINES --
1204
1205sub checkDirect {
1206  my ($package, $path) = @_;
1207  return `find $path -name '*.java' | xargs grep -l "^import $package\\."`;
1208}
1209
1210sub checkReflect {
1211  my ($package, $path) = @_;
1212  return `find $path -name '*.java' | xargs grep -l "optional $package"`;
1213}
1214
1215sub smartSplit {
1216  my ($front, $div, @list) = @_;
1217  my $lead = $front;
1218  $lead =~ s/./ /g;
1219  my $tDiv = rtrim($div);
1220  my $end = 79;
1221  my $len = @list;
1222  my $line = $front;
1223  if ($len == 0) {
1224    $line .= "(none)";
1225  }
1226  for (my $i = 0; $i < $len; $i++) {
1227    my $item = $list[$i];
1228    if ($item eq '') { next; }
1229    if ($i == 0) {
1230      # first item
1231      $line .= $item;
1232    }
1233    else {
1234      my $q = $line . $div . $item;
1235      my $max = $i == $len - 1 ? $end : $end - length($tDiv);
1236      if (length($q) > $max) {
1237        # line wrap
1238        $line .= $tDiv;
1239        print "$line\n";
1240        $line = $lead . $item;
1241      }
1242      else {
1243        # append
1244        $line = $q;
1245      }
1246    }
1247  }
1248  print "$line\n";
1249}
1250
1251sub rtrim {
1252  my $string = shift;
1253  $string =~ s/\s+$//;
1254  return $string;
1255}
Note: See TracBrowser for help on using the repository browser.