 |
GlassFish Build Questions
Why are only a subset of maven features used?
Currently maven is used as a wrapper around the previously existing ant based build scripts for GlassFish. We plan to update this in the future.
What goals/objectives does this Maven based framework achieve ?
The module based framework meets the following objectives:
- It should be possible to check out and build each independent module separately.
- It must be possible to build the entire source tree from a top level directory / workspace.
- It must be possible for a module engineer (e.g. appserv-webtier) to just check out the relevant module files, instead of the checking out the entire workspace.
- There must be a facility for obtaining a "binary" module (i.e. one whose source code is not available).
- Developers should be not have to compile and build every dependent module. Instead it should be possible to retrieve a pre-compiled and tested version of the module. They should also be able to download an entire Glassfish installation (called Glassfish image) and build the module against it.
- The build environment must be completely reproducible meaning that all tools and external modules used in the build environment can be retrieved from a known location. Except for Maven, CVS and JDK 1.5, which needs to be installed manually before checking out the workspace.
What are the different types of modules ?
There are 3 types of modules:
- Source modules: These are modules whose sources are hosted under the /glassfish CVS repository (i.e. under our control) and which can be bootstrapped and built using this build system. e.g. mail, activation, appserv-webtier, appserv etc. Source modules are stored in CVS. The CVS server is supported by CollabNet on java.net/glassfish project.
- Binary modules: These are modules whose source code is either controlled by other groups, 3rd parties, unavailable to us, or modules whose build systems do not conform to the concepts described in this document. Consequently we only use binary versions of these files and rely on an external release mechanism. Those module must be available using the http protocol (since Maven use HTTP for retrieving dependencies).
- Image module: This module represent a complete GlassFish installation binary. User's can download the image, configure it and start the application server. They can also build against that image and update the image with their newly builded classes files.
What are the list of useful Maven goals ?
- Cleaning the module: maven clean
- Checking out a module: maven checkout
- Building the module: maven build
- Installing the glassfish-image: maven bootstrap
- Installing an empty glassfish image that only contains the binaries dependencies: maven bootstrap-all
- Configuring glassfish image: maven configure-runtime (add -Dsilent for a silent installation)
- Cleaning/Checking out/Building only some modules: maven -Dmodules={comma separated list} goal name
What does maven bootstrap do ?
When Maven starts, the first operation performed is synchronizing its local repository with the Glassfish remote repositories, based on the * project.xml dependencies list. If any dependencies are missing, these will be downloaded. Once all the dependencies have been validated, the bootstrap goals will unzip the glassfish-image-SNAPSHOT.jar under the ${glassfish.home}.
What does maven bootstrap-all do ?
For building glassfish from source and empty glassfish image, "maven bootstrap-all" goal is used.
bootstrap-all goal installs an empty glassfish image that only contains the binaries dependencies, then downloads individual binary dependencies and unzips them into $glassfish.home. Post-bootstrapping is also done to initialize some major jar files like appserv-rt.jar, appserv-admin.jar, or to add some unzipped jars into these runtime jar files.
Main file to look for which affects bootstrap-all goal is:
Location: glassfish/bootstrap Files: project.properties, glassfish.xml, project-src.xml, project.xml
This goal requires all the modules to be checked out and built from scratch. As the glassfish server image is built from empty or few initialized jar files, and is built by each module specified in glassfish.build.dependency.order in project.properties file.
Maven command to run glassfish build from source:
% maven checkout bootstrap-all build configure-runtime
What does maven clean do ?
The Maven clean goal deletes the module compilation output folder where the .class has been stored.
Why Maven doesn't find the dependencies ?
Maven bases the build process on some properties, defined in properties files usually named build.properties and project.properties.
To build GF, you can either define a build.properties file in the glassfish/bootstrap folder, or you can define it (more globally) in
%HOME% or %HOMEPATH% folders. If you choose the latter solution, whatever properties you put in build.properties
will take (override) precedence over the properties with the same name defined under glassfish/bootstrap. This may occurr
more easily to those users already using Maven. If you have got a build.properties defined in your %HOME% or %HOMEPATH%
folder containing the
maven.repo.remote
property pointing to the remote repositories you are used to, the same property defined in glassfish/bootstrap/project.properties
will be overridden, and therefore to Maven the remote repositories where GF dependencies are stored won't be visible.
SOLUTION:
If you want to maintain the build.properties file at a global level (%HOME%, %HOMEPATH%) you'll have to append the
repositories specified in glassfish/bootstrap/project.properties (maven.repo.remote property) to the same property
defined in your %HOME% or %HOMEPATH% build.properties file.
What does maven checkout do ?
The Maven checkout goal will checkout, from cvs, the module from where the command is executed. If executed from the glassfish/ directory, it will checkout all the module described in project.properties:
glassfish.build.dependecy.order=activation,mail, deployment-api, transaction-api, servlet-api, ejb-api, connector-api, management-api, jms-api ,jacc-api, common-util, appserv-commons ,jmx-remote, admin-core, jts,pwc-commons, appserv-webtier, webtier-extensions, jacc-provider, container-auth, appserv-core, appserv-docs, admin, admin-cli, jdbcra, tools, avk-verifier-only, admin-gui
What does maven clobber do ?
The Maven clobber goals delete the current glassfish image. It does the same as doing:
% rm -rf ${glassfish.home}
What does maven build do ?
The Maven build goal compile the module and update the glassfish image with the results. As an example, if you do:
% cd appserv-webtier
% maven build
The results will be an updated version of the ${glassfish.home}/lib/appserv-rt.jar and ${glassfish.home}/lib/j2ee.jar. You can always build more than one module at the time:
% cd appserv-webtier
% maven build -Dmodules=appserv-webtier,appserv-core
What does the configure-runtime contain?
The Maven configure-runtime goal configure the glassfish image scripts.
instance.name="server"
admin.usere="admin"
admin.password="administrator"
admin.port="4848"
instance.port="8080"
orb.port="3700"
imq.port="7676"
https.port="1043"
using the properties defined in project.properties. After executing the configure-runtime goal, the application server is ready to be started:
% cd ${glassfish.home}/bin
% ./asadmin start-domain
What does maven clean-config do?
maven clean-config goal deletes domain1 created by configure-runtime goal.
maven configure-runtime goal creates admin domain, domain1, so if you run configure-runtime more than once, it will fail since domain1 is already present.
You can run configure-runtime again if you made any changes related to domain creation or domain.xml changes for classpath, jvm-option etc.
% maven clean-config configure-runtime
What does maven checkout-quicklook do?
maven checkout-quicklook goal checks-out only required files for quicklook tests from appserv-tests module, so you may use this instead of checking out whole appserv-tests module which will take little longer to checkout and run quicklook tests.
How are modules versioned ?
The party binary are assigned version numbers/tags by the external group/site from where we obtain the bits.
GlassFish image binary comes in three form:
- latest nightly build: glassfish-image.SNAPSHOT.jar
- nightly build: glassfish-image-b01-nightly-01_apr_2005.jar
- promoted build: glassfish-image-b01-promoted-10_apr_2005.jar
By default, invoking
% maven build
will always use the SNAPSHOT version. Maven dependencies mechanism uses that special tag to synch up its local repository with the remote repository. Since nightly build are created every night, then invoking maven build will synch up the image once every day. If you don't need to synch up the image everyday, you can change the default value to point to a nightly or promoted build.
How are download Promoted/versioned builds?
If you want to use a promoted build, you need to edit, in glassfish/bootstrap/project.properties:
glassfish.image.version=SNAPSHOT
to
glassfish.image.version=b01-promoted-10_apr_2005
(b01 is the promoted build number). Note that Maven will download the image once, after this you will not need to download a new image.
Then run "maven bootstrap" goal to download promoted builds.
How to add New Source module in glassfish build?
First of all, get it review/approval from glassfish workspace team (send email to: dev@glassfish.dev.java.net) to add new source module.
A module built using maven is typically driven from project.xml and maven.xml residing in its top level directory that typically contains all, bootstrap, build, clean, clobber goals (target).
The Maven infrastructure relies mostly on the build, bootstrap and clean targets. If your are creating a new module that does not already have a project.xml, project.properties and maven.xml file, you can use one of the module/maven.xml, project.properties and project.xml files to get started. For example; get the build scripts from glassfish/mail module.
For adding this new module in the top-level build it needs to be added in glassfish.build.dependency.order variables in the following file:
Location: glassfish/bootstrap, Files: project.properties, variable: glassfish.build.dependency.order
You can test addition of the module under glassfish and run "maven build" command to see if it builds first.
Before commiting the changes, run full build from source: using 'maven bootstrap-all checkout build' command from glassfish/bootstrap module for verifying this in local workspace.
Then create module using "cvs add <new-module>" for all individual files or use "cvs import" to import all files. Using cvs import will avoid adding each file individually. The command syntax to do this is as below.
cd glassfish/<new-module>
cvs -d :pserver:<java.net id>@cvs.dev.java.net:/cvs import -I! -ICVS -m "GlassFish first drop" glassfish/<new-module> SJSAS_9_0 START
In general, you should try out commands on a local temporary cvs repository and make sure everything works before you run the commands on the real cvs repository. Here is how to create a temporary cvs repository --
cvs -d /tmp/cvstest init
After this, you can either set your CVSROOT to /tmp/cvstest or use -d /tmp/cvstest on every cvs command.
At the end of your test run you should have all ,v cmp files in /tmp/cvstest/glassfish/cmp.
How to add New Binary module in glassfish build?
First of all, get it review/approval from glassfish workspace team (send email to: dev@glassfish.dev.java.net) to add new binary module.
For adding binary module/dependencies the following files need to be updated.
Location: glassfish/bootstrap, Files: project.properties, project-src.xml, glassfish.xml
$maven.repo.remote variable in project.properties specifies all URLs to download the binary dependency locations in a sequence till it downloads the binary.
Edit project.properties, project-src.xml and add your dependency under the section:
<dependency>
<id>${glassfish.jaxb.name}</id>
<version>${glassfish.jaxb.version}</version>
<url/>
</dependency>
Edit glassfish.xml to unzip the downloaded binaries from $maven.repo.local to $glassfish.home directory.
For module specific bootstrapping, you need to edit project.xml, project.properties for Online modules which try downloading dependencies and do the rest of unzipping in build.xml or publish.xml.
Before commiting the changes, run a full build from source: using 'maven bootstrap-all checkout build' command from glassfish/bootstrap module after verifying this in local workspace.
Why do I get a 'Warning invalid module xxx' when I try to checkout?
You could be getting this message because the default JDK is the incorrect version. Please verify that you have JDK 1.5.0_01 or higher installed and in your path.
Why does the build fail on Mac OS X?
First you need to ensure you are running Tiger (10.4) and have manually installed JDK 1.5 from Apple.
Also, even after installing JDK 1.5, the 1.4.2 version bundled with OS X remains the default JDK,
you need to modify your .profile to set those environment variables :
export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.5/Home
export PATH=.:$JAVA_HOME/bin:$PATH
This will ensure that the JDK 1.5 is picked up before the 1.4.2 version. Alternatively, being root you can
reset the "CurrentJDK" symlink in /System/Library/Frameworks/JavaVM.framework/Versions
to the proper subdirectory, but note that it will reset the default JDK of your Tiger installation to JDK 1.5
Why do I get a 'Error retrieving artifact' error during bootstrap/-all?
Check your basic configurations for the platform, proxy settings in your $HOME/build.properties file:
glassfish.os.name=<correct platform - WINNT,SunOS,SunOS_X86, Linux, Darwin>
maven.proxy.host=<set appropriate proxy host>
maven.proxy.port=<set appropriate proxy port>
set JAVA_HOME to JDK1.5.0_04 or the latest supported/published, and add $JAVA_HOME/bin in PATH variable.
If you see error below while running "bootstrap-all" target
Attempting to download jsf-1.2_04-p03-b20.jar.
Cookie rejected: "$Version=0; JSESSIONID=1CA057FA7401CBF6C9841BFF1E24B614; $Path=/servlets". Illegal path attribute "/servlets". Path of origin: "/nonav/repository/jsf/jars/jsf-1.2_04-p03-b20.jar"
Error retrieving artifact from [http://www.ibiblio.org/maven/jsf/jars/jsf-1.2_04-p03-b20.jar]: java.io.IOException: Unknown error downloading; status code was: 301
WARNING: Failed to download jsf-1.2_04-p03-b20.jar.
You may have download.java.net entry in your /etc/hosts file, so comment out this, and download will be successful.
#64.125.132.44 download.java.net
What is Tinderbox and how is it used?
#Tinderbox
Tinderbox is a continuous build tool which is used to build the GlassFish workspace. Builds happen continuously throughout the day so any build breakages can be detected prior to the nightly builds. Tinderbox is only available within the Sun SWAN at this time. We are currently testing an installation of tinderbox which will be available to the entire community soon.
One issue that arises, is that because CVS is used as the source repository and it is nontransactional, there may be a situation where someone is in the process of doing a commit when the workspace is checked out for the continuous build. Especially if the commit is a large number of files. This may cause a failure to be reported by the build system. For large commits, please send email to dev@glassfish.dev.java.net so that the build master knows there is a possiblity of breakage in the build system. This also alerts other people of a large commit coming down the pipeline.
How to build Glassfish Beta builds from AS9_BETA_BRANCH?
Following are the steps to build from Beta Branch:
% mkdir workspace
% cd workspace
% cvs -d :pserver:<userid>@cvs.dev.java.net:/cvs checkout -r AS9_BETA_BRANCH glassfish/bootstrap
As glassfish/bootstrap/project.properties from AS9_BETA_BRANCH branch has variable "glassfish.cvstag" set as "glassfish.cvstag=AS9_BETA_BRANCH" Beta Branch sources will be checked out and built accordingly.
Edit glassfish/bootstrap/project.properties or create ${user.home}/build.properties (Unix) or %HOMEPATH%\build.properties (Windows) and set following properties:
glassfish.os.name= // The OS name under which GlassFish will be built (possible values are WINNT, SunOS?, Linux, SunOS?_X86, Darwin)
glassfish.root=<ws directory> // Directory where you want to checkout the workspace, in this case workspace. All the source code, dependencies and jar files will end up here.
glassfish.cvs.username= // The java.net id that will be used to checkout the source code.
Then:
% cd glassfish/bootstrap
% maven checkout bootstrap-all build configure-runtime
|