I've added a new functionality for vinyasa 0.1.5 - a much needed function 
for reloading java code

the repo is here: https://github.com/zcaudate/vinyasa

Enjoy!

-------
reimport

Don't you wish that you could make some changes to your java files and have 
them instantly loaded into your repl without restarting? Well now you can!

For example, in project.clj, you have specified your :java-source-paths

(defproject .....
   :source-paths ["src/clojure"]
   :java-source-paths ["src/java"]
   ....)

and you have a file src/java/testing/Dog.java

package testing;public class Dog{
  public int legs = 3;  
  public Dog(){};}

You can load it into your library dynamically using reimport

(reimport '[testing.Dog]);;=> 'testing.Dog' imported from 
<project>/target/reload/testing/Dog.class
(.legs (Dog.));; => 3

You can then change legs in testing.Dog from 3 to 4, save and go back to 
your repl:

(reimport '[[testing Dog]]) ;; supports multiple classes;;=> 'testing.Dog' 
imported from <project>/target/reload/testing/Dog.class
(.legs (Dog.));; => 4

If you have more files, ie. copy your Dog.java file to Cat.java and do a 
global replace:

(reimport) ;; will load all classes into your namespace;;=> 'testing.Dog' 
imported from <project>/target/reload/testing/Dog.class;;   'testing.Cat' 
imported from <project>/target/reload/testing/Cat.class
(.legs (Cat.));; => 4

Now the pain associated with mixed clojure/java development is gone!


-----------------------------------
installation

inject allows easy customisation of your clojure.core namespace by allowing 
injecting of the functions that you have always wanted to have in your 
profiles.clj file. Here is an example taken from myprofiles.clj.

{:user {:plugins [...]
         :dependencies [[spyscope "0.1.4"]
                        [org.clojure/tools.namespace "0.2.4"]
                        [io.aviso/pretty "0.1.8"]
                        [leiningen "2.3.4"]
                        [im.chit/vinyasa "0.1.5"]]
         :injections [(require 'spyscope.core)
                      (require 'vinyasa.inject)
                      (vinyasa.inject/inject 'clojure.core
                        '[[vinyasa.inject inject]
                          [vinyasa.pull pull]
                          [vinyasa.lein lein]
                          [vinyasa.reimport reimport]])
                      (vinyasa.inject/inject 'clojure.core '>
                        '[[cemerick.pomegranate add-classpath get-classpath 
resources]
                          [clojure.tools.namespace.repl refresh]
                          [clojure.repl apropos dir doc find-doc source pst 
                                        [root-cause >cause]]
                          [clojure.pprint pprint]
                          [clojure.java.shell sh]])]}}

I have now imported the following vars into clojure.core and they will stay 
with me as I am coding in emacs:

   - from vinyasa:
   - inject as #'clojure.core/inject
      - pull as #'clojure.core/pull
      - lein as #'clojure.core/lein
      - reimport as #'clojure.core/reimport
   - from tools.namespace:
      - refresh as #'clojure.core/refresh
   - from clojure.repl:
   - apropos as #'clojure.core/>apropos
      - dir as #'clojure.core/>dir
      - doc as #'clojure.core/>doc
      - find-doc as #'clojure.core/>find-doc
      - root-cause as #'clojure.core/>cause`
      - pst as #'clojure.core/>pst
   - from clojure.pprint:
      - pprint as #'clojure.core/>pprint
   - from clojure.java.shell:
      - sh as #'clojure.core/>sh
   - from cemerick.pomegranate:
      - add-classpath as #'clojure.core/>add-classpath
      - get-classpath as #'clojure.core/>get-classpath
      - resources as #'clojure.core/>resources
   
<https://github.com/zcaudate/vinyasa#license>

-- 
-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to