src/JavaLibraries.st
branchjk_new_structure
changeset 756 dd9543675518
parent 754 a3d9edeb7d73
child 758 be8e84381ce0
--- a/src/JavaLibraries.st	Fri Apr 08 14:14:47 2011 +0000
+++ b/src/JavaLibraries.st	Fri Apr 08 15:08:34 2011 +0000
@@ -8,6 +8,95 @@
 !
 
 
+!JavaLibraries class methodsFor:'accessing'!
+
+directory
+
+    ^Java cacheDirectory / 'libs'
+
+    "
+        JavaLibraries directory   
+    "
+
+    "Created: / 08-04-2011 / 16:27:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+url
+
+    ^stx_libjava svnRepositoryUrlBase , '/libs'
+
+    "Created: / 08-04-2011 / 16:32:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLibraries class methodsFor:'private'!
+
+checkoutDirectory
+
+    OperatingSystem getNetworkAddresses size < 2 
+        ifTrue:
+            [self error: 'No network connection!!'. ^self].
+
+    (OperatingSystem
+        executeCommand:('svn co %1 %2' bindWith: self url with: self directory asString))
+        ifFalse:
+            [self error: 'Cannot checkout libraries!!'. ^self].
+
+    "Created: / 08-04-2011 / 16:38:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+updateDirectory
+
+    OperatingSystem getNetworkAddresses size < 2 
+        ifTrue:
+            [^self].
+
+    (OperatingSystem
+        executeCommand:('svn update %1 %2' bindWith: self url with: self directory asString))
+        ifFalse:
+            [self error: 'Cannot update libraries!!'. ^self].
+
+    "Created: / 08-04-2011 / 16:38:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
+!JavaLibraries class methodsFor:'utilities'!
+
+addToClassPath: jarname
+
+    | dir jar |
+
+    (dir := self directory) exists 
+        ifFalse:[self update].
+
+    (jar := dir / jarname) exists 
+        ifTrue: [Java addToClassPath: jar pathName]
+        ifFalse:[self error:'Library ' , jarname , ' not found in ', dir pathName].
+
+    "
+        JavaLibraries addToClassPath:'junit4.jar'.
+        Java classPath
+    "
+
+    "Created: / 08-04-2011 / 16:49:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+flush
+
+    self directory recursiveRemove
+
+    "Created: / 08-04-2011 / 16:27:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+update
+
+    | dir |
+    dir := self directory.
+    dir exists 
+        ifTrue: [self updateDirectory]
+        ifFalse:[self checkoutDirectory]
+
+    "Created: / 08-04-2011 / 16:29:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaLibraries class methodsFor:'documentation'!
 
 version_SVN