JavaCodeBundle.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 30 Jan 2013 13:27:16 +0000
branchrefactoring-vmdata
changeset 2008 c348b894fbfe
parent 2004 160dfe552938
child 2062 8bf477337331
permissions -rw-r--r--
Merged ef3da336a6c9 and 6eac81f7f606 (branch development.)

"
 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'!

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

    "Created: / 12-01-2013 / 16:08:26 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

remove: libraryOrBundle

    libraries remove: libraryOrBundle

    "Created: / 12-01-2013 / 16:08:31 / 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_HG

    ^ '$Changeset: <not expanded> $'
! !