classpathonly mode

2 views
Skip to first unread message

seancorfield

unread,
Oct 7, 2010, 6:57:17 PM10/7/10
to cfmljure
I'm starting to use cfmljure in a larger, multi-file project and
finding that the assumptions about relative paths from the class path
start to break down. I'm using Leiningen (and, now, Cake as well) so
my project structure looks like:

{project}/
lib/ -- clojure / contrib / other libraries
src/
{project}/
data/
-- various data layer files
interop/
-- CFML interop utilities (based on some of the code
in the task example)
-- various main API files
test/
{project}/
test/
data/
-- various data layer tests
interop/
-- tests for CFML interop utilities
-- tests for main API files

My namespace declarations are starting to :use files in various other
namespaces. My Tomcat classpath has been extended to include:

{project}/lib
{project}/lib/*.jar
{project}/src


I've updated cfmljure to have a classpathonly = true construction
option. When that is true, cfmljure ignores the concept of projects
and no longer adds a clj/ prefix to file paths. Instead it relies
entirely on you having your classpath set up correctly and that the
Clojure runtime (RT) will be able to load source files directly.

Let's assume a project structure like this:

my_project/
lib/
src/
my_project/
data/
thingy.clj
core.clj

(and the appropriate test/ tree)

core.clj will have a namespace declaration something like this:

(ns my-project.core
(:use [my-project.data.thingy]))

Note that - in namespaces and functions maps to _ in file paths - and
in the variables created in CFML by cfmljure!

In your CFML code, you'd have something like:

clj = new cfmljure( classpathonly = true );
config = {
'my_project/core'
};
clj.install( config, target );

You only need to load the files containing functions you are calling
directly - the API. The other files are loaded and managed entirely
inside Clojure.

I'll post more of my experiences using Clojure from CFML over time and
cfmljure will evolve to support such larger scale usage.

Sean
Reply all
Reply to author
Forward
0 new messages