facebook

Directory Structure

  1. MyEclipse IDE
  2.  > 
  3. Off Topic
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #252982 Reply

    Samer Kanjo
    Participant

    I am curious as to how others are structuring their application directories and how they are managing Eclipse projects within that structure and whether or not Ant is being used. I know with the Eclipse recommendation is to have single project for each of your JARs, WARs EJBs and EAR.

    So assuming I use the following layers:

    dao
    domain
    service
    remote
    webapp

    I would create one service project which encapsulated the service, domain, and dao layers. This project would then be included in the webapp project and the remote project. It could also potentially be included in command line interface projects or rich application interface projects. The projects would be defined as follows in Eclipse:

    MyApp Service
    MyApp Remote
    MyApp Webapp

    This is all fine but problems occur when I start to consider my target environments: dev, test, train, and prod. I have property files that define environment specific values such as database connection information, mail server, etc. These properties change from one environment to the other.

    For example, if I had a database.properties file that defined the following:

    db.driver=@DB_DRIVER@
    db.url=@DB_URL@
    db.user=@DB_USER@
    db.password=@DB_PASSWORD@

    The database.properties file is intended to be included in my archive files like any standard properties file. Now assume I had the following environment specific property files that defined the values for database properties based on the target environment:

    dev.xml
    <property name=”db.driver” value=”oracle.jdbc.driver.OracleDriver”/>
    <property name=”db.url” value=”jdbc:oracle:thin:@devhost:1521:DEV1″/>
    <property name=”db.user” value=”foo1″/>
    <property name=”db.password” value=”bar1″/>

    test.xml
    <property name=”db.driver” value=”oracle.jdbc.driver.OracleDriver”/>
    <property name=”db.url” value=”jdbc:oracle:thin:@tsthost:1521:TST1″/>
    <property name=”db.user” value=”foo2″/>
    <property name=”db.password” value=”bar2″/>

    etc.

    What I do with Ant in this example is enter the target environment at the command line as an environment variable. The value of the target environment variable determines which environment specific properties I load (i.e. dev.xml, test.xml, train.xml, prod.xml). The values from that target environment property file are used to fill in the values in the database.properties file and finally the application uses the database.properties file to connect to the database.

    If I ran
    ant -Dtarget_env=dev dist

    then the database.properties included in my archive would look like:

    db.driver=oracle.jdbc.driver.OracleDriver
    db.url=jdbc:oracle:thin:@devhost:1521:DEV1
    db.user=foo1
    db.password=bar1

    The Eclipse problem with this configuration is that I have no idea how to tell Eclipse to do this for me when running a test or debugging or just prototyping some idea within Eclipse.

    #252983 Reply

    Samer Kanjo
    Participant

    Oops… I forgot to post my directory structure.

    
    /<app_name>
        /build (volatile)
        /dist (volatile)
        /docs
            /require
            /design
            /change
            /...
        /etc
        /service (Eclipse project root)
            /etc (environment properties defined in here)
            /main (main source branch)
            /test (test source)
        /webapp (Eclipse project root and dependent on service)
            /etc (environment properties defined in here)
            /main (main source branch)
            /web (web artifacts)
            /test (test source)
        /remote (Eclipse project root and dependent on service)
            /etc (environment properties defined in here)
            /main (main source branch)
            /web (web artifacts)
            /test (test source)
        build.xml
        build.bat
        properties.xml (standard build properties across environments)
    
    #253350 Reply

    Samer Kanjo
    Participant

    So nobody has any interest in talking about directory structures?

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: Directory Structure

You must be logged in to post in the forum log in