You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by to...@apache.org on 2004/11/24 23:31:13 UTC
cvs commit: db-ojb/src/ojb-blank build.xml build.properties
tomdz 2004/11/24 14:31:13
Modified: src/samples/org/apache/ojb/tutorial2 Application.java
src/ojb-blank build.xml build.properties
Added: src/ojb-blank/src/resources run.bat run.sh
Log:
Ported changes to ojb-blank in 1.0 STABLE to 1.1 HEAD
Revision Changes Path
1.2 +3 -0 db-ojb/src/ojb-blank/src/resources/run.bat
1.2 +2 -0 db-ojb/src/ojb-blank/src/resources/run.sh
1.4 +4 -9 db-ojb/src/samples/org/apache/ojb/tutorial2/Application.java
Index: Application.java
===================================================================
RCS file: /home/cvs/db-ojb/src/samples/org/apache/ojb/tutorial2/Application.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Application.java 23 Jun 2004 07:13:14 -0000 1.3
+++ Application.java 24 Nov 2004 22:31:13 -0000 1.4
@@ -19,7 +19,6 @@
import java.io.InputStreamReader;
import java.util.Vector;
-import org.apache.ojb.broker.TestHelper;
import org.apache.ojb.broker.util.ui.AsciiSplash;
import org.apache.ojb.odmg.OJB;
import org.odmg.Database;
@@ -31,15 +30,11 @@
*/
public class Application
{
+ /** The name of the database, i.e. the jcd-alias (including username and password) */
+ private static final String DATABASE_NAME = "default#sa#";
+
/** The use cases */
private Vector useCases;
- /** The name of the database */
- private static String databaseName;
-
- static
- {
- databaseName = TestHelper.DEF_DATABASE_NAME;
- }
/**
* Creates a new application object.
@@ -53,7 +48,7 @@
// open database
try
{
- db.open(databaseName, Database.OPEN_READ_WRITE);
+ db.open(DATABASE_NAME, Database.OPEN_READ_WRITE);
}
catch (ODMGException ex)
{
1.7 +83 -46 db-ojb/src/ojb-blank/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/db-ojb/src/ojb-blank/build.xml,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- build.xml 12 Aug 2004 19:03:29 -0000 1.6
+++ build.xml 24 Nov 2004 22:31:13 -0000 1.7
@@ -20,7 +20,7 @@
and lib/*.jar to a classpath and run the project.
The default "build" target will build everything and copy src/resources/*
- over to build/resources. Class files will wind up in build/classes
+ over to build. Class files will wind up in build/classes.
The "jar" target kindly jars things up for you.
@@ -37,16 +37,18 @@
<property file="build.properties"/>
<path id="compile-classpath">
- <fileset dir="${build.lib.dir}">
+ <fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="runtime-classpath">
- <fileset dir="${build.lib.dir}">
- <include name="**/*.jar"/>
+ <fileset dir="${lib.dir}">
+ <exclude name="xdoclet*.jar"/>
+ <exclude name="xjavadoc*.jar"/>
+ <exclude name="torque*.jar"/>
+ <exclude name="velocity*.jar"/>
</fileset>
- <pathelement location="${build.classes.dir}"/>
</path>
<!-- ================================================================== -->
@@ -55,17 +57,39 @@
<target name="compile">
<tstamp/>
<mkdir dir="${build.dir}"/>
- <mkdir dir="${build.classes.dir}"/>
- <javac srcdir="${source.java.dir}" destdir="${build.classes.dir}">
+ <mkdir dir="${build.dir}/classes"/>
+ <javac srcdir="${source.java.dir}" destdir="${build.dir}/classes">
<classpath refid="compile-classpath"/>
</javac>
</target>
<!-- ================================================================== -->
+ <!-- Creates repository_user.xml and project-schema.xml from the source -->
+ <!-- ================================================================== -->
+ <target name="xdoclet" depends="compile">
+ <taskdef name="ojbdoclet"
+ classname="xdoclet.modules.ojb.OjbDocletTask">
+ <classpath>
+ <path refid="compile-classpath"/>
+ <pathelement path="${build.dir}/classes"/>
+ </classpath>
+ </taskdef>
+
+ <ojbdoclet destdir=".">
+ <fileset dir="${source.java.dir}"/>
+
+ <ojbrepository destinationFile="${build.dir}/repository_user.xml"/>
+ <torqueschema databaseName="${databaseName}"
+ dtdUrl="http://db.apache.org/torque/dtd/database_3_0_1.dtd"
+ destinationFile="${build.dir}/database/project-schema.xml"/>
+ </ojbdoclet>
+ </target>
+
+ <!-- ================================================================== -->
<!-- Builds the project and preprocesses the configuration files -->
<!-- ================================================================== -->
- <target name="build" depends="compile">
- <copy todir="${build.resource.dir}/">
+ <target name="build" depends="xdoclet">
+ <copy todir="${build.dir}/">
<fileset dir="${source.resource.dir}">
<include name="*.properties"/>
<include name="*.dtd"/>
@@ -76,32 +100,46 @@
<filter token="JCD_ALIAS" value="${jcdAlias}"/>
<filter token="DBMS_NAME" value="${dbmsName}"/>
<filter token="JDBC_LEVEL" value="${jdbcLevel}"/>
- <filter token="DRIVER_NAME" value="${jdbcRuntimeDriver}"/>
+ <filter token="DRIVER_NAME" value="${torque.database.driver}"/>
<filter token="URL_PROTOCOL" value="${urlProtocol}"/>
<filter token="URL_SUBPROTOCOL" value="${urlSubprotocol}"/>
<filter token="URL_DBALIAS" value="${urlDbalias}"/>
- <filter token="USER_NAME" value="${databaseUser}"/>
- <filter token="USER_PASSWD" value="${databasePassword}"/>
+ <filter token="USER_NAME" value="${torque.database.user}"/>
+ <filter token="USER_PASSWD" value="${torque.database.password}"/>
</filterset>
</copy>
+ <mkdir dir="${build.dir}/lib"/>
+ <copy todir="${build.dir}/lib">
+ <fileset dir="${lib.dir}">
+ <exclude name="xdoclet*.jar"/>
+ <exclude name="xjavadoc*.jar"/>
+ <exclude name="torque*.jar"/>
+ <exclude name="velocity*.jar"/>
+ </fileset>
+ </copy>
+ <antcall target="build_if_with_mainclass"/>
</target>
- <!-- ================================================================== -->
- <!-- Creates repository_user.xml and project-schema.xml from the source -->
- <!-- ================================================================== -->
- <target name="xdoclet" depends="compile">
- <taskdef name="ojbdoclet"
- classname="xdoclet.modules.ojb.OjbDocletTask"
- classpathref="runtime-classpath"/>
-
- <ojbdoclet destdir=".">
- <fileset dir="${source.java.dir}"/>
-
- <ojbrepository destinationFile="${build.resource.dir}/repository_user.xml"/>
- <torqueschema databaseName="${databaseName}"
- dtdUrl="http://db.apache.org/torque/dtd/database_3_0_1.dtd"
- destinationFile="${build.resource.dir}/project-schema.xml"/>
- </ojbdoclet>
+ <target name="build_if_with_mainclass" if="source.main.class">
+ <pathconvert targetos="unix" property="script.classpath.unix" refid="runtime-classpath">
+ <map from="${basedir}\${lib.dir}" to="lib"/>
+ <map from="${basedir}/${lib.dir}" to="lib"/>
+ </pathconvert>
+ <pathconvert targetos="windows" property="script.classpath.windows" refid="runtime-classpath">
+ <map from="${basedir}\${lib.dir}" to="lib"/>
+ <map from="${basedir}/${lib.dir}" to="lib"/>
+ </pathconvert>
+ <copy todir="${build.dir}">
+ <fileset dir="${source.resource.dir}">
+ <include name="*.bat"/>
+ <include name="*.sh"/>
+ </fileset>
+ <filterset>
+ <filter token="MAIN_CLASS" value="${source.main.class}"/>
+ <filter token="CLASSPATH_UNIX" value="classes:${script.classpath.unix}"/>
+ <filter token="CLASSPATH_WINDOWS" value="classes;${script.classpath.windows}"/>
+ </filterset>
+ </copy>
</target>
<!-- ================================================================== -->
@@ -113,19 +151,18 @@
<property name="torque.project"
value="${databaseName}"/>
<property name="torque.schema.dir"
- value="${build.resource.dir}"/>
+ value="${build.dir}/database"/>
<property name="torque.output.dir"
- value="${build.resource.dir}"/>
+ value="${build.dir}/database"/>
<property name="torque.sql.dir"
value="${torque.output.dir}"/>
<property name="torque.useClasspath"
value="true"/>
- <property name="torque.database.driver"
- value="${jdbcRuntimeDriver}"/>
<!-- We want Torque to also process the schema for OJB's internal tables.
If you do not require them, put a comment around this copy task -->
- <copy todir="${build.resource.dir}">
+ <mkdir dir="${build.dir}/database"/>
+ <copy todir="${build.dir}/database">
<fileset dir="${source.schema.dir}" includes="*schema.xml"/>
<filterset>
<filter token="DATABASE_DEFAULT" value="${databaseName}"/>
@@ -150,23 +187,23 @@
<!-- Cleans the project -->
<!-- ================================================================== -->
<target name="clean">
- <delete dir="target" quiet="true"/>
- <delete dir="build" quiet="true"/>
- <delete file="velocity.log"/>
+ <delete dir="target" quiet="true" failonerror="false"/>
+ <delete dir="build" quiet="true" failonerror="false"/>
+ <delete file="velocity.log" quit="true" failonerror="false"/>
</target>
<!-- ================================================================== -->
- <!-- Creates a jar for the project -->
+ <!-- Creates a distribution jar for the project -->
<!-- ================================================================== -->
- <target name="jar" depends="build">
+ <target name="dist" depends="build">
<mkdir dir="${target.dir}"/>
- <jar index="true" jarfile="${target.dir}/${jar.name}">
- <fileset dir="${build.classes.dir}/">
- <include name="**/*.class"/>
- </fileset>
- <fileset dir="${build.resource.dir}">
- <include name="**/*"/>
- </fileset>
+ <jar index="true"
+ jarfile="${target.dir}/${jar.name}"
+ basedir="${build.dir}"
+ excludes="**/*-schema.xml,**/*.sql,**/*.sql.generation,**/sqldb.map">
+ <manifest>
+ <attribute name="Built-By" value="Apache OJB Blank build script"/>
+ </manifest>
</jar>
</target>
@@ -185,7 +222,7 @@
failonerror="yes"
classname="com.sun.jdori.enhancer.Main"
classpathref="compile-classpath">
- <arg line="-v -f -d ${build.classes.dir} ${source.java.dir}/org/apache/ojb/tutorial5/Product.jdo ${build.classes.dir}/org/apache/ojb/tutorial5/Product.class"/>
+ <arg line="-v -f -d ${build.dir}/classes ${source.java.dir}/org/apache/ojb/tutorial5/Product.jdo ${build.dir}/org/apache/ojb/tutorial5/Product.class"/>
</java>
</target>
</project>
1.4 +15 -13 db-ojb/src/ojb-blank/build.properties
Index: build.properties
===================================================================
RCS file: /home/cvs/db-ojb/src/ojb-blank/build.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- build.properties 22 Jun 2004 19:10:49 -0000 1.3
+++ build.properties 24 Nov 2004 22:31:13 -0000 1.4
@@ -18,20 +18,20 @@
# These are build properties for the ojb-blank project. In addition to
# any customization of your build process, you will probably want
# to change the values in the block below to map to your database
-# rather than a generic HSQLDB instance.
+# rather than to a generic HSQLDB instance.
#
jcdAlias=default
databaseName=ojb_blank
-databaseUser=sa
-databasePassword=
+torque.database.user=sa
+torque.database.password=
# Settings are for Hsqldb (embedded database)
dbmsName=Hsqldb
jdbcLevel=2.0
-jdbcRuntimeDriver=org.hsqldb.jdbcDriver
+torque.database.driver=org.hsqldb.jdbcDriver
urlProtocol=jdbc
urlSubprotocol=hsqldb
-urlDbalias=${databaseName}
+urlDbalias=database/${databaseName}
# For MySQL this would look like:
#dbmsName=MySQL
@@ -51,20 +51,24 @@
# For instance, MySQL requires an url that points to the host, but without a database name
#
# For Hsqldb we have to mangle the path so that we can invoke Torque in the base
-# directory but the database is created in the ${build.resource.dir} folder
-torque.database.createUrl=${urlProtocol}:${urlSubprotocol}:${build.resource.dir}${urlDbalias}
+# directory but the database is created in the ${build.dir}/database folder
+torque.database.createUrl=${urlProtocol}:${urlSubprotocol}:${build.dir}/database/${databaseName}
# This specifies the url that Torque uses to access the existing database
#
# For Hsqldb we use the same url as for the createUrl above
-torque.database.buildUrl=${urlProtocol}:${urlSubprotocol}:${build.resource.dir}${urlDbalias}
+torque.database.buildUrl=${torque.database.createUrl}
-# Set this to the name of the jar file you want produced from the jar target
+# Set this to the name of the jar file you want produced from the dist target
jar.name=my-project.jar
+# This is the class containing the main method. Set this so that an executable jar and
+# appropriate batch/shell skripts can be automatically generated for you.
+#source.main.class=org.apache.ojb.tutorial1.Application
+
################################################################################
-# Build Properties
+# Build Properties - you shouldn't have to change anything here
#
source.dir=src
source.java.dir=${source.dir}/java
@@ -73,8 +77,6 @@
source.schema.dir=${source.dir}/schema
build.dir=build
-build.lib.dir=lib
-build.classes.dir=${build.dir}/classes/
-build.resource.dir=${build.dir}/resources/
+lib.dir=lib
target.dir=target
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org