Before proceeding to create a new [fleXive] application, make sure you have a working build system, i.e. at least
JDK 6 or higher, and
Apache Ant 1.7.0 or higher.
For running the application you need a working environment including MySQL as described in the installation chapter.
To get started with your first [fleXive] application, open a command shell and change to the directory containing the [fleXive] distribution. Type ant. You should be greeted by the welcome page of the [fleXive] build system:
Buildfile: build.xml
info:
[flexive]
[flexive] Welcome to the flexive build tool. Feel free to use the following build targets:
[flexive]
[flexive] project.create
[flexive] Creates a new flexive project directory.
[flexive]
[flexive] component.create
[flexive] Creates a new flexive UI component directory.
[flexive]
[flexive] db.create
[flexive] Create or reset the database schema of a flexive division.
[flexive] Warning: if the schema already exists, it will be dropped (i.e. you will lose all data
[flexive] stored in the schema).
[flexive]
[flexive] db.config.create
[flexive] Create or reset the global flexive configuration schema.
[flexive]
[flexive] ear
[flexive] Create a flexive.ear distribution including any flexive application stored in
[flexive] flexive-dist/applications.
[flexive]
[flexive] glassfish.libs
[flexive] Copies libraries needed for Glassfish compatibility to a directory
[flexive]
[input] Please enter a target name, or quit to exit:
Let's create a new project. Type
project.create
and hit return. You will be asked for a project name. This name will be used as the
root directory name for the project, so be careful to include only characters that
may appear in filenames and URLs. For a start, enter
flexive-test.
[fleXive] will create the project folder in the same directory where the [fleXive] distribution is stored, i.e. in the current parent directory. The major reason for this is that the project references the distribution directory, i.e. it includes all the libraries from the distribution directory and does not use its own copies. Thus new [fleXive] projects use little disk space, and you need only one [fleXive] distribution for all your projects.
After confirming your selection, the root directory layout for flexive-test will be created. Your screen should look approximately like this:
[input] Please enter a target name, or quit to exit:
project.create
check:
project.create:
[input] Name of the project you want to create:
flexive-test
[flexive]
[flexive] Please confirm your input:
[flexive] Project name: flexive-test
[flexive] Base directory: ../flexive-test
[flexive]
[input] Are these settings correct? ([y], n)
y
[mkdir] Created dir: /home/daniel/dev/idea-workspace/flexive/flexive-test
[copy] Copying 4 files to /home/daniel/dev/idea-workspace/flexive/flexive-test
[copy] Copied 14 empty directories to 9 empty directories under /home/daniel/dev/idea-workspace/flexive/flexive-test
[copy] Copying 1 file to /home/daniel/dev/idea-workspace/flexive/flexive-test
[copy] Copying 1 file to /home/daniel/dev/idea-workspace/flexive/flexive-test
[echo] Project flexive-test created successfully. The project root directory is
[echo] ../flexive-test
BUILD SUCCESSFUL
When the build tool has finished successfully, go to the newly created directory, e.g. cd ../flexive-test. The directory structure contains a blank project structure, which looks like the following:
.
|-- build.xml
|-- lib
|-- resources
| |-- META-INF
| | |-- faces-config.xml
| | |-- template.taglib.xml.sample
| | `-- web.xml
| |-- messages
| |-- scripts
| | |-- library
| | |-- runonce
| | `-- startup
| `-- templates
|-- src
| `-- java
| |-- ejb
| |-- shared
| `-- war
`-- web
`-- index.xhtml
Before examining the directory structure, let's do a quick test if the the environment
is working. Type
ant. The build should complete successfully, leaving you with
some artifacts in the
dist/
subdirectory:
flexive-test.ear,
flexive-test-shared.jar, and
flexive-test.war.
To deploy the application, first you need to setup the database schemas. Type
ant db.create db.config.create
and when prompted for the database schema use the default name,
flexive.
When the command completed successfully, your can deploy
flexive-test.ear
and have a working (albeit empty) [fleXive] application, including the backend administration application.
The project root directory contains a build file,
build.xml,
that can be customized for the project. By default, it builds JAR files for all layers,
including an EAR archive. The major subdirectories are:
src/java
contains the Java sources of the project. They are split up by layer, i.e. there are three distinct source trees for the EJB, web, and shared classes. This is especially useful for IDEs with support for multiple project modules, where you can also specify wanted (and forbidden) relationships between the layers.
web
contains the documents for the web application (if any).
lib
contains additional libraries and components used by the project.
resources
is the root folder for various project resources:
resources/scripts
contains the run-once, startup and library scripts of the application,
resources/messages
contains the application's localized message resources that can be accessed with the fxMessageBean,
resources/META-INF
contains the application's configuration files, mostly for the web layer,
resources/templates
is the standard folder for Facelets templates. You can choose any folder of course if you like, but then you'd have to modify the build script.