This makes me think about a possible improvement.

(stop me if I'm wrong).

I think that your java source classes will only have a compilation
dependency on clojure source if your clojure source generates classes or
interfaces via gen-class / gen-interface.
(If there are other kind of dependencies *for the java compilation* I'm not
aware of, then my whole suggestion may collapse).

So if you expect from your users to keep the gen-class / gen-interface
declarations separate from the implementation, everything can go OK.
In fact, I've already used this pattern succesfully at work.

So at the cost of an optional set of directories/patterns for identifying
"pure gen-class / gen-interface" namespaces in the maven pom, you could
automate it correctly :

 * first compile all the "pure gen-class/gen-interface" namespaces (the only
dependencies these namespaces can have are towards other "pure
gen-class/gen-interface" namespaces, and third-party namespaces java maven
artifacts declared in the pom.

 * then compile the java source files normally.

 * then compile the rest of the clojure files, whose dependencies towards
project's specific java artifacts will succesfully be found.

The only thing not covered by the above scenario is if you have, for
example, the java source files of your project creating new classes or
interfaces you want to extend/implement via gen-class/gen-interface.
This was not a problem in my use case, since the only interfaces/classes I
wanted to extend were those provided by third-party frameworks, not my own
code.

Regards,

-- 
Laurent

2009/8/25 Mark Derricutt <m...@talios.com>

> If you have the clojure:compile goal bound to the compile phase it runs
> -after- the normal java compiler.  One solution I've used is just using
> multiple modules and keeping the clojure code separate from the java.
>
> However, if your only talking TO java from clojure this might not be a
> problem.
> --
>
> On Tue, Aug 25, 2009 at 11:06 PM, Christian Vest Hansen <
> karmazi...@gmail.com> wrote:
>
>>
>> How does it work if you have both Java and Clojure code in the same
>> project? Which is compiled first?
>>
>> On Tue, Aug 25, 2009 at 12:46 PM, Mark Derricutt<m...@talios.com> wrote:
>> > For my own usages I've just been using IDEAs native maven support and
>> > opening the pom.xml - This sadly doesn't pick up the source directories
>> > thou.
>> > --
>> >
>> > On Tue, Aug 25, 2009 at 7:33 PM, Laurent PETIT <laurent.pe...@gmail.com
>> >
>> > wrote:
>> >>
>> >> Excellent, thanks Mark for this contribution !
>> >>
>> >> When time permits, I'll undoubtedly give a thorough look at it, and see
>> >> how I can integrate this with Counterclockwise (new name for
>> clojure-dev
>> >> eclipse plugin).
>> >> Something like a mvn clojure:eclipse that could extend the
>> eclipse:eclipse
>> >> goal for initializing the eclipse project with the clojure nature, and
>> use
>> >> the provided strategy for resolving namespaces to compile.
>> >>
>> >> Regards,
>> >>
>> >> --
>> >> Laurent
>> >>
>> >> 2009/8/24 Mark Derricutt <m...@talios.com>
>> >>>
>> >>> Hey all,
>> >>> I've released 1.0 of my clojure-maven-plugin and its now available in
>> >>> maven-central.
>> >>> To use it, a minimal pom.xml declaring a dependency on clojure, and
>> the
>> >>> the plugin (without configuration) is all you need.
>> >>>   - http://gist.github.com/174217
>> >>> With the above pom, running "mvn clojure:compile" will scan any .clj
>> file
>> >>> under ./src/main/clojure and compile them into the ./target/classes
>> >>> directory.
>> >>> "mvn clojure:test-compile" will do the same for any .clj file under
>> >>> ./src/test/clojure.
>> >>> For more options such as hooking up a test script, filtering
>> namespaces
>> >>> etc. see the project site at:
>> >>>   http://github.com/talios/clojure-maven-plugin
>> >>> Mark
>> >>> --
>> >>> Discouragement is a dissatisfaction with the past, a distaste for the
>> >>> present, and a distrust of the future
>> >>> - Maree De Jong, Life NZ.
>> >>>
>> >>> blog: http://www.talios.com
>> >>> podcast: http://www.illegalargument.com
>> >>> skype / twitter: talios
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> >
>> > >
>> >
>>
>>
>>
>> --
>> Venlig hilsen / Kind regards,
>> Christian Vest Hansen.
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to