Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Leiningen projects with java sources. #1

Open
wants to merge 2 commits into from

2 participants

@r0man

Hi Andreas,

I'm working with a clojure project that has java sources and uses
the :java-source-path key which is part of Leiningen for a while
now. I updated you lein-eclipse plugin to handle these type of
projects as well. Would you like to merge this into your master
and publish it on clojars?

Roman

@danharvey

Any update on the progress of this merge request? Would be great to have this in as I've got some mixed clojure/java projects that I'd like to work from inside eclipse.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 51 additions and 69 deletions.
  1. +1 −0  .gitignore
  2. +4 −5 project.clj
  3. +46 −64 src/leiningen/eclipse.clj
View
1  .gitignore
@@ -4,3 +4,4 @@ classes
lein-eclipse.jar
lib
pom.xml
+/lein-eclipse-1.1.0-SNAPSHOT.jar
View
9 project.clj
@@ -1,6 +1,5 @@
-(defproject lein-eclipse "1.0.0"
+(defproject lein-eclipse "1.1.0-SNAPSHOT"
:description "A leiningen plugin to create Eclipse project descriptor files."
- :dev-dependencies [[org.clojure/clojure "1.1.0"]
- [org.clojure/clojure-contrib "1.1.0"]
- [leiningen "1.1.0"]
- [lein-clojars "0.5.0"]])
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]]
+ :dev-dependencies [[leiningen "1.5.0"]])
View
110 src/leiningen/eclipse.clj
@@ -1,17 +1,14 @@
(ns leiningen.eclipse
"Create Eclipse project descriptor files."
- (:use [clojure.contrib.duck-streams :only [with-out-writer]])
- (:use [clojure.contrib.java-utils :only [file]])
- (:use [clojure.contrib.prxml :only [prxml *prxml-indent*]])
- (:use [clojure.contrib.str-utils :only [re-sub]])
- (:use [leiningen.deps :only [deps]])
- (:import [java.io File])
- (:import [java.util.regex Pattern]))
-
-;; copied from jar.clj
-(defn- unix-path
- [path]
- (.replaceAll path "\\\\" "/"))
+ (:import [java.io File]
+ [java.util.regex Pattern])
+ (:use [clojure.contrib.duck-streams :only [with-out-writer]]
+ [clojure.contrib.java-utils :only [file]]
+ [clojure.contrib.prxml :only [prxml *prxml-indent*]]
+ [clojure.contrib.str-utils :only [re-sub]]
+ [leiningen.classpath :only (get-classpath)]
+ [leiningen.deps :only [deps]]
+ [leiningen.jar :only (unix-path)]))
;; copied from jar.clj
(defn- trim-leading-str
@@ -22,69 +19,54 @@
[arg]
(.isDirectory (File. arg)))
-(defn- list-libraries
- [project]
- (map #(.getPath %) (.listFiles (File. (:library-path project)))))
-
-(defn- create-classpath
+(defn- print-classpath
"Print .classpath to *out*."
[project]
(let [root (str (unix-path (:root project)) \/)
- noroot #(trim-leading-str (unix-path %) root)
- [resources-path compile-path source-path test-path]
- (map noroot (map project [:resources-path
- :compile-path
- :source-path
- :test-path]))]
- (prxml [:decl!]
- [:classpath
- (if (directory? source-path)
- [:classpathentry {:kind "src"
- :path source-path}])
- (if (directory? resources-path)
- [:classpathentry {:kind "src"
- :path resources-path}])
- (if (directory? test-path)
- [:classpathentry {:kind "src"
- :path test-path}])
- [:classpathentry {:kind "con"
- :path "org.eclipse.jdt.launching.JRE_CONTAINER"}]
- (for [library (list-libraries project)]
- [:classpathentry {:kind "lib"
- :path (noroot library)}])
- [:classpathentry {:kind "output"
- :path compile-path}]
- ])))
+ noroot #(trim-leading-str (unix-path (str %)) root)]
+ (prxml
+ [:decl!]
+ [:classpath
+ [:classpathentry
+ {:kind "con" :path "org.eclipse.jdt.launching.JRE_CONTAINER"}]
+ (if (directory? (:java-source-path project))
+ [:classpathentry {:kind "src" :path (noroot (:java-source-path project))}])
+ [:classpathentry
+ {:kind "output" :path (noroot (:compile-path project))}]
+ (for [path (get-classpath project)]
+ [:classpathentry
+ (if (.isDirectory (File. (str path)))
+ {:kind "src" :path (noroot path)}
+ {:kind "lib" :path (noroot path)})])])))
-(defn- create-project
+(defn- print-project
"Print .project to *out*."
[project]
- (prxml [:decl!]
- [:projectDescription
- [:name (:name project)]
- [:comment (:description project)]
- [:projects]
- [:buildSpec
- [:buildCommand
- [:name "ccw.builder"]
- [:arguments]]
- [:buildCommand
- [:name "org.eclipse.jdt.core.javabuilder"]
- [:arguments]]]
- [:natures
- [:nature "ccw.nature"]
- [:nature "org.eclipse.jdt.core.javanature"]]]))
+ (prxml
+ [:decl!]
+ [:projectDescription
+ [:name (:name project)]
+ [:comment (:description project)]
+ [:projects]
+ [:buildSpec
+ [:buildCommand
+ [:name "ccw.builder"]
+ [:arguments]]
+ [:buildCommand
+ [:name "org.eclipse.jdt.core.javabuilder"]
+ [:arguments]]]
+ [:natures
+ [:nature "ccw.nature"]
+ [:nature "org.eclipse.jdt.core.javanature"]]]))
(defn eclipse
"Create Eclipse project descriptor files."
[project]
(deps project)
(binding [*prxml-indent* 2]
- (with-out-writer
- (file (:root project) ".classpath")
- (create-classpath project))
+ (with-out-writer (file (:root project) ".classpath")
+ (print-classpath project))
(println "Created .classpath")
- (with-out-writer
- (file (:root project) ".project")
- (create-project project))
+ (with-out-writer (file (:root project) ".project")
+ (print-project project))
(println "Created .project")))
Something went wrong with that request. Please try again.