Last installment we looked at building Flex with Maven and Ant, and now we'll look at the development lifecycle so far. Then, in preparation for next installment, we'll look at the dependencies for the persistence layer.
Now that we have tasks to help us and we’ve hooked into a few points in the Maven build process, let’s discuss making changes and reviewing those changes through the web browser in our development environment.
Let’s look at it from this point of view (see Table 4). What type of resource changed, and what needs to happen for us to see the changes? The “Build” column in the table tells what command to run and from what project to run it to compile, build, or otherwise make the changes “stick.”
The “Deploy” column tells which command from which project will push the changes to the local development environment so that we can see the changes.
|Table 4. Maven build Resource Changes|
|Type of change||Changed resource||Build||Deploy|
|`ant load-schema` in bookie-data||None needed|
|Entity or session bean change||Any Java in |
|`mvn package` in bookie-data||`ant dev-deploy` in root of project|
For example, Figure 9 shows the output of load-schema in the bookie-data project.
Building the Persistence Layer: Maven Configuration
We’ve already gone over the bulk of the POM file and its interaction with Ant. All that’s left is to look at the dependencies:
I’m not going to put the whole dependency list in here, but there are a few points to hit. Notice how a dependency uses the same “big three” identifiers that all projects need to define: groupId, artifactId, and version. This is enough information for Maven to uniquely pick out a dependency.<scope>, the next tag under the big three, tells Maven when the project needs the dependency. Table 5 lists the full explanation of scope from Maven’s web site.
|Table 5. Scope in Maven|
|compile||This is the default scope, and it is used if none is specified. Compile dependencies are available in all classpaths.|
|provided||This is much like compile, but it indicates that you expect the JDK or a container to provide it. It is available only on the compilation classpath, and it is not transitive.|
|runtime||This scope indicates that the dependency is not required for compilation, but it is required for execution. It is in the runtime and test classpaths, but not in the compile classpath.|
|test||This scope indicates that the dependency is not required for normal use of the application, and it is available only for the test compilation and execution phases.|
|system||This scope is similar to provided, except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.|
src is a directory for the main source of the project, called main. At the same level is a folder for test code, called test. The code goes in the main and test directories and is organized by the type of language—in this case, a java directory holds the Java code in the data project directory, and a java and flex directory in the web project.
You can also mark a dependency
Remember that you can build the bookie-data’s persistence unit JAR by typing `mvn package` on the command line inside the root of the bookie-data project.
Next installment we're going to look at the code that makes up the persistence layer of our sample application, both the Java and ActionScript code. You can always find the entire series here.