use lein compile a Java project

163 views
Skip to first unread message

Gaofeng Zeng

unread,
Oct 11, 2013, 9:00:36 AM10/11/13
to clo...@googlegroups.com
How use lein compile a Java project?

I know the java-source-paths can specify the src path. But I don't know is there any option can specify the lib path that contains dependencies of Java source.

(defproject crawler "0.1.0-SNAPSHOT"
         :description "FIXME: write description"
         :url "http://example.com/FIXME"
         :license {:name "Eclipse Public License"
                   :url "http://www.eclipse.org/legal/epl-v10.html"}
         :dependencies [[org.clojure/clojure "1.5.1"]]
         :source-paths ["src/clj"]
         :java-source-paths ["java/NetSpider/src"])

Pablo Nussembaum

unread,
Oct 11, 2013, 10:09:40 AM10/11/13
to clo...@googlegroups.com
another thing that you can't do with lein and java mixed project is to
define a java-tests-path. I have that problem :(
The only solution is to use a dev profile to exclude test paths from
production code.

So I think that lein is not thought for java projects.
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

John D. Hume

unread,
Oct 11, 2013, 10:20:41 AM10/11/13
to clo...@googlegroups.com
I believe :dependencies and :resource-paths will be used for the classpath at both build and run time. Does that meet your needs?


--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Gaofeng Zeng

unread,
Oct 11, 2013, 10:26:47 PM10/11/13
to clo...@googlegroups.com

.
├── doc
│   └── intro.md
├── java
│   ├── LIBS
│   └── NetSpider
│       ├── bin
│       ├── build.xml
│       ├── invalid.src
│       └── src
├── LICENSE
├── project.clj
├── project.clj.bak
├── README.md
├── resources
│   └── lib
│       ├── commons-codec-1.4.jar
│       ├── commons-logging-1.1.1.jar
│       ├── httpclient-4.1.2.jar
│       ├── httpclient-cache-4.1.2.jar
│       ├── httpcore-4.1.2.jar
│       ├── httpmime-4.1.2.jar
│       ├── jsoup-1.6.3.jar
│       └── mongo-2.10.1.jar
├── src
│   ├── clj
│   │   └── crawler
│   └── java
│       ├── test
│       └── util
├── target
│   ├── classes
│   ├── spider.jar
│   └── stale
│       └── extract-native.dependencies
└── test
    └── crawler
        └── core_test.clj


This is my dir tree of my project. Compile the  java project need the jars that located in resources/lib, and I set this (:resource-paths ["resources/lib"]), but not effect.

Shantanu Kumar

unread,
Oct 12, 2013, 2:00:56 AM10/12/13
to clo...@googlegroups.com
Hi Gaofeng,

The JAR files are dependency artifacts that must be placed in the Maven repository. You can specify them in the :dependencies vector as below:

: dependencies [[commons-codec "1.4"]
                        [commons-logging "1.1.1"]
                        [org.apache.httpcomponents/httpclient "4.1.2"]
                        ....]

Find their maven coordinates of those artifacts on http://mvnrepository.com or http://search.maven.org/ and use them in project.clj. You need not have these JARs in resources/lib folder.

Shantanu

Gaofeng Zeng

unread,
Oct 14, 2013, 12:57:42 PM10/14/13
to clo...@googlegroups.com
thanks for you guide, this way is available.
Reply all
Reply to author
Forward
0 new messages