Re: Digest for enclojure@googlegroups.com - 1 Message in 1 Topic

510 views
Skip to first unread message

Steve Lindsay

unread,
Sep 30, 2010, 11:11:04 PM9/30/10
to encl...@googlegroups.com
On Fri, Oct 1, 2010 at 10:37 AM, <enclojur...@googlegroups.com> wrote:
>
> I create my project, then add the dependency. I then right click it to
> add the artifact manually which then seems to load into the project
> since I can see the jar tree populate with the classes etc. When i try
> to use it though the REPL just says it can't find the source files I
> am trying to use.
>

I think you need to restart the repl before any new dependencies will
be added to the classpath, and then you need to import them in the
repl if you haven't already done so in the file you loaded into the
repl. There's an arrow on the toolbar on the side of the repl window
that resets it.

>
> Lastly, I'm sure this is also something very noob, but when i try and
> run my project it asks me to locate the main class, which doesn't
> exist so I have to cancel. I have only run things by right clicking on
> the file and saying to evaluate in the REPL, how should I be compiling
> and running enclojure projects?
>

I don't think the "Run Main Project" stuff works with enclojure (if it
does you must need to tweak a few things). I generally do most of my
development with a repl running (so lots of alt-L, alt-shift-N, call
the function, rinse wash repeat), then when I want to deploy I add the
appropriate maven directives to the pom to create a runnable jar file
(using the jar and dependency plugins), which means I can do java -jar
<jarfile> and it runs. If that is the kind of thing you're looking for
give me a yell and I'll send some examples.

Very much a clojure noob though so not sure if that is a typical workflow.

- Steve

Douwe

unread,
Oct 8, 2010, 5:06:54 AM10/8/10
to encl...@googlegroups.com
Steve Lindsay <stephen.a.lindsay@...> writes:

>
> I don't think the "Run Main Project" stuff works with enclojure (if it
> does you must need to tweak a few things). I generally do most of my
> development with a repl running (so lots of alt-L, alt-shift-N, call
> the function, rinse wash repeat), then when I want to deploy I add the
> appropriate maven directives to the pom to create a runnable jar file
> (using the jar and dependency plugins), which means I can do java -jar
> <jarfile> and it runs. If that is the kind of thing you're looking for
> give me a yell and I'll send some examples.
>
> Very much a clojure noob though so not sure if that is a typical workflow.
>
> - Steve
>

Hi Steve,

I was also trying to get things going in a similar way (i.e. develop with
netbeans/enclojure/repl and then generate a stand alone jar) - after the build I
could not run the executale jar (could not find main class). I would be happy if
you can provide an example that worked for you.

Thanks,
Douwe


Steve

unread,
Oct 10, 2010, 6:46:03 AM10/10/10
to enclojure
On Oct 8, 8:06 pm, Douwe <douwe.v...@gmail.com> wrote:
>
> I was also trying to get things going in a similar way (i.e. develop with
> netbeans/enclojure/repl and then generate a stand alone jar) - after the build I
> could not run the executale jar (could not find main class). I would be happy if
> you can provide an example that worked for you.
>

Create a clojure project with the following clojure file in package
"bar":

(ns foo.bar
(:gen-class))

(defn -main []
(println "Looks like it works"))

Then add the following to the pom in the plugins section:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>foo.bar</mainClass>
<classpathPrefix>dependency</
classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
</execution>
</executions>
</plugin>

Run "mvn clean install", then "java -jar target/sample-0.0.1.jar" and
hopefully it will work.

The first plugin sets a main class in the manifest, and includes jars
from the "dependency" directory in the classpath.
The second plugin copies the dependencies into the "dependency"
directory in the "target directory.

- Steve

Douwe

unread,
Oct 11, 2010, 5:56:53 AM10/11/10
to enclojure
Thanks very much, "looks like it works" (I created a package foo
instead of bar).

Now I can just hit Shift+F11 to clean + built the jar file.

Douwe
Reply all
Reply to author
Forward
0 new messages