tools/extensions.st
changeset 3409 f9d023dc6606
parent 2841 6fa1bcf9c997
child 3496 e1e02c2f3b94
child 3730 9515eedef000
--- a/tools/extensions.st	Tue Mar 17 20:56:13 2015 +0000
+++ b/tools/extensions.st	Thu Mar 19 17:27:21 2015 +0000
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "{ Package: 'stx:libjava/tools' }"!
 
 !ConfigurableFeatures class methodsFor:'queries-features'!
@@ -34,6 +36,77 @@
     "Created: / 18-02-2012 / 16:44:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaCodeLibrary methodsFor:'validating'!
+
+validate
+    "Validate this Java library and raise validation warning for each
+     problem. A caller may give up upon first problem of proceed to collect
+     all warnings."
+
+    classes isNil ifTrue:[ 
+        JavaCodeLibraryValidationError classesNotSpecified newException
+            messageText: 'No classes specified';
+            parameter: self;
+            raiseRequest
+    ] ifFalse:[ 
+        | classesFile |
+
+        classesFile := classes asFilename.
+        classesFile exists ifTrue:[ 
+            (classesFile isRegularFile and:[(ZipArchive isZipArchive: classes) not]) ifTrue:[
+                JavaCodeLibraryValidationWarning classesArchiveInvalid newException
+                    messageText: 'Classes archive is not a valid .jar / .zip archive: ', classes;
+                    parameter: self;
+                    raiseRequest
+            ]
+        ] ifFalse:[ 
+            JavaCodeLibraryValidationWarning classesDontExist newException
+                messageText: ('Classes doesn''t exist: ' , classes);
+                parameter: self;
+                raiseRequest
+        ].
+    ].
+    sources notNil ifTrue:[
+        | sourcesFile |
+
+        sourcesFile := sources asFilename.
+        sourcesFile exists ifTrue:[ 
+            (sourcesFile isRegularFile and:[(ZipArchive isZipArchive: sources) not]) ifTrue:[
+                JavaCodeLibraryValidationWarning sourcesArchiveInvalid newException
+                    messageText: 'Sources archive is not a valid .jar / .zip archive: ' , sources;
+                    parameter: self;
+                    raiseRequest
+            ]
+        ] ifFalse:[ 
+            JavaCodeLibraryValidationWarning sourcesDontExist newException
+                messageText: ('Sources dont exist: ' , sources);
+                parameter: self;
+                raiseRequest
+        ].
+    ].         
+    javadoc notNil ifTrue:[
+        | javadocFile |
+
+        javadocFile := javadoc asFilename.
+        javadocFile exists ifTrue:[ 
+            (javadocFile isRegularFile and:[(ZipArchive isZipArchive: sources) not]) ifTrue:[
+                JavaCodeLibraryValidationWarning sourcesArchiveInvalid newException
+                    messageText: 'JavaDoc archive is not a valid .zip archive: ' , javadoc;
+                    parameter: self;
+                    raiseRequest
+            ]
+        ] ifFalse:[ 
+            JavaCodeLibraryValidationWarning sourcesDontExist newException
+                messageText: ('JavaDoc doesnt exist: ' , javadoc);
+                parameter: self;
+                raiseRequest
+        ].
+    ].
+
+    "Created: / 19-03-2015 / 11:58:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 19-03-2015 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaObject methodsFor:'inspecting'!
 
 inspectorClass