JavaCodeBundle.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 01 May 2013 15:07:27 +0100
branchdevelopment
changeset 2573 59aeefc96cf4
parent 2566 f1cea8b752ba
child 2578 fc6186a4961f
permissions -rw-r--r--
Improvement in benchmark runner - option to turn JIT on/off.

"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010
"
"{ Package: 'stx:libjava' }"

JavaCodeLibraryOrBundle subclass:#JavaCodeBundle
	instanceVariableNames:'libraries'
	classVariableNames:'Root'
	poolDictionaries:''
	category:'Languages-Java-Support-Libraries'
!

!JavaCodeBundle class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1996-2011 by Claus Gittinger

 New code and modifications done at SWING Research Group [1]:

 COPYRIGHT (c) 2010-2011 by Jan Vrany, Jan Kurs and Marcel Hlopko
                            SWING Research Group, Czech Technical University in Prague

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.

 [1] Code written at SWING Research Group contains a signature
     of one of the above copright owners. For exact set of such code,
     see the differences between this version and version stx:libjava
     as of 1.9.2010

"
!

documentation
"
    A container for several JavaCodeLibraries bundled together.

    [author:]
        Jan Vrany <jan.vrany@fit.cvut.cz>

    [instance variables:]

    [class variables:]

    [see also:]

"
! !

!JavaCodeBundle class methodsFor:'instance creation'!

new
    "return an initialized instance"

    ^ self basicNew initialize.
!

standardPackageBundleFor: packageId
    "Return bundle for packageId. Assumes that that
     package has standard layout, i.e.,

     <package-dir>/java
        bin ..................... compiler .class files
        src ..................... java sources
        libs .................... required .jar files
        libs-src ................ (optional) sources code for .jars
    "
        
    | bundle lib pkg javadir p libs libssrc |

    pkg := ProjectDefinition definitionClassForPackage: packageId.
    pkg isNil ifTrue:[ ^ nil ].
    javadir := pkg packageDirectory / 'java'.
    (javadir isDirectory not or:[javadir isReadable not]) ifTrue:[ ^ nil ].
    bundle := JavaCodeBundle new name: pkg package.
    (p := javadir / 'bin') isDirectory ifTrue:[
        lib := JavaCodeLibrary new name: 'java'.
        lib classes: p pathName.
        (p := javadir /'src') isDirectory ifTrue:[
            lib sources: p pathName
        ].
        bundle add: lib.
    ].
    libs := javadir / 'libs'.
    libssrc := javadir / 'libs-src'.
    libs isDirectory ifTrue:[
        libs directoryContentsAsFilenamesDo:[:each|
            each suffix = 'jar' ifTrue:[
                lib := JavaCodeLibrary new name: each baseName.
                lib classes: each pathName.
                (p :=  libssrc / (each withoutSuffix baseName , '-sources.jar') ) exists ifTrue:[
                    lib sources: p pathName.
                ] ifFalse:[
                    (p :=  libssrc / (each withoutSuffix baseName , '-sources.zip') ) exists ifTrue:[
                        lib sources: p pathName.            
                    ].
                ].
                bundle add: lib.
            ].
        ].
    ].
    ^bundle

    "
        JavaCodeBundle standardPackageBundleFor: #'stx:libjava'
        JavaCodeBundle standardPackageBundleFor: #'stx:libjava/libs'
    "

    "Created: / 15-01-2013 / 17:05:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'accessing'!

/ name
    ^libraries detect:[:e|e name = name] ifNone:[self error:'No such library or sub-bundle'].

    "Created: / 12-02-2013 / 15:07:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

libraries
    ^ libraries

    "Modified: / 15-01-2013 / 17:32:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'adding & removing'!

add: libraryOrBundle

    libraries add: libraryOrBundle.
    self changed: #libraries.

    "Created: / 12-01-2013 / 16:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 22-02-2013 / 15:18:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

remove: libraryOrBundle

    libraries remove: libraryOrBundle.
    self changed: #libraries.

    "Created: / 12-01-2013 / 16:08:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 22-02-2013 / 15:38:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'enumerating'!

allLibrariesDo:aBlock 
    "Enumerate all libraries in the bundle and evaluate
     aBlock on each of them"
    
    self libraries do:[:each | 
        each allLibrariesDo:aBlock
    ]

    "Modified: / 07-03-2013 / 12:05:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'generating'!

classPathOn:aStream
    "superclass JavaCodeLibraryOrBundle says that I am responsible to implement this method"

    ^ self libraries do:[:each|each classPathOn: aStream].

    "Modified: / 15-01-2013 / 17:32:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

sourcePathOn:aStream
    "superclass JavaCodeLibraryOrBundle says that I am responsible to implement this method"

    ^ self libraries do:[:each|each sourcePathOn: aStream].

    "Created: / 12-01-2013 / 16:24:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
    "Modified: / 15-01-2013 / 17:32:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'initialization'!

initialize
    "Invoked when a new instance is created."

    "/ please change as required (and remove this comment)
    libraries := OrderedCollection new.

    "/ super initialize.   -- commented since inherited method does nothing

    "Modified: / 12-01-2013 / 16:07:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle methodsFor:'testing'!

isBundle
    ^true

    "Created: / 25-01-2013 / 21:44:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !

!JavaCodeBundle class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libjava/JavaCodeBundle.st,v 1.3 2013-03-07 15:32:16 +0000 vrany Exp $'
!

version_CVS
    ^ '$Header: /cvs/stx/stx/libjava/JavaCodeBundle.st,v 1.3 2013-03-07 15:32:16 vrany Exp $'
!

version_HG

    ^ 'Changeset: <not expanded> '
! !