5
5
import java .io .FilenameFilter ;
6
6
import java .io .IOException ;
7
7
import java .util .ArrayList ;
8
+ import java .util .Arrays ;
8
9
import java .util .Collections ;
9
10
import java .util .HashSet ;
10
11
import java .util .List ;
@@ -104,9 +105,32 @@ public void run(final String[] args) throws FileNotFoundException, XMLStreamExce
104
105
SummaryGenerator generator = new SummaryGeneratorFactory ().initSummaryGenerator ();
105
106
106
107
// Parse the mandatory arguments
107
- File toAnalyze = new File ( extraArgs [0 ]) ;
108
+ String toAnalyze = extraArgs [0 ];
108
109
File outputFolder = new File (extraArgs [1 ]);
109
110
111
+ // Check if the given files to analyze do exist
112
+ List <String > filesToAnalyze = Arrays .asList (toAnalyze .split (File .pathSeparator ));
113
+ for (String fileStr : filesToAnalyze ) {
114
+ File file = new File (fileStr );
115
+ if (!file .exists ()) {
116
+ System .err .println ("File not found: " + file );
117
+ System .exit (1 );
118
+ return ;
119
+ }
120
+ if (file .isDirectory ()) {
121
+ File [] files = file .listFiles (new FilenameFilter () {
122
+ @ Override
123
+ public boolean accept (File dir , String name ) {
124
+ return name .toLowerCase ().endsWith (".jar" );
125
+ }
126
+ });
127
+ for (int c = 0 ; c < files .length ; c ++) {
128
+ File f = files [c ];
129
+ toAnalyze += File .pathSeparator + f .getPath ();
130
+ }
131
+ }
132
+ }
133
+
110
134
// Collect the classes to be analyzed from our command line
111
135
List <String > classesToAnalyze = new ArrayList <>();
112
136
if (!summarizeFullJAR ) {
@@ -133,38 +157,10 @@ public void run(final String[] args) throws FileNotFoundException, XMLStreamExce
133
157
configureOptionalSettings (cmd , generator );
134
158
135
159
// Configure the output directory
136
- if (!toAnalyze .exists ()) {
137
- System .err .println ("File not found: " + toAnalyze );
138
- System .exit (1 );
139
- return ;
140
- }
141
160
generator .getConfig ().addAdditionalSummaryDirectory (outputFolder .getAbsolutePath ());
142
161
143
162
// Run it
144
- if (toAnalyze .isDirectory ()) {
145
- File [] files = toAnalyze .listFiles (new FilenameFilter () {
146
-
147
- @ Override
148
- public boolean accept (File dir , String name ) {
149
- return name .toLowerCase ().endsWith (".jar" );
150
- }
151
-
152
- });
153
- for (int c = 0 ; c < files .length ; c ++) {
154
- File f = files [c ];
155
- System .out .println (String .format ("Jar %d of %d: %s" , c + 1 , files .length , f ));
156
- createSummaries (generator , classesToAnalyze , forceOverwrite , f , outputFolder );
157
- }
158
-
159
- // If we don't have any JAR files, the target may be a normal classpath with
160
- // Java class files
161
- if (files .length == 0 ) {
162
- System .out .println (String .format ("Analyzing directory %s..." , toAnalyze .getAbsolutePath ()));
163
- createSummaries (generator , classesToAnalyze , forceOverwrite , toAnalyze , outputFolder );
164
- }
165
- } else {
166
- createSummaries (generator , classesToAnalyze , forceOverwrite , toAnalyze , outputFolder );
167
- }
163
+ createSummaries (generator , classesToAnalyze , forceOverwrite , toAnalyze , outputFolder );
168
164
169
165
System .out .println ("Done." );
170
166
} catch (ParseException e ) {
@@ -236,8 +232,8 @@ private void printHelpMessage() {
236
232
}
237
233
238
234
private static void createSummaries (SummaryGenerator generator , List <String > classesToAnalyze ,
239
- final boolean doForceOverwrite , File toAnalyze , File outputFolder ) {
240
- ClassSummaries summaries = generator .createMethodSummaries (toAnalyze . getPath () , classesToAnalyze ,
235
+ final boolean doForceOverwrite , String toAnalyze , File outputFolder ) {
236
+ ClassSummaries summaries = generator .createMethodSummaries (toAnalyze , classesToAnalyze ,
241
237
new IClassSummaryHandler () {
242
238
243
239
@ Override
0 commit comments